xoxys.unifi/tasks/certificates.yml

57 lines
1.7 KiB
YAML
Raw Normal View History

2018-07-12 21:02:27 +00:00
---
2018-07-12 22:04:34 +00:00
- name: Copy tls cert and key
copy:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
mode: "{{ item.mode }}"
with_items:
- "{ src: {{ unifi_tls_key_path }}, dest: '/etc/pki/tls/private/unifi.pem' ,mode: '0600' }"
- "{ src: {{ unifi_tls_cert_path }}, dest: '/etc/pki/tls/certs/unifi.pem',mode: '0750' }"
register: __unifi_certs
become: True
become_user: root
2018-07-12 21:02:27 +00:00
- block:
2018-07-12 22:04:34 +00:00
- set_fact:
__unifi_pkcs12_path: /tmp/unifi.p12
__unifi_keystore_path: "{{ unifi_base_dir }}/{{ unifi_version }}//UniFi/data/keystore"
- name: Create temp openssl pkcs12 keystore at '{{ __unifi_pkcs12_path }}'
2018-07-12 21:02:27 +00:00
openssl_pkcs12:
2018-07-12 22:04:34 +00:00
path: "{{ __unifi_pkcs12_path }}"
2018-07-12 21:02:27 +00:00
friendly_name: ubnt
2018-07-12 22:04:34 +00:00
privatekey_path: /etc/pki/tls/private/unifi.pem
cert_path: /etc/pki/tls/certs/unifi.pem
2018-07-12 21:26:37 +00:00
passphrase: "{{ unifi_tls_pkcs12_passphrase }}"
2018-07-12 21:02:27 +00:00
state: present
2018-07-12 22:04:34 +00:00
- name: Delete current keystore file
file:
path: "{{ __unifi_keystore_path }}"
state: absent
- name: Create java keystore at '{{ __unifi_keystore_path }}'
pkcs12_path: "/tmp/importkeystore.p12"
cert_alias: ubnt
keystore_path: "{{ __unifi_keystore_path }}"
keystore_pass: aircontrolenterprise
2018-07-12 22:05:54 +00:00
pkcs12_password: "{{ unifi_tls_pkcs12_passphrase }}"
2018-07-12 22:04:34 +00:00
keystore_create: yes
state: present
notify: __unifi_restart
- name: Adjust keystore filesystem permissions
file:
path: "{{ __unifi_keystore_path }}"
owner: "{{ unifi_user }}"
group: "{{ unifi_group }}"
mode: 0600
- name: Remove '{{ __unifi_pkcs12_path }}'
file:
path: "{{ __unifi_pkcs12_path }}"
state: absent
2018-07-12 21:02:27 +00:00
become: True
2018-07-12 22:04:34 +00:00
become_user: root
when: __unifi_certs.changed