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