Skip to content

Commit 40d5b0b

Browse files
committed
Use copy/template backup parameter
Use the backup parameter in the copy/template modules instead of using a convoluted backup system
1 parent c7cd484 commit 40d5b0b

File tree

2 files changed

+6
-38
lines changed

2 files changed

+6
-38
lines changed

tasks/conf/push-config.yml

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,9 @@
11
---
2-
- name: "(Setup: All NGINX) Check NGINX Default Configuration File Exists"
3-
stat:
4-
path: /etc/nginx/nginx.conf
5-
when: main_push_enable
6-
register: main_exists
7-
8-
- name: "(Setup: All NGINX) Backup NGINX Default Configuration File"
9-
copy:
10-
remote_src: yes
11-
src: /etc/nginx/nginx.conf
12-
dest: /etc/nginx/nginx.conf.bak
13-
when: main_exists.stat.exists and main_exists.stat.isreg and main_push_enable
14-
15-
- name: "(Setup: All NGINX) Delete NGINX Default Configuration File"
16-
file:
17-
path: /etc/nginx/nginx.conf
18-
state: absent
19-
when: main_exists.stat.exists is defined and main_exists.stat.isreg and main_push_enable
20-
212
- name: "(Setup: All NGINX) Upload NGINX Main Configuration File"
223
copy:
234
src: "{{ main_push_location }}"
245
dest: /etc/nginx/nginx.conf
6+
backup: yes
257
notify: "(Handler: All OSs) Reload NGINX"
268
when: main_push_enable
279

@@ -35,6 +17,7 @@
3517
copy:
3618
src: "{{ item }}"
3719
dest: /etc/nginx/conf.d/http
20+
backup: yes
3821
with_fileglob:
3922
- "{{ http_push_location }}"
4023
notify: "(Handler: All OSs) Reload NGINX"
@@ -50,6 +33,7 @@
5033
copy:
5134
src: "{{ item }}"
5235
dest: /etc/nginx/conf.d/stream
36+
backup: yes
5337
with_fileglob:
5438
- "{{ stream_push_location }}"
5539
notify: "(Handler: All OSs) Reload NGINX"

tasks/conf/template-config.yml

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,9 @@
11
---
2-
- name: "(Setup: All NGINX) Check NGINX Default Configuration File Exists"
3-
stat:
4-
path: /etc/nginx/nginx.conf
5-
when: main_template_enable
6-
register: main_exists
7-
8-
- name: "(Setup: All NGINX) Backup NGINX Default Configuration File"
9-
copy:
10-
remote_src: yes
11-
src: /etc/nginx/nginx.conf
12-
dest: /etc/nginx/nginx.conf.bak
13-
when: main_exists.stat.exists is defined and main_exists.stat.isreg and main_template_enable
14-
15-
- name: "(Setup: All NGINX) Delete NGINX Default Configuration File"
16-
file:
17-
path: /etc/nginx/conf.d/default.conf
18-
state: absent
19-
when: main_exists.stat.exists is defined and main_exists.stat.isreg and main_template_enable
20-
212
- name: "(Setup: All NGINX) Dynamically Generate NGINX Main Configuration File"
223
template:
234
src: nginx.conf.j2
245
dest: /etc/nginx/nginx.conf
6+
backup: yes
257
when: main_template_enable
268
notify: "(Handler: All OSs) Reload NGINX"
279

@@ -35,6 +17,7 @@
3517
template:
3618
src: "{{ item }}"
3719
dest: /etc/nginx/conf.d/http/{{ item | basename | regex_replace('\.j2','') }}
20+
backup: yes
3821
with_fileglob:
3922
- "../templates/http/*.j2"
4023
when: http_template_enable
@@ -50,6 +33,7 @@
5033
template:
5134
src: "{{ item }}"
5235
dest: /etc/nginx/conf.d/stream/{{ item | basename | regex_replace('\.j2','') }}
36+
backup: yes
5337
with_fileglob:
5438
- "../templates/stream/*.j2"
5539
when: stream_template_enable

0 commit comments

Comments
 (0)