Skip to content

Commit 9c80941

Browse files
committed
Only remove/backup nginx.conf when necessary
1 parent e2cc166 commit 9c80941

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

tasks/conf/push-config.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,21 @@
22
- name: "(Setup: All NGINX) Check NGINX Default Configuration File Exists"
33
stat:
44
path: /etc/nginx/conf.d/default.conf
5+
when: main_upload_enable
56
register: default_exists
67

78
- name: "(Setup: All NGINX) Backup NGINX Default Configuration File"
89
copy:
910
remote_src: yes
1011
src: /etc/nginx/conf.d/default.conf
1112
dest: /etc/nginx/conf.d/default.conf.bak
12-
when: default_exists.stat.exists
13+
when: default_exists.stat.exists && main_upload_enable
1314

1415
- name: "(Setup: All NGINX) Delete NGINX Default Configuration File"
1516
file:
1617
path: /etc/nginx/conf.d/default.conf
1718
state: absent
18-
when: default_exists.stat.exists
19+
when: default_exists.stat.exists && main_upload_enable
1920

2021
- name: "(Setup: All NGINX) Upload NGINX Main Configuration File"
2122
copy:

tasks/conf/template-config.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,27 @@
22
- name: "(Setup: All NGINX) Check NGINX Default Configuration File Exists"
33
stat:
44
path: /etc/nginx/conf.d/default.conf
5+
when: main_template_enable
56
register: default_exists
67

78
- name: "(Setup: All NGINX) Backup NGINX Default Configuration File"
89
copy:
910
remote_src: yes
1011
src: /etc/nginx/conf.d/default.conf
1112
dest: /etc/nginx/conf.d/default.conf.bak
12-
when: default_exists.stat.exists
13+
when: default_exists.stat.exists && main_template_enable
1314

1415
- name: "(Setup: All NGINX) Delete NGINX Default Configuration File"
1516
file:
1617
path: /etc/nginx/conf.d/default.conf
1718
state: absent
18-
when: default_exists.stat.exists
19+
when: default_exists.stat.exists && main_template_enable
1920

2021
- name: "(Setup: All NGINX) Dynamically Generate NGINX Main Configuration File"
2122
template:
2223
src: nginx.conf.j2
2324
dest: /etc/nginx/nginx.conf
25+
when: main_template_enable
2426
notify: "(Handler: All OSs) Reload NGINX"
2527

2628
- name: "(Setup: All NGINX) Ensure NGINX HTTP Directory Exists"

0 commit comments

Comments
 (0)