Skip to content

Commit e2cc166

Browse files
authored
Merge pull request #14 from RDelorier/fix-template-path-bugs
Fix template path issues
2 parents 4723ffa + 681395b commit e2cc166

File tree

3 files changed

+68
-6
lines changed

3 files changed

+68
-6
lines changed

tasks/conf/push-config.yml

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,54 @@
11
---
2+
- name: "(Setup: All NGINX) Check NGINX Default Configuration File Exists"
3+
stat:
4+
path: /etc/nginx/conf.d/default.conf
5+
register: default_exists
6+
7+
- name: "(Setup: All NGINX) Backup NGINX Default Configuration File"
8+
copy:
9+
remote_src: yes
10+
src: /etc/nginx/conf.d/default.conf
11+
dest: /etc/nginx/conf.d/default.conf.bak
12+
when: default_exists.stat.exists
13+
14+
- name: "(Setup: All NGINX) Delete NGINX Default Configuration File"
15+
file:
16+
path: /etc/nginx/conf.d/default.conf
17+
state: absent
18+
when: default_exists.stat.exists
19+
220
- name: "(Setup: All NGINX) Upload NGINX Main Configuration File"
321
copy:
422
src: "{{ main_upload_location }}"
523
dest: /etc/nginx/nginx.conf
624
notify: "(Handler: All OSs) Reload NGINX"
725
when: main_upload_enable
826

27+
- name: "(Setup: All NGINX) Ensure NGINX HTTP Directory Exists"
28+
file:
29+
path: /etc/nginx/conf.d/http
30+
state: directory
31+
when: http_template_enable
32+
933
- name: "(Setup: All NGINX) Upload NGINX HTTP Configuration Files"
1034
copy:
1135
src: "{{ item }}"
12-
dest: /etc/nginx/conf.d/
36+
dest: /etc/nginx/conf.d/http
1337
with_fileglob:
1438
- "{{ http_upload_location }}"
1539
notify: "(Handler: All OSs) Reload NGINX"
1640
when: http_upload_enable
1741

42+
- name: "(Setup: All NGINX) Ensure NGINX Stream Directory Exists"
43+
file:
44+
path: /etc/nginx/conf.d/stream
45+
state: directory
46+
when: stream_template_enable
47+
1848
- name: "(Setup: All NGINX) Upload NGINX Stream Configuration Files"
1949
copy:
2050
src: "{{ item }}"
21-
dest: /etc/nginx/conf.d/
51+
dest: /etc/nginx/conf.d/stream
2252
with_fileglob:
2353
- "{{ stream_upload_location }}"
2454
notify: "(Handler: All OSs) Reload NGINX"

tasks/conf/setup-status.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
- name: "(Setup: Open Source NGINX) Enable Open Source NGINX Status"
33
blockinfile:
4-
path: /etc/nginx/conf.d/stub_status.conf
4+
path: "{{ (http_template_enable) | ternary('/etc/nginx/conf.d/http/stub_status.conf','/etc/nginx/conf.d/stub_status.conf') }}"
55
create: yes
66
block: |
77
server {
@@ -17,7 +17,7 @@
1717

1818
- name: "(Setup: NGINX Plus) Enable NGINX Plus Status"
1919
blockinfile:
20-
path: /etc/nginx/conf.d/status.conf
20+
path: "{{ (http_template_enable) | ternary('/etc/nginx/conf.d/http/status.conf','/etc/nginx/conf.d/status.conf') }}"
2121
create: yes
2222
block: |
2323
server {

tasks/conf/template-config.yml

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,54 @@
11
---
2+
- name: "(Setup: All NGINX) Check NGINX Default Configuration File Exists"
3+
stat:
4+
path: /etc/nginx/conf.d/default.conf
5+
register: default_exists
6+
7+
- name: "(Setup: All NGINX) Backup NGINX Default Configuration File"
8+
copy:
9+
remote_src: yes
10+
src: /etc/nginx/conf.d/default.conf
11+
dest: /etc/nginx/conf.d/default.conf.bak
12+
when: default_exists.stat.exists
13+
14+
- name: "(Setup: All NGINX) Delete NGINX Default Configuration File"
15+
file:
16+
path: /etc/nginx/conf.d/default.conf
17+
state: absent
18+
when: default_exists.stat.exists
19+
220
- name: "(Setup: All NGINX) Dynamically Generate NGINX Main Configuration File"
321
template:
422
src: nginx.conf.j2
523
dest: /etc/nginx/nginx.conf
624
notify: "(Handler: All OSs) Reload NGINX"
725

26+
- name: "(Setup: All NGINX) Ensure NGINX HTTP Directory Exists"
27+
file:
28+
path: /etc/nginx/conf.d/http
29+
state: directory
30+
when: http_template_enable
31+
832
- name: "(Setup: All NGINX) Dynamically Generate NGINX HTTP Configuration Files"
933
template:
1034
src: "{{ item }}"
11-
dest: /etc/nginx/conf.d/{{ item | basename | regex_replace('\.j2','') }}
35+
dest: /etc/nginx/conf.d/http/{{ item | basename | regex_replace('\.j2','') }}
1236
with_fileglob:
1337
- "../templates/http/*.j2"
38+
when: http_template_enable
1439
notify: "(Handler: All OSs) Reload NGINX"
1540

41+
- name: "(Setup: All NGINX) Ensure NGINX Stream Directory Exists"
42+
file:
43+
path: /etc/nginx/conf.d/stream
44+
state: directory
45+
when: stream_template_enable
46+
1647
- name: "(Setup: All NGINX) Dynamically Generate NGINX Stream Configuration Files"
1748
template:
1849
src: "{{ item }}"
19-
dest: /etc/nginx/conf.d/{{ item | basename | regex_replace('\.j2','') }}
50+
dest: /etc/nginx/conf.d/stream/{{ item | basename | regex_replace('\.j2','') }}
2051
with_fileglob:
2152
- "../templates/stream/*.j2"
53+
when: stream_template_enable
2254
notify: "(Handler: All OSs) Reload NGINX"

0 commit comments

Comments
 (0)