2018-07-12 21:02:27 +00:00
|
|
|
---
|
2018-08-14 19:02:18 +00:00
|
|
|
- block:
|
2019-01-09 21:13:40 +00:00
|
|
|
- name: Create tls folder structure
|
|
|
|
file:
|
|
|
|
path: "{{ item }}"
|
|
|
|
state: directory
|
|
|
|
owner: "{{ unifi_user }}"
|
|
|
|
group: "{{ unifi_group }}"
|
|
|
|
recurse: True
|
2019-02-03 22:26:35 +00:00
|
|
|
loop:
|
2019-01-09 21:13:40 +00:00
|
|
|
- "{{ unifi_tls_certs_dir }}"
|
|
|
|
- "{{ unifi_tls_key_dir }}"
|
2018-08-14 19:26:37 +00:00
|
|
|
become: True
|
|
|
|
become_user: root
|
2018-08-14 19:02:18 +00:00
|
|
|
|
2018-09-22 13:16:07 +00:00
|
|
|
- block:
|
2019-08-04 20:31:25 +00:00
|
|
|
- name: Copy certs and private key
|
2019-01-09 21:13:40 +00:00
|
|
|
copy:
|
|
|
|
src: "{{ item.src }}"
|
|
|
|
dest: "{{ item.dest }}"
|
|
|
|
mode: "{{ item.mode }}"
|
2019-02-03 22:26:35 +00:00
|
|
|
loop:
|
2019-01-09 21:13:40 +00:00
|
|
|
- { src: "{{ unifi_tls_key_source }}", dest: '{{ unifi_tls_key_file }}', mode: '0600' }
|
|
|
|
- { src: "{{ unifi_tls_cert_source }}", dest: '{{ unifi_tls_cert_file }}', mode: '0750' }
|
|
|
|
loop_control:
|
|
|
|
label: "{{ item.dest }}"
|
2019-08-04 20:31:25 +00:00
|
|
|
register: __unifi_tls
|
2018-07-12 22:04:34 +00:00
|
|
|
|
2019-01-09 21:19:50 +00:00
|
|
|
- name: Set internal control variables
|
|
|
|
set_fact:
|
2019-01-09 21:13:40 +00:00
|
|
|
__unifi_pkcs12_path: /tmp/unifi.p12
|
|
|
|
__unifi_keystore_path: "{{ unifi_base_dir }}/{{ unifi_version }}//UniFi/data/keystore"
|
2018-10-13 17:26:32 +00:00
|
|
|
become: True
|
|
|
|
become_user: "{{ unifi_user }}"
|
2018-07-12 22:04:34 +00:00
|
|
|
|
2018-10-13 17:26:32 +00:00
|
|
|
- block:
|
2019-01-09 21:13:40 +00:00
|
|
|
- name: Create temp openssl pkcs12 keystore at '{{ __unifi_pkcs12_path }}'
|
|
|
|
openssl_pkcs12:
|
|
|
|
path: "{{ __unifi_pkcs12_path }}"
|
|
|
|
friendly_name: ubnt
|
|
|
|
privatekey_path: "{{ unifi_tls_key_file }}"
|
|
|
|
cert_path: "{{ unifi_tls_cert_file }}"
|
|
|
|
passphrase: "{{ unifi_tls_pkcs12_passphrase }}"
|
|
|
|
state: present
|
2018-07-12 22:04:34 +00:00
|
|
|
|
2019-01-09 21:13:40 +00:00
|
|
|
- name: Delete current keystore file
|
|
|
|
file:
|
|
|
|
path: "{{ __unifi_keystore_path }}"
|
|
|
|
state: absent
|
2018-07-12 22:04:34 +00:00
|
|
|
|
2019-01-09 21:13:40 +00:00
|
|
|
- name: Create java keystore at '{{ __unifi_keystore_path }}'
|
|
|
|
java_cert:
|
|
|
|
pkcs12_path: "{{ __unifi_pkcs12_path }}"
|
|
|
|
cert_alias: ubnt
|
|
|
|
pkcs12_alias: ubnt
|
|
|
|
keystore_path: "{{ __unifi_keystore_path }}"
|
|
|
|
keystore_pass: aircontrolenterprise
|
|
|
|
pkcs12_password: "{{ unifi_tls_pkcs12_passphrase }}"
|
|
|
|
keystore_create: yes
|
|
|
|
state: present
|
|
|
|
notify: __unifi_restart
|
2018-07-12 22:04:34 +00:00
|
|
|
|
2019-01-09 21:13:40 +00:00
|
|
|
- name: Adjust keystore filesystem permissions
|
|
|
|
file:
|
|
|
|
path: "{{ __unifi_keystore_path }}"
|
|
|
|
owner: "{{ unifi_user }}"
|
|
|
|
group: "{{ unifi_group }}"
|
|
|
|
mode: 0600
|
2018-07-12 22:04:34 +00:00
|
|
|
|
2019-01-09 21:13:40 +00:00
|
|
|
- name: Remove '{{ __unifi_pkcs12_path }}'
|
|
|
|
file:
|
|
|
|
path: "{{ __unifi_pkcs12_path }}"
|
|
|
|
state: absent
|
2019-08-04 20:31:25 +00:00
|
|
|
when: __unifi_tls.changed
|
2018-07-12 21:02:27 +00:00
|
|
|
become: True
|
2018-08-14 19:26:37 +00:00
|
|
|
become_user: "{{ unifi_user }}"
|