Merge pull request #14 from RDelorier/fix-template-path-bugs

Fix template path issues
This commit is contained in:
Alessandro Fael Garcia 2018-04-10 15:45:18 -07:00 committed by GitHub
commit e2cc1660cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 68 additions and 6 deletions

View File

@ -1,4 +1,22 @@
---
- name: "(Setup: All NGINX) Check NGINX Default Configuration File Exists"
stat:
path: /etc/nginx/conf.d/default.conf
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
when: default_exists.stat.exists
- name: "(Setup: All NGINX) Delete NGINX Default Configuration File"
file:
path: /etc/nginx/conf.d/default.conf
state: absent
when: default_exists.stat.exists
- name: "(Setup: All NGINX) Upload NGINX Main Configuration File"
copy:
src: "{{ main_upload_location }}"
@ -6,19 +24,31 @@
notify: "(Handler: All OSs) Reload NGINX"
when: main_upload_enable
- name: "(Setup: All NGINX) Ensure NGINX HTTP Directory Exists"
file:
path: /etc/nginx/conf.d/http
state: directory
when: http_template_enable
- name: "(Setup: All NGINX) Upload NGINX HTTP Configuration Files"
copy:
src: "{{ item }}"
dest: /etc/nginx/conf.d/
dest: /etc/nginx/conf.d/http
with_fileglob:
- "{{ http_upload_location }}"
notify: "(Handler: All OSs) Reload NGINX"
when: http_upload_enable
- name: "(Setup: All NGINX) Ensure NGINX Stream Directory Exists"
file:
path: /etc/nginx/conf.d/stream
state: directory
when: stream_template_enable
- name: "(Setup: All NGINX) Upload NGINX Stream Configuration Files"
copy:
src: "{{ item }}"
dest: /etc/nginx/conf.d/
dest: /etc/nginx/conf.d/stream
with_fileglob:
- "{{ stream_upload_location }}"
notify: "(Handler: All OSs) Reload NGINX"

View File

@ -1,7 +1,7 @@
---
- name: "(Setup: Open Source NGINX) Enable Open Source NGINX Status"
blockinfile:
path: /etc/nginx/conf.d/stub_status.conf
path: "{{ (http_template_enable) | ternary('/etc/nginx/conf.d/http/stub_status.conf','/etc/nginx/conf.d/stub_status.conf') }}"
create: yes
block: |
server {
@ -17,7 +17,7 @@
- name: "(Setup: NGINX Plus) Enable NGINX Plus Status"
blockinfile:
path: /etc/nginx/conf.d/status.conf
path: "{{ (http_template_enable) | ternary('/etc/nginx/conf.d/http/status.conf','/etc/nginx/conf.d/status.conf') }}"
create: yes
block: |
server {

View File

@ -1,22 +1,54 @@
---
- name: "(Setup: All NGINX) Check NGINX Default Configuration File Exists"
stat:
path: /etc/nginx/conf.d/default.conf
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
when: default_exists.stat.exists
- name: "(Setup: All NGINX) Delete NGINX Default Configuration File"
file:
path: /etc/nginx/conf.d/default.conf
state: absent
when: default_exists.stat.exists
- name: "(Setup: All NGINX) Dynamically Generate NGINX Main Configuration File"
template:
src: nginx.conf.j2
dest: /etc/nginx/nginx.conf
notify: "(Handler: All OSs) Reload NGINX"
- name: "(Setup: All NGINX) Ensure NGINX HTTP Directory Exists"
file:
path: /etc/nginx/conf.d/http
state: directory
when: http_template_enable
- name: "(Setup: All NGINX) Dynamically Generate NGINX HTTP Configuration Files"
template:
src: "{{ item }}"
dest: /etc/nginx/conf.d/{{ item | basename | regex_replace('\.j2','') }}
dest: /etc/nginx/conf.d/http/{{ item | basename | regex_replace('\.j2','') }}
with_fileglob:
- "../templates/http/*.j2"
when: http_template_enable
notify: "(Handler: All OSs) Reload NGINX"
- name: "(Setup: All NGINX) Ensure NGINX Stream Directory Exists"
file:
path: /etc/nginx/conf.d/stream
state: directory
when: stream_template_enable
- name: "(Setup: All NGINX) Dynamically Generate NGINX Stream Configuration Files"
template:
src: "{{ item }}"
dest: /etc/nginx/conf.d/{{ item | basename | regex_replace('\.j2','') }}
dest: /etc/nginx/conf.d/stream/{{ item | basename | regex_replace('\.j2','') }}
with_fileglob:
- "../templates/stream/*.j2"
when: stream_template_enable
notify: "(Handler: All OSs) Reload NGINX"