xoxys.unifi/tasks/nginx.yml

63 lines
2.0 KiB
YAML
Raw Normal View History

2018-08-13 20:06:00 +00:00
---
- block:
2018-09-22 13:16:07 +00:00
- 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
2018-09-22 13:16:07 +00:00
- name: Copy certs and private key to nginx proxy (files)
copy:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
mode: "{{ item.mode }}"
with_items:
2018-08-14 21:36:09 +00:00
- { 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
become_user: root
2018-10-13 16:02:39 +00:00
tags: tls_renewal
2018-08-13 20:06:00 +00:00
- block:
2018-08-13 20:23:46 +00:00
- name: Add vhost configuration file
2018-08-13 20:06:00 +00:00
template:
src: nginx/vhost.j2
dest: "{{ unifi_nginx_vhost_dir }}/unifi"
owner: root
group: root
mode: 0640
notify: __nginx_reload
2018-08-13 20:23:46 +00:00
- name: Enable unifi vhost
2018-08-13 20:06:00 +00:00
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:
2018-08-13 20:11:43 +00:00
name: allow_unifi_nginx_proxy
2018-08-13 20:06:00 +00:00
state: present
2018-08-13 21:18:10 +00:00
rules: '-A OUTPUT -m state --state NEW -p tcp -d {{ unifi_server_ip }} --dport {{ unifi_server_port }} -j ACCEPT'
2018-08-13 20:06:00 +00:00
when: unifi_nginx_iptables_enabled
delegate_to: "{{ unifi_nginx_server }}"
become: True
become_user: root