parent
7ca5074157
commit
4143fd228e
|
@ -1,30 +1,30 @@
|
||||||
---
|
---
|
||||||
- block:
|
- block:
|
||||||
- name: Copy certs and private key to nginx proxy (content)
|
- name: Copy certs and private key to nginx proxy (content)
|
||||||
copy:
|
copy:
|
||||||
content: "{{ item.src }}"
|
content: "{{ item.src }}"
|
||||||
dest: "{{ item.dest }}"
|
dest: "{{ item.dest }}"
|
||||||
mode: "{{ item.mode }}"
|
mode: "{{ item.mode }}"
|
||||||
with_items:
|
with_items:
|
||||||
- { src: "{{ unifi_tls_key_source }}", dest: '/etc/pki/tls/private/{{ unifi_nginx_tls_key_file }}', mode: '0600' }
|
- { src: "{{ unifi_tls_key_source }}", dest: '/etc/pki/tls/private/{{ unifi_nginx_tls_key_file }}', mode: '0600' }
|
||||||
- { src: "{{ unifi_tls_cert_source }}", dest: '/etc/pki/tls/certs/{{ unifi_nginx_tls_cert_file }}', mode: '0750' }
|
- { src: "{{ unifi_tls_cert_source }}", dest: '/etc/pki/tls/certs/{{ unifi_nginx_tls_cert_file }}', mode: '0750' }
|
||||||
loop_control:
|
loop_control:
|
||||||
label: "{{ item.dest }}"
|
label: "{{ item.dest }}"
|
||||||
notify: __nginx_reload
|
notify: __nginx_reload
|
||||||
when: unifi_tls_source_use_content
|
when: unifi_tls_source_use_content
|
||||||
|
|
||||||
- name: Copy certs and private key to nginx proxy (files)
|
- name: Copy certs and private key to nginx proxy (files)
|
||||||
copy:
|
copy:
|
||||||
src: "{{ item.src }}"
|
src: "{{ item.src }}"
|
||||||
dest: "{{ item.dest }}"
|
dest: "{{ item.dest }}"
|
||||||
mode: "{{ item.mode }}"
|
mode: "{{ item.mode }}"
|
||||||
with_items:
|
with_items:
|
||||||
- { src: "{{ unifi_tls_key_source }}", dest: '/etc/pki/tls/private/{{ unifi_nginx_tls_key_file }}', mode: '0600' }
|
- { src: "{{ unifi_tls_key_source }}", dest: '/etc/pki/tls/private/{{ unifi_nginx_tls_key_file }}', mode: '0600' }
|
||||||
- { src: "{{ unifi_tls_cert_source }}", dest: '/etc/pki/tls/certs/{{ unifi_nginx_tls_cert_file }}', mode: '0750' }
|
- { src: "{{ unifi_tls_cert_source }}", dest: '/etc/pki/tls/certs/{{ unifi_nginx_tls_cert_file }}', mode: '0750' }
|
||||||
loop_control:
|
loop_control:
|
||||||
label: "{{ item.dest }}"
|
label: "{{ item.dest }}"
|
||||||
notify: __nginx_reload
|
notify: __nginx_reload
|
||||||
when: unifi_tls_source_use_files
|
when: unifi_tls_source_use_files
|
||||||
delegate_to: "{{ unifi_nginx_server }}"
|
delegate_to: "{{ unifi_nginx_server }}"
|
||||||
when: unifi_nginx_tls_enabled
|
when: unifi_nginx_tls_enabled
|
||||||
become: True
|
become: True
|
||||||
|
@ -32,31 +32,31 @@
|
||||||
tags: tls_renewal
|
tags: tls_renewal
|
||||||
|
|
||||||
- block:
|
- block:
|
||||||
- name: Add vhost configuration file
|
- name: Add vhost configuration file
|
||||||
template:
|
template:
|
||||||
src: nginx/vhost.j2
|
src: nginx/vhost.j2
|
||||||
dest: "{{ unifi_nginx_vhost_dir }}/unifi"
|
dest: "{{ unifi_nginx_vhost_dir }}/unifi"
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: 0640
|
mode: 0640
|
||||||
notify: __nginx_reload
|
notify: __nginx_reload
|
||||||
|
|
||||||
- name: Enable unifi vhost
|
- name: Enable unifi vhost
|
||||||
file:
|
file:
|
||||||
src: "{{ unifi_nginx_vhost_dir }}/unifi"
|
src: "{{ unifi_nginx_vhost_dir }}/unifi"
|
||||||
dest: "{{ unifi_nginx_vhost_symlink }}/unifi"
|
dest: "{{ unifi_nginx_vhost_symlink }}/unifi"
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
state: link
|
state: link
|
||||||
notify: __nginx_reload
|
notify: __nginx_reload
|
||||||
when: unifi_nginx_vhost_symlink is defined
|
when: unifi_nginx_vhost_symlink is defined
|
||||||
|
|
||||||
- name: Open ports in iptables
|
- name: Open ports in iptables
|
||||||
iptables_raw:
|
iptables_raw:
|
||||||
name: allow_unifi_nginx_proxy
|
name: allow_unifi_nginx_proxy
|
||||||
state: present
|
state: present
|
||||||
rules: '-A OUTPUT -m state --state NEW -p tcp -d {{ unifi_server_ip }} --dport {{ unifi_server_port }} -j ACCEPT'
|
rules: '-A OUTPUT -m state --state NEW -p tcp -d {{ unifi_server_ip }} --dport {{ unifi_server_port }} -j ACCEPT'
|
||||||
when: unifi_nginx_iptables_enabled
|
when: unifi_nginx_iptables_enabled
|
||||||
delegate_to: "{{ unifi_nginx_server }}"
|
delegate_to: "{{ unifi_nginx_server }}"
|
||||||
become: True
|
become: True
|
||||||
become_user: root
|
become_user: root
|
||||||
|
|
|
@ -7,28 +7,29 @@
|
||||||
msg: Current version is '{{ unifi_current_version }}'
|
msg: Current version is '{{ unifi_current_version }}'
|
||||||
|
|
||||||
- block:
|
- block:
|
||||||
- name: Install requirements
|
- name: Install requirements
|
||||||
package:
|
package:
|
||||||
name: "{{ item }}"
|
name: "{{ item }}"
|
||||||
state: present
|
state: present
|
||||||
with_items:
|
with_items:
|
||||||
- "java-{{ unifi_openjdk_version }}-openjdk"
|
- "java-{{ unifi_openjdk_version }}-openjdk"
|
||||||
- unzip
|
- unzip
|
||||||
- wget
|
- wget
|
||||||
- pyOpenSSL
|
- pyOpenSSL
|
||||||
|
|
||||||
- name: Create group '{{ unifi_group }}'
|
- name: Create group '{{ unifi_group }}'
|
||||||
group:
|
group:
|
||||||
name: "{{ unifi_group }}"
|
name: "{{ unifi_group }}"
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: Create user '{{ unifi_user }}'
|
- name: Create user '{{ unifi_user }}'
|
||||||
user:
|
user:
|
||||||
name: "{{ unifi_user }}"
|
name: "{{ unifi_user }}"
|
||||||
group: "{{ unifi_group }}"
|
group: "{{ unifi_group }}"
|
||||||
|
|
||||||
- name: Setup local facts
|
- name: Setup local facts
|
||||||
file:
|
file:
|
||||||
path: /etc/ansible/facts.d
|
path: /etc/ansible/facts.d
|
||||||
state: directory
|
state: directory
|
||||||
become: True
|
become: True
|
||||||
|
become_user: root
|
||||||
|
|
|
@ -1,26 +1,27 @@
|
||||||
---
|
---
|
||||||
- block:
|
- block:
|
||||||
- name: Create volume group '{{ unifi_lvm_vg }}'
|
- name: Create volume group '{{ unifi_lvm_vg }}'
|
||||||
lvg:
|
lvg:
|
||||||
vg: "{{ unifi_lvm_vg }}"
|
vg: "{{ unifi_lvm_vg }}"
|
||||||
pvs: "{{ unifi_lvm_pvs|join(',') }}"
|
pvs: "{{ unifi_lvm_pvs|join(',') }}"
|
||||||
|
|
||||||
- name: Create logical volume '{{ unifi_lvm_lv }}'
|
- name: Create logical volume '{{ unifi_lvm_lv }}'
|
||||||
lvol:
|
lvol:
|
||||||
vg: "{{ unifi_lvm_vg }}"
|
vg: "{{ unifi_lvm_vg }}"
|
||||||
lv: "{{ unifi_lvm_lv }}"
|
lv: "{{ unifi_lvm_lv }}"
|
||||||
size: "{{ unifi_lvm_size }}"
|
size: "{{ unifi_lvm_size }}"
|
||||||
|
|
||||||
- name: Create filesystem for '/dev/mapper/{{ unifi_lvm_vg }}-{{ unifi_lvm_lv }}'
|
- name: Create filesystem for '/dev/mapper/{{ unifi_lvm_vg }}-{{ unifi_lvm_lv }}'
|
||||||
filesystem:
|
filesystem:
|
||||||
fstype: "{{ unifi_lvm_fstype }}"
|
fstype: "{{ unifi_lvm_fstype }}"
|
||||||
dev: "/dev/mapper/{{ unifi_lvm_vg }}-{{ unifi_lvm_lv }}"
|
dev: "/dev/mapper/{{ unifi_lvm_vg }}-{{ unifi_lvm_lv }}"
|
||||||
resizefs: True
|
resizefs: True
|
||||||
|
|
||||||
- name: Mount volume to '{{ unifi_base_dir }}'
|
- name: Mount volume to '{{ unifi_base_dir }}'
|
||||||
mount:
|
mount:
|
||||||
path: "{{ unifi_base_dir }}"
|
path: "{{ unifi_base_dir }}"
|
||||||
src: "/dev/mapper/{{ unifi_lvm_vg }}-{{ unifi_lvm_lv }}"
|
src: "/dev/mapper/{{ unifi_lvm_vg }}-{{ unifi_lvm_lv }}"
|
||||||
fstype: "{{ unifi_lvm_fstype }}"
|
fstype: "{{ unifi_lvm_fstype }}"
|
||||||
state: mounted
|
state: mounted
|
||||||
become: True
|
become: True
|
||||||
|
become_user: root
|
||||||
|
|
140
tasks/tls.yml
140
tasks/tls.yml
|
@ -1,89 +1,89 @@
|
||||||
---
|
---
|
||||||
- block:
|
- block:
|
||||||
- name: Create tls folder structure
|
- name: Create tls folder structure
|
||||||
file:
|
file:
|
||||||
path: "{{ item }}"
|
path: "{{ item }}"
|
||||||
state: directory
|
state: directory
|
||||||
owner: "{{ unifi_user }}"
|
owner: "{{ unifi_user }}"
|
||||||
group: "{{ unifi_group }}"
|
group: "{{ unifi_group }}"
|
||||||
recurse: True
|
recurse: True
|
||||||
with_items:
|
with_items:
|
||||||
- "{{ unifi_tls_certs_dir }}"
|
- "{{ unifi_tls_certs_dir }}"
|
||||||
- "{{ unifi_tls_key_dir }}"
|
- "{{ unifi_tls_key_dir }}"
|
||||||
become: True
|
become: True
|
||||||
become_user: root
|
become_user: root
|
||||||
|
|
||||||
- block:
|
- block:
|
||||||
- name: Copy certs and private key (file)
|
- name: Copy certs and private key (file)
|
||||||
copy:
|
copy:
|
||||||
src: "{{ item.src }}"
|
src: "{{ item.src }}"
|
||||||
dest: "{{ item.dest }}"
|
dest: "{{ item.dest }}"
|
||||||
mode: "{{ item.mode }}"
|
mode: "{{ item.mode }}"
|
||||||
with_items:
|
with_items:
|
||||||
- { src: "{{ unifi_tls_key_source }}", dest: '{{ unifi_tls_key_file }}', mode: '0600' }
|
- { src: "{{ unifi_tls_key_source }}", dest: '{{ unifi_tls_key_file }}', mode: '0600' }
|
||||||
- { src: "{{ unifi_tls_cert_source }}", dest: '{{ unifi_tls_cert_file }}', mode: '0750' }
|
- { src: "{{ unifi_tls_cert_source }}", dest: '{{ unifi_tls_cert_file }}', mode: '0750' }
|
||||||
loop_control:
|
loop_control:
|
||||||
label: "{{ item.dest }}"
|
label: "{{ item.dest }}"
|
||||||
register: __unifi_certs_file
|
register: __unifi_certs_file
|
||||||
when: unifi_tls_source_use_files
|
when: unifi_tls_source_use_files
|
||||||
|
|
||||||
- name: Copy certs and private key (content)
|
- name: Copy certs and private key (content)
|
||||||
copy:
|
copy:
|
||||||
content: "{{ item.src }}"
|
content: "{{ item.src }}"
|
||||||
dest: "{{ item.dest }}"
|
dest: "{{ item.dest }}"
|
||||||
mode: "{{ item.mode }}"
|
mode: "{{ item.mode }}"
|
||||||
with_items:
|
with_items:
|
||||||
- { src: "{{ unifi_tls_key_source }}", dest: '{{ unifi_tls_key_file }}', mode: '0600' }
|
- { src: "{{ unifi_tls_key_source }}", dest: '{{ unifi_tls_key_file }}', mode: '0600' }
|
||||||
- { src: "{{ unifi_tls_cert_source }}", dest: '{{ unifi_tls_cert_file }}', mode: '0750' }
|
- { src: "{{ unifi_tls_cert_source }}", dest: '{{ unifi_tls_cert_file }}', mode: '0750' }
|
||||||
loop_control:
|
loop_control:
|
||||||
label: "{{ item.dest }}"
|
label: "{{ item.dest }}"
|
||||||
register: __unifi_certs_content
|
register: __unifi_certs_content
|
||||||
when: unifi_tls_source_use_content
|
when: unifi_tls_source_use_content
|
||||||
|
|
||||||
- set_fact:
|
- set_fact:
|
||||||
__unifi_pkcs12_path: /tmp/unifi.p12
|
__unifi_pkcs12_path: /tmp/unifi.p12
|
||||||
__unifi_keystore_path: "{{ unifi_base_dir }}/{{ unifi_version }}//UniFi/data/keystore"
|
__unifi_keystore_path: "{{ unifi_base_dir }}/{{ unifi_version }}//UniFi/data/keystore"
|
||||||
become: True
|
become: True
|
||||||
become_user: "{{ unifi_user }}"
|
become_user: "{{ unifi_user }}"
|
||||||
|
|
||||||
- block:
|
- block:
|
||||||
- name: Create temp openssl pkcs12 keystore at '{{ __unifi_pkcs12_path }}'
|
- name: Create temp openssl pkcs12 keystore at '{{ __unifi_pkcs12_path }}'
|
||||||
openssl_pkcs12:
|
openssl_pkcs12:
|
||||||
path: "{{ __unifi_pkcs12_path }}"
|
path: "{{ __unifi_pkcs12_path }}"
|
||||||
friendly_name: ubnt
|
friendly_name: ubnt
|
||||||
privatekey_path: "{{ unifi_tls_key_file }}"
|
privatekey_path: "{{ unifi_tls_key_file }}"
|
||||||
cert_path: "{{ unifi_tls_cert_file }}"
|
cert_path: "{{ unifi_tls_cert_file }}"
|
||||||
passphrase: "{{ unifi_tls_pkcs12_passphrase }}"
|
passphrase: "{{ unifi_tls_pkcs12_passphrase }}"
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: Delete current keystore file
|
- name: Delete current keystore file
|
||||||
file:
|
file:
|
||||||
path: "{{ __unifi_keystore_path }}"
|
path: "{{ __unifi_keystore_path }}"
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: Create java keystore at '{{ __unifi_keystore_path }}'
|
- name: Create java keystore at '{{ __unifi_keystore_path }}'
|
||||||
java_cert:
|
java_cert:
|
||||||
pkcs12_path: "{{ __unifi_pkcs12_path }}"
|
pkcs12_path: "{{ __unifi_pkcs12_path }}"
|
||||||
cert_alias: ubnt
|
cert_alias: ubnt
|
||||||
pkcs12_alias: ubnt
|
pkcs12_alias: ubnt
|
||||||
keystore_path: "{{ __unifi_keystore_path }}"
|
keystore_path: "{{ __unifi_keystore_path }}"
|
||||||
keystore_pass: aircontrolenterprise
|
keystore_pass: aircontrolenterprise
|
||||||
pkcs12_password: "{{ unifi_tls_pkcs12_passphrase }}"
|
pkcs12_password: "{{ unifi_tls_pkcs12_passphrase }}"
|
||||||
keystore_create: yes
|
keystore_create: yes
|
||||||
state: present
|
state: present
|
||||||
notify: __unifi_restart
|
notify: __unifi_restart
|
||||||
|
|
||||||
- name: Adjust keystore filesystem permissions
|
- name: Adjust keystore filesystem permissions
|
||||||
file:
|
file:
|
||||||
path: "{{ __unifi_keystore_path }}"
|
path: "{{ __unifi_keystore_path }}"
|
||||||
owner: "{{ unifi_user }}"
|
owner: "{{ unifi_user }}"
|
||||||
group: "{{ unifi_group }}"
|
group: "{{ unifi_group }}"
|
||||||
mode: 0600
|
mode: 0600
|
||||||
|
|
||||||
- name: Remove '{{ __unifi_pkcs12_path }}'
|
- name: Remove '{{ __unifi_pkcs12_path }}'
|
||||||
file:
|
file:
|
||||||
path: "{{ __unifi_pkcs12_path }}"
|
path: "{{ __unifi_pkcs12_path }}"
|
||||||
state: absent
|
state: absent
|
||||||
become: True
|
become: True
|
||||||
become_user: "{{ unifi_user }}"
|
become_user: "{{ unifi_user }}"
|
||||||
when: __unifi_certs_file.changed or __unifi_certs_content.changed
|
when: __unifi_certs_file.changed or __unifi_certs_content.changed
|
||||||
|
|
Loading…
Reference in New Issue
Block a user