From fb36b5b643c1473f41de5414dd534f0876edf3c4 Mon Sep 17 00:00:00 2001 From: rickydelorier Date: Wed, 4 Apr 2018 19:48:31 -0400 Subject: [PATCH 1/3] Fix template path issues --- tasks/conf/template-config.yml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tasks/conf/template-config.yml b/tasks/conf/template-config.yml index 46490ec..e34ae53 100644 --- a/tasks/conf/template-config.yml +++ b/tasks/conf/template-config.yml @@ -5,18 +5,32 @@ dest: /etc/nginx/nginx.conf notify: "(Handler: All OSs) Reload NGINX" +- name: "(Setup: All NGINX) Ensures /etc/nginx/conf.d/http dir 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) Ensures /etc/nginx/conf.d/stream dir 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" From 8bf17d77c0ef9bced28168cb9b985177c3689497 Mon Sep 17 00:00:00 2001 From: Alessandro Fael Garcia Date: Thu, 5 Apr 2018 14:32:37 -0700 Subject: [PATCH 2/3] Fix path for all HTTP/Stream *.conf files Change path in all relevant tasks to ensure that HTTP and Stream NGINX *.conf files get uploaded/created in the right directory --- tasks/conf/push-config.yml | 16 ++++++++++++++-- tasks/conf/setup-status.yml | 4 ++-- tasks/conf/template-config.yml | 4 ++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/tasks/conf/push-config.yml b/tasks/conf/push-config.yml index 6dd21b6..254f9b9 100644 --- a/tasks/conf/push-config.yml +++ b/tasks/conf/push-config.yml @@ -6,19 +6,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" diff --git a/tasks/conf/setup-status.yml b/tasks/conf/setup-status.yml index c8258e9..1b1a4a9 100644 --- a/tasks/conf/setup-status.yml +++ b/tasks/conf/setup-status.yml @@ -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 { diff --git a/tasks/conf/template-config.yml b/tasks/conf/template-config.yml index e34ae53..1c51b52 100644 --- a/tasks/conf/template-config.yml +++ b/tasks/conf/template-config.yml @@ -5,7 +5,7 @@ dest: /etc/nginx/nginx.conf notify: "(Handler: All OSs) Reload NGINX" -- name: "(Setup: All NGINX) Ensures /etc/nginx/conf.d/http dir exists" +- name: "(Setup: All NGINX) Ensure NGINX HTTP Directory Exists" file: path: /etc/nginx/conf.d/http state: directory @@ -20,7 +20,7 @@ when: http_template_enable notify: "(Handler: All OSs) Reload NGINX" -- name: "(Setup: All NGINX) Ensures /etc/nginx/conf.d/stream dir exists" +- name: "(Setup: All NGINX) Ensure NGINX Stream Directory Exists" file: path: /etc/nginx/conf.d/stream state: directory From 681395baad4faf82b0f396c6bf8527fa3a7c8d5a Mon Sep 17 00:00:00 2001 From: Alessandro Fael Garcia Date: Fri, 6 Apr 2018 16:05:23 -0700 Subject: [PATCH 3/3] Backup/remove default.conf NGINX configuration file Backup and then remove the default.conf configuration file created by NGINX upon initial installation --- tasks/conf/push-config.yml | 18 ++++++++++++++++++ tasks/conf/template-config.yml | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/tasks/conf/push-config.yml b/tasks/conf/push-config.yml index 254f9b9..cbb052e 100644 --- a/tasks/conf/push-config.yml +++ b/tasks/conf/push-config.yml @@ -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 }}" diff --git a/tasks/conf/template-config.yml b/tasks/conf/template-config.yml index 1c51b52..5d54b77 100644 --- a/tasks/conf/template-config.yml +++ b/tasks/conf/template-config.yml @@ -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) Dynamically Generate NGINX Main Configuration File" template: src: nginx.conf.j2