Only remove/backup nginx.conf when necessary

This commit is contained in:
Alessandro Fael Garcia 2018-04-12 10:05:43 -07:00
parent e2cc1660cb
commit 9c80941892
2 changed files with 7 additions and 4 deletions

View File

@ -2,6 +2,7 @@
- name: "(Setup: All NGINX) Check NGINX Default Configuration File Exists"
stat:
path: /etc/nginx/conf.d/default.conf
when: main_upload_enable
register: default_exists
- name: "(Setup: All NGINX) Backup NGINX Default Configuration File"
@ -9,13 +10,13 @@
remote_src: yes
src: /etc/nginx/conf.d/default.conf
dest: /etc/nginx/conf.d/default.conf.bak
when: default_exists.stat.exists
when: default_exists.stat.exists && main_upload_enable
- name: "(Setup: All NGINX) Delete NGINX Default Configuration File"
file:
path: /etc/nginx/conf.d/default.conf
state: absent
when: default_exists.stat.exists
when: default_exists.stat.exists && main_upload_enable
- name: "(Setup: All NGINX) Upload NGINX Main Configuration File"
copy:

View File

@ -2,6 +2,7 @@
- name: "(Setup: All NGINX) Check NGINX Default Configuration File Exists"
stat:
path: /etc/nginx/conf.d/default.conf
when: main_template_enable
register: default_exists
- name: "(Setup: All NGINX) Backup NGINX Default Configuration File"
@ -9,18 +10,19 @@
remote_src: yes
src: /etc/nginx/conf.d/default.conf
dest: /etc/nginx/conf.d/default.conf.bak
when: default_exists.stat.exists
when: default_exists.stat.exists && main_template_enable
- name: "(Setup: All NGINX) Delete NGINX Default Configuration File"
file:
path: /etc/nginx/conf.d/default.conf
state: absent
when: default_exists.stat.exists
when: default_exists.stat.exists && main_template_enable
- name: "(Setup: All NGINX) Dynamically Generate NGINX Main Configuration File"
template:
src: nginx.conf.j2
dest: /etc/nginx/nginx.conf
when: main_template_enable
notify: "(Handler: All OSs) Reload NGINX"
- name: "(Setup: All NGINX) Ensure NGINX HTTP Directory Exists"