2018-02-20 21:28:14 +01:00
|
|
|
---
|
2018-04-07 01:05:23 +02:00
|
|
|
- name: "(Setup: All NGINX) Check NGINX Default Configuration File Exists"
|
|
|
|
stat:
|
|
|
|
path: /etc/nginx/conf.d/default.conf
|
2018-04-12 19:05:43 +02:00
|
|
|
when: main_template_enable
|
2018-04-07 01:05:23 +02:00
|
|
|
register: default_exists
|
|
|
|
|
|
|
|
- name: "(Setup: All NGINX) Backup NGINX Default Configuration File"
|
|
|
|
copy:
|
|
|
|
remote_src: yes
|
|
|
|
src: /etc/nginx/conf.d/default.conf
|
|
|
|
dest: /etc/nginx/conf.d/default.conf.bak
|
2018-04-12 19:05:43 +02:00
|
|
|
when: default_exists.stat.exists && main_template_enable
|
2018-04-07 01:05:23 +02:00
|
|
|
|
|
|
|
- name: "(Setup: All NGINX) Delete NGINX Default Configuration File"
|
|
|
|
file:
|
|
|
|
path: /etc/nginx/conf.d/default.conf
|
|
|
|
state: absent
|
2018-04-12 19:05:43 +02:00
|
|
|
when: default_exists.stat.exists && main_template_enable
|
2018-04-07 01:05:23 +02:00
|
|
|
|
2018-02-20 21:28:14 +01:00
|
|
|
- name: "(Setup: All NGINX) Dynamically Generate NGINX Main Configuration File"
|
|
|
|
template:
|
|
|
|
src: nginx.conf.j2
|
|
|
|
dest: /etc/nginx/nginx.conf
|
2018-04-12 19:05:43 +02:00
|
|
|
when: main_template_enable
|
2018-02-20 21:28:14 +01:00
|
|
|
notify: "(Handler: All OSs) Reload NGINX"
|
|
|
|
|
2018-04-05 23:32:37 +02:00
|
|
|
- name: "(Setup: All NGINX) Ensure NGINX HTTP Directory Exists"
|
2018-04-05 01:48:31 +02:00
|
|
|
file:
|
|
|
|
path: /etc/nginx/conf.d/http
|
|
|
|
state: directory
|
|
|
|
when: http_template_enable
|
|
|
|
|
2018-02-20 21:28:14 +01:00
|
|
|
- name: "(Setup: All NGINX) Dynamically Generate NGINX HTTP Configuration Files"
|
|
|
|
template:
|
|
|
|
src: "{{ item }}"
|
2018-04-05 01:48:31 +02:00
|
|
|
dest: /etc/nginx/conf.d/http/{{ item | basename | regex_replace('\.j2','') }}
|
2018-02-20 21:28:14 +01:00
|
|
|
with_fileglob:
|
|
|
|
- "../templates/http/*.j2"
|
2018-04-05 01:48:31 +02:00
|
|
|
when: http_template_enable
|
2018-02-20 21:28:14 +01:00
|
|
|
notify: "(Handler: All OSs) Reload NGINX"
|
|
|
|
|
2018-04-05 23:32:37 +02:00
|
|
|
- name: "(Setup: All NGINX) Ensure NGINX Stream Directory Exists"
|
2018-04-05 01:48:31 +02:00
|
|
|
file:
|
|
|
|
path: /etc/nginx/conf.d/stream
|
|
|
|
state: directory
|
|
|
|
when: stream_template_enable
|
|
|
|
|
2018-02-20 21:28:14 +01:00
|
|
|
- name: "(Setup: All NGINX) Dynamically Generate NGINX Stream Configuration Files"
|
|
|
|
template:
|
|
|
|
src: "{{ item }}"
|
2018-04-05 01:48:31 +02:00
|
|
|
dest: /etc/nginx/conf.d/stream/{{ item | basename | regex_replace('\.j2','') }}
|
2018-02-20 21:28:14 +01:00
|
|
|
with_fileglob:
|
|
|
|
- "../templates/stream/*.j2"
|
2018-04-05 01:48:31 +02:00
|
|
|
when: stream_template_enable
|
2018-02-20 21:28:14 +01:00
|
|
|
notify: "(Handler: All OSs) Reload NGINX"
|