xoxys.unifi/tasks/tls.yml

77 lines
2.3 KiB
YAML
Raw Normal View History

2018-07-12 23:02:27 +02:00
---
2018-08-14 21:02:18 +02:00
- block:
2019-01-09 22:13:40 +01:00
- name: Create tls folder structure
file:
path: "{{ item }}"
state: directory
owner: "{{ unifi_user }}"
group: "{{ unifi_group }}"
recurse: True
2019-02-03 23:26:35 +01:00
loop:
2019-01-09 22:13:40 +01:00
- "{{ unifi_tls_certs_dir }}"
- "{{ unifi_tls_key_dir }}"
2018-08-14 21:26:37 +02:00
become: True
become_user: root
2018-08-14 21:02:18 +02:00
2018-09-22 15:16:07 +02:00
- block:
2019-08-04 22:31:25 +02:00
- name: Copy certs and private key
2019-01-09 22:13:40 +01:00
copy:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
mode: "{{ item.mode }}"
2019-02-03 23:26:35 +01:00
loop:
2019-01-09 22:13:40 +01: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 22:31:25 +02:00
register: __unifi_tls
2018-07-13 00:04:34 +02:00
2019-01-09 22:19:50 +01:00
- name: Set internal control variables
set_fact:
2019-01-09 22:13:40 +01:00
__unifi_pkcs12_path: /tmp/unifi.p12
__unifi_keystore_path: "{{ unifi_base_dir }}/{{ unifi_version }}//UniFi/data/keystore"
2018-10-13 19:26:32 +02:00
become: True
become_user: "{{ unifi_user }}"
2018-07-13 00:04:34 +02:00
2018-10-13 19:26:32 +02:00
- block:
2019-01-09 22:13:40 +01: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-13 00:04:34 +02:00
2019-01-09 22:13:40 +01:00
- name: Delete current keystore file
file:
path: "{{ __unifi_keystore_path }}"
state: absent
2018-07-13 00:04:34 +02:00
2019-01-09 22:13:40 +01: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-13 00:04:34 +02:00
2019-01-09 22:13:40 +01:00
- name: Adjust keystore filesystem permissions
file:
path: "{{ __unifi_keystore_path }}"
owner: "{{ unifi_user }}"
group: "{{ unifi_group }}"
mode: 0600
2018-07-13 00:04:34 +02:00
2019-01-09 22:13:40 +01:00
- name: Remove '{{ __unifi_pkcs12_path }}'
file:
path: "{{ __unifi_pkcs12_path }}"
state: absent
2019-08-04 22:31:25 +02:00
when: __unifi_tls.changed
2018-07-12 23:02:27 +02:00
become: True
2018-08-14 21:26:37 +02:00
become_user: "{{ unifi_user }}"