xoxys.unifi/tasks/tls.yml

90 lines
2.7 KiB
YAML
Raw Normal View History

2018-07-12 21:02:27 +00:00
---
2018-08-14 19:02:18 +00:00
- block:
- name: Create tls folder structure
file:
path: "{{ item }}"
state: directory
2018-08-14 19:26:37 +00:00
owner: "{{ unifi_user }}"
group: "{{ unifi_group }}"
recurse: True
2018-08-14 19:02:18 +00:00
with_items:
- "{{ 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-08-14 19:26:37 +00:00
- block:
2018-08-14 19:02:18 +00:00
- name: Copy certs and private key (file)
copy:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
mode: "{{ item.mode }}"
with_items:
- { 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 }}"
2018-08-14 20:45:19 +00:00
register: __unifi_certs_file
2018-08-14 20:28:41 +00:00
when: unifi_tls_source_use_files
2018-08-14 19:02:18 +00:00
- name: Copy certs and private key (content)
copy:
content: "{{ item.src }}"
dest: "{{ item.dest }}"
mode: "{{ item.mode }}"
with_items:
- { 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 }}"
2018-08-14 20:45:19 +00:00
register: __unifi_certs_content
2018-08-14 20:28:41 +00:00
when: unifi_tls_source_use_content
2018-07-12 22:04:34 +00:00
become: True
2018-08-14 19:26:37 +00:00
become_user: "{{ unifi_user }}"
2018-07-12 22:04:34 +00:00
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-08-14 19:02:18 +00:00
privatekey_path: "{{ unifi_tls_key_file }}"
2018-08-14 19:37:18 +00:00
cert_path: "{{ unifi_tls_cert_file }}"
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 }}'
2018-07-12 22:10:56 +00:00
java_cert:
2018-07-12 22:44:09 +00:00
pkcs12_path: "{{ __unifi_pkcs12_path }}"
2018-07-12 22:04:34 +00:00
cert_alias: ubnt
2018-07-12 22:52:30 +00:00
pkcs12_alias: ubnt
2018-07-12 22:04:34 +00:00
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-08-14 19:26:37 +00:00
become_user: "{{ unifi_user }}"
2018-08-14 20:45:19 +00:00
when: __unifi_certs_file.changed or __unifi_certs_content.changed