Merge pull request #29 from nginxinc/(feature)/use-backup-option

Use copy/template backup parameter
This commit is contained in:
Alessandro Fael Garcia 2018-04-17 17:25:15 -07:00 committed by GitHub
commit 95801b7939
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 38 deletions

View File

@ -1,27 +1,9 @@
--- ---
- name: "(Setup: All NGINX) Check NGINX Default Configuration File Exists"
stat:
path: /etc/nginx/nginx.conf
when: main_push_enable
register: main_exists
- name: "(Setup: All NGINX) Backup NGINX Default Configuration File"
copy:
remote_src: yes
src: /etc/nginx/nginx.conf
dest: /etc/nginx/nginx.conf.bak
when: main_exists.stat.exists and main_exists.stat.isreg and main_push_enable
- name: "(Setup: All NGINX) Delete NGINX Default Configuration File"
file:
path: /etc/nginx/nginx.conf
state: absent
when: main_exists.stat.exists is defined and main_exists.stat.isreg and main_push_enable
- name: "(Setup: All NGINX) Upload NGINX Main Configuration File" - name: "(Setup: All NGINX) Upload NGINX Main Configuration File"
copy: copy:
src: "{{ main_push_location }}" src: "{{ main_push_location }}"
dest: /etc/nginx/nginx.conf dest: /etc/nginx/nginx.conf
backup: yes
notify: "(Handler: All OSs) Reload NGINX" notify: "(Handler: All OSs) Reload NGINX"
when: main_push_enable when: main_push_enable
@ -35,6 +17,7 @@
copy: copy:
src: "{{ item }}" src: "{{ item }}"
dest: /etc/nginx/conf.d/http dest: /etc/nginx/conf.d/http
backup: yes
with_fileglob: with_fileglob:
- "{{ http_push_location }}" - "{{ http_push_location }}"
notify: "(Handler: All OSs) Reload NGINX" notify: "(Handler: All OSs) Reload NGINX"
@ -50,6 +33,7 @@
copy: copy:
src: "{{ item }}" src: "{{ item }}"
dest: /etc/nginx/conf.d/stream dest: /etc/nginx/conf.d/stream
backup: yes
with_fileglob: with_fileglob:
- "{{ stream_push_location }}" - "{{ stream_push_location }}"
notify: "(Handler: All OSs) Reload NGINX" notify: "(Handler: All OSs) Reload NGINX"

View File

@ -1,27 +1,9 @@
--- ---
- name: "(Setup: All NGINX) Check NGINX Default Configuration File Exists"
stat:
path: /etc/nginx/nginx.conf
when: main_template_enable
register: main_exists
- name: "(Setup: All NGINX) Backup NGINX Default Configuration File"
copy:
remote_src: yes
src: /etc/nginx/nginx.conf
dest: /etc/nginx/nginx.conf.bak
when: main_exists.stat.exists is defined and main_exists.stat.isreg and main_template_enable
- name: "(Setup: All NGINX) Delete NGINX Default Configuration File"
file:
path: /etc/nginx/conf.d/default.conf
state: absent
when: main_exists.stat.exists is defined and main_exists.stat.isreg and main_template_enable
- name: "(Setup: All NGINX) Dynamically Generate NGINX Main Configuration File" - name: "(Setup: All NGINX) Dynamically Generate NGINX Main Configuration File"
template: template:
src: nginx.conf.j2 src: nginx.conf.j2
dest: /etc/nginx/nginx.conf dest: /etc/nginx/nginx.conf
backup: yes
when: main_template_enable when: main_template_enable
notify: "(Handler: All OSs) Reload NGINX" notify: "(Handler: All OSs) Reload NGINX"
@ -35,6 +17,7 @@
template: template:
src: "{{ item }}" src: "{{ item }}"
dest: /etc/nginx/conf.d/http/{{ item | basename | regex_replace('\.j2','') }} dest: /etc/nginx/conf.d/http/{{ item | basename | regex_replace('\.j2','') }}
backup: yes
with_fileglob: with_fileglob:
- "../templates/http/*.j2" - "../templates/http/*.j2"
when: http_template_enable when: http_template_enable
@ -50,6 +33,7 @@
template: template:
src: "{{ item }}" src: "{{ item }}"
dest: /etc/nginx/conf.d/stream/{{ item | basename | regex_replace('\.j2','') }} dest: /etc/nginx/conf.d/stream/{{ item | basename | regex_replace('\.j2','') }}
backup: yes
with_fileglob: with_fileglob:
- "../templates/stream/*.j2" - "../templates/stream/*.j2"
when: stream_template_enable when: stream_template_enable