From d294779f8be1c7f739f4e6a2df77ac9b39dfe152 Mon Sep 17 00:00:00 2001 From: Alessandro Fael Garcia Date: Fri, 14 Sep 2018 16:28:20 -0700 Subject: [PATCH 1/4] Rename variables All variables are now prefixed with `nginx` - resolves #57 --- README.md | 88 +++++++++++++------------- defaults/main.yml | 70 ++++++++++---------- tasks/conf/push-config.yml | 10 +-- tasks/conf/setup-status.yml | 4 +- tasks/conf/template-config.yml | 10 +-- tasks/main.yml | 18 +++--- tasks/modules/install-geoip.yml | 4 +- tasks/modules/install-image-filter.yml | 4 +- tasks/modules/install-modules.yml | 2 +- tasks/modules/install-njs.yml | 4 +- tasks/modules/install-perl.yml | 4 +- tasks/modules/install-rtmp.yml | 4 +- tasks/modules/install-xslt.yml | 4 +- tasks/opensource/install-oss.yml | 2 +- tasks/plus/install-plus.yml | 2 +- tasks/unit/install-unit.yml | 2 +- tests/playbooks/nginx-push.yml | 8 +-- tests/playbooks/nginx-stable.yml | 2 +- tests/playbooks/nginx-template.yml | 6 +- tests/playbooks/nginx-unit.yml | 4 +- 20 files changed, 126 insertions(+), 126 deletions(-) diff --git a/README.md b/README.md index 923d2b4..1c875cc 100644 --- a/README.md +++ b/README.md @@ -173,13 +173,13 @@ nginx_enable: true # Specify which version of NGINX you want to install. # Options are 'opensource' or 'plus'. # Default is 'opensource'. -type: opensource +nginx_type: opensource # Specify repository origin for NGINX Open Source. # Options are 'nginx_repository' or 'os_repository'. -# Only works if 'type' is set to 'opensource'. +# Only works if 'nginx_type' is set to 'opensource'. # Default is nginx_repository. -install_from: nginx_repository +nginx_install_from: nginx_repository # Specify source repository for NGINX Open Source. # Only works if 'install_from' is set to 'nginx_repository'. @@ -197,21 +197,21 @@ nginx_repository: # Options are 'mainline' or 'stable'. # Only works if 'install_from' is set to 'nginx_repository'. # Default is mainline. -branch: mainline +nginx_branch: mainline # Location of your NGINX Plus license in your local machine. # Default is the files folder within the NGINX Ansible role. -license: +nginx_license: certificate: license/nginx-repo.crt key: license/nginx-repo.key # Delete NGINX Plus license after installation for security purposes. # Default is true. -delete_license: true +nginx_delete_license: true # Install NGINX JavaScript, Perl, ModSecurity WAF (NGINX Plus only), GeoIP, Image-Filter, RTMP Media Streaming, and/or XSLT modules. # Default is false. -modules: +nginx_modules: njs: false perl: false waf: false @@ -224,58 +224,58 @@ modules: # Use your NGINX Amplify API key. # Requires access to either the NGINX stub status or the NGINX Plus REST API. # Default is null. -amplify_enable: false -amplify_api_key: null +nginx_amplify_enable: false +nginx_amplify_api_key: null # Install NGINX Controller. # Use your NGINX Controller API key and NGINX Controller API endpoint. # Requires NGINX Plus and write access to the NGINX Plus REST API. # Default is null. -controller_enable: false -controller_api_key: null -controller_api_endpoint: null +nginx_controller_enable: false +nginx_controller_api_key: null +nginx_controller_api_endpoint: null # Install NGINX Unit and NGINX Unit modules. # Use a list of supported NGINX Unit modules. # Default is false. -unit_enable: false -unit_modules: null +nginx_unit_enable: false +nginx_unit_modules: null # Enable NGINX status data. # Will enable 'stub_status' in NGINX Open Source and 'status' in NGINX Plus. # Default is false. -status_enable: false +nginx_status_enable: false # Enable NGINX Plus REST API, write access to the REST API, and NGINX Plus dashboard. # Requires NGINX Plus. # Default is false. -rest_api_enable: false -rest_api_write: false -rest_api_dashboard: false +nginx_rest_api_enable: false +nginx_rest_api_write: false +nginx_rest_api_dashboard: false # Enable uploading NGINX configuration files to your system. # Default for uploading files is false. # Default location of files is the files folder within the NGINX Ansible role. -main_push_enable: false -main_push_location: conf/nginx.conf -http_push_enable: false -http_push_location: conf/http/*.conf -stream_push_enable: false -stream_push_location: conf/stream/*.conf +nginx_main_push_enable: false +nginx_main_push_location: conf/nginx.conf +nginx_http_push_enable: false +nginx_http_push_location: conf/http/*.conf +nginx_stream_push_enable: false +nginx_stream_push_location: conf/stream/*.conf # Configuration variables to create a templated NGINX configuration. # Defaults are the values found in a fresh NGINX installation. -main_template_enable: false -main_template_user: nginx -main_template_worker_processes: auto -main_template_error_level: warn -main_template_worker_connections: 1024 -http_template_enable: false -http_template_keepalive_timeout: 65 -http_template_listen: 80 -http_template_server_name: localhost -stream_template_enable: false -stream_template_listen: 12345 +nginx_main_template_enable: false +nginx_main_template_user: nginx +nginx_main_template_worker_processes: auto +nginx_main_template_error_level: warn +nginx_main_template_worker_connections: 1024 +nginx_http_template_enable: false +nginx_http_template_keepalive_timeout: 65 +nginx_http_template_listen: 80 +nginx_http_template_server_name: localhost +nginx_stream_template_enable: false +nginx_stream_template_listen: 12345 ``` Dependencies @@ -315,7 +315,7 @@ This is a sample playbook file for deploying the Ansible Galaxy NGINX role in a roles: - role: nginxinc.nginx vars: - type: plus + nginx_type: plus ``` This is a sample playbook file for deploying the Ansible Galaxy NGINX role in a localhost to install NGINX Plus and the NGINX Controller agent. @@ -326,12 +326,12 @@ This is a sample playbook file for deploying the Ansible Galaxy NGINX role in a roles: - role: nginxinc.nginx vars: - type: plus - rest_api_enable: true - rest_api_write: true - controller_enable: true - controller_api_key: - controller_api_endpoint: https:///1.4 + nginx_type: plus + nginx_rest_api_enable: true + nginx_rest_api_write: true + nginx_controller_enable: true + nginx_controller_api_key: + nginx_controller_api_endpoint: https:///1.4 ``` This is a sample playbook file for deploying the Ansible Galaxy NGINX role in a localhost to install NGINX Unit and the PHP/Perl NGINX Unit language modules. @@ -344,8 +344,8 @@ This is a sample playbook file for deploying the Ansible Galaxy NGINX role in a - role: nginxinc.nginx vars: nginx_enable: false - unit_enable: true - unit_modules: + nginx_unit_enable: true + nginx_unit_modules: - unit-php - unit-perl ``` diff --git a/defaults/main.yml b/defaults/main.yml index c2c6ef5..911d91e 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -6,13 +6,13 @@ nginx_enable: true # Specify which version of NGINX you want to install. # Options are 'opensource' or 'plus'. # Default is 'opensource'. -type: opensource +nginx_type: opensource # Specify repository origin for NGINX Open Source. # Options are 'nginx_repository' or 'os_repository'. -# Only works if 'type' is set to 'opensource'. +# Only works if 'nginx_type' is set to 'opensource'. # Default is nginx_repository. -install_from: nginx_repository +nginx_install_from: nginx_repository # Specify source repository for NGINX Open Source. # Only works if 'install_from' is set to 'nginx_repository'. @@ -30,21 +30,21 @@ nginx_repository: # Options are 'mainline' or 'stable'. # Only works if 'install_from' is set to 'nginx_repository'. # Default is mainline. -branch: mainline +nginx_branch: mainline # Location of your NGINX Plus license in your local machine. # Default is the files folder within the NGINX Ansible role. -license: +nginx_license: certificate: license/nginx-repo.crt key: license/nginx-repo.key # Delete NGINX Plus license after installation for security purposes. # Default is true. -delete_license: true +nginx_delete_license: true # Install NGINX JavaScript, Perl, ModSecurity WAF (NGINX Plus only), GeoIP, Image-Filter, RTMP Media Streaming, and/or XSLT modules. # Default is false. -modules: +nginx_modules: njs: false perl: false waf: false @@ -57,55 +57,55 @@ modules: # Use your NGINX Amplify API key. # Requires access to either the NGINX stub status or the NGINX Plus REST API. # Default is null. -amplify_enable: false -amplify_api_key: null +nginx_amplify_enable: false +nginx_amplify_api_key: null # Install NGINX Controller. # Use your NGINX Controller API key and NGINX Controller API endpoint. # Requires NGINX Plus and write access to the NGINX Plus REST API. # Default is null. -controller_enable: false -controller_api_key: null -controller_api_endpoint: null +nginx_controller_enable: false +nginx_controller_api_key: null +nginx_controller_api_endpoint: null # Install NGINX Unit and NGINX Unit modules. # Use a list of supported NGINX Unit modules. # Default is false. -unit_enable: false -unit_modules: null +nginx_unit_enable: false +nginx_unit_modules: null # Enable NGINX status data. # Will enable 'stub_status' in NGINX Open Source and 'status' in NGINX Plus. # Default is false. -status_enable: false +nginx_status_enable: false # Enable NGINX Plus REST API, write access to the REST API, and NGINX Plus dashboard. # Requires NGINX Plus. # Default is false. -rest_api_enable: false -rest_api_write: false -rest_api_dashboard: false +nginx_rest_api_enable: false +nginx_rest_api_write: false +nginx_rest_api_dashboard: false # Enable uploading NGINX configuration files to your system. # Default for uploading files is false. # Default location of files is the files folder within the NGINX Ansible role. -main_push_enable: false -main_push_location: conf/nginx.conf -http_push_enable: false -http_push_location: conf/http/*.conf -stream_push_enable: false -stream_push_location: conf/stream/*.conf +nginx_main_push_enable: false +nginx_main_push_location: conf/nginx.conf +nginx_http_push_enable: false +nginx_http_push_location: conf/http/*.conf +nginx_stream_push_enable: false +nginx_stream_push_location: conf/stream/*.conf # Configuration variables to create a templated NGINX configuration. # Defaults are the values found in a fresh NGINX installation. -main_template_enable: false -main_template_user: nginx -main_template_worker_processes: auto -main_template_error_level: warn -main_template_worker_connections: 1024 -http_template_enable: false -http_template_keepalive_timeout: 65 -http_template_listen: 80 -http_template_server_name: localhost -stream_template_enable: false -stream_template_listen: 12345 +nginx_main_template_enable: false +nginx_main_template_user: nginx +nginx_main_template_worker_processes: auto +nginx_main_template_error_level: warn +nginx_main_template_worker_connections: 1024 +nginx_http_template_enable: false +nginx_http_template_keepalive_timeout: 65 +nginx_http_template_listen: 80 +nginx_http_template_server_name: localhost +nginx_stream_template_enable: false +nginx_stream_template_listen: 12345 diff --git a/tasks/conf/push-config.yml b/tasks/conf/push-config.yml index b996889..e1ab3c7 100644 --- a/tasks/conf/push-config.yml +++ b/tasks/conf/push-config.yml @@ -5,13 +5,13 @@ dest: /etc/nginx/nginx.conf backup: yes notify: "(Handler: All OSs) Reload NGINX" - when: main_push_enable + when: nginx_main_push_enable - name: "(Setup: All NGINX) Ensure NGINX HTTP Directory Exists" file: path: /etc/nginx/conf.d/http state: directory - when: http_push_enable + when: nginx_http_push_enable - name: "(Setup: All NGINX) Upload NGINX HTTP Configuration Files" copy: @@ -21,13 +21,13 @@ with_fileglob: - "{{ http_push_location }}" notify: "(Handler: All OSs) Reload NGINX" - when: http_push_enable + when: nginx_http_push_enable - name: "(Setup: All NGINX) Ensure NGINX Stream Directory Exists" file: path: /etc/nginx/conf.d/stream state: directory - when: stream_push_enable + when: nginx_stream_push_enable - name: "(Setup: All NGINX) Upload NGINX Stream Configuration Files" copy: @@ -37,4 +37,4 @@ with_fileglob: - "{{ stream_push_location }}" notify: "(Handler: All OSs) Reload NGINX" - when: stream_push_enable + when: nginx_stream_push_enable diff --git a/tasks/conf/setup-status.yml b/tasks/conf/setup-status.yml index e1f609a..7a373a7 100644 --- a/tasks/conf/setup-status.yml +++ b/tasks/conf/setup-status.yml @@ -12,7 +12,7 @@ deny all; } } - when: type == "opensource" + when: nginx_type == "opensource" notify: "(Handler: All OSs) Reload NGINX" - name: "(Setup: NGINX Plus) Enable NGINX Plus Status" @@ -28,5 +28,5 @@ deny all; } } - when: type == "plus" + when: nginx_type == "plus" notify: "(Handler: All OSs) Reload NGINX" diff --git a/tasks/conf/template-config.yml b/tasks/conf/template-config.yml index 49c8756..c7ecef7 100644 --- a/tasks/conf/template-config.yml +++ b/tasks/conf/template-config.yml @@ -4,14 +4,14 @@ src: nginx.conf.j2 dest: /etc/nginx/nginx.conf backup: yes - when: main_template_enable + when: nginx_main_template_enable 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 + when: nginx_http_template_enable - name: "(Setup: All NGINX) Dynamically Generate NGINX HTTP Configuration Files" template: @@ -20,14 +20,14 @@ backup: yes with_fileglob: - "../templates/http/*.j2" - when: http_template_enable + when: nginx_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 + when: nginx_stream_template_enable - name: "(Setup: All NGINX) Dynamically Generate NGINX Stream Configuration Files" template: @@ -36,5 +36,5 @@ backup: yes with_fileglob: - "../templates/stream/*.j2" - when: stream_template_enable + when: nginx_stream_template_enable notify: "(Handler: All OSs) Reload NGINX" diff --git a/tasks/main.yml b/tasks/main.yml index 925589e..6544143 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -11,33 +11,33 @@ block: - import_tasks: opensource/install-oss.yml - when: type == "opensource" + when: nginx_type == "opensource" - import_tasks: plus/install-plus.yml - when: type == "plus" + when: nginx_type == "plus" - import_tasks: modules/install-modules.yml when: true in modules.values() - import_tasks: conf/push-config.yml - when: main_push_enable or http_push_enable or stream_push_enable + when: nginx_main_push_enable or nginx_http_push_enable or nginx_stream_push_enable - import_tasks: conf/template-config.yml - when: main_template_enable or http_template_enable or stream_template_enable + when: nginx_main_template_enable or nginx_http_template_enable or nginx_stream_template_enable - import_tasks: conf/setup-status.yml - when: status_enable + when: nginx_status_enable - import_tasks: conf/setup-rest-api.yml - when: rest_api_enable and type == "plus" + when: nginx_rest_api_enable and nginx_type == "plus" when: nginx_enable - import_tasks: amplify/install-amplify.yml - when: amplify_enable and amplify_api_key is defined and amplify_api_key + when: nginx_amplify_enable and nginx_amplify_api_key is defined and nginx_amplify_api_key - import_tasks: controller/install-controller.yml - when: controller_enable and controller_api_key is defined and controller_api_key and controller_api_endpoint is defined and controller_api_endpoint + when: nginx_controller_enable and nginx_controller_api_key is defined and nginx_controller_api_key and nginx_controller_api_endpoint is defined and nginx_controller_api_endpoint - import_tasks: unit/install-unit.yml - when: unit_enable + when: nginx_unit_enable diff --git a/tasks/modules/install-geoip.yml b/tasks/modules/install-geoip.yml index 3dd08f3..f03c6d6 100644 --- a/tasks/modules/install-geoip.yml +++ b/tasks/modules/install-geoip.yml @@ -3,13 +3,13 @@ package: name: nginx-module-geoip state: present - when: type == "opensource" + when: nginx_type == "opensource" - name: "(Install: All OSs) Install NGINX Plus GeoIP Module" package: name: nginx-plus-module-geoip state: present - when: type == "plus" + when: nginx_type == "plus" - name: "(Setup: All NGINX) Load NGINX GeoIP Module" blockinfile: diff --git a/tasks/modules/install-image-filter.yml b/tasks/modules/install-image-filter.yml index ab89bc6..bb4cf13 100644 --- a/tasks/modules/install-image-filter.yml +++ b/tasks/modules/install-image-filter.yml @@ -3,13 +3,13 @@ package: name: nginx-module-image-filter state: present - when: type == "opensource" + when: nginx_type == "opensource" - name: "(Install: All OSs) Install NGINX Plus Image Filter Module" package: name: nginx-plus-module-image-filter state: present - when: type == "plus" + when: nginx_type == "plus" - name: "(Setup: All NGINX) Load NGINX Image Filter Module" lineinfile: diff --git a/tasks/modules/install-modules.yml b/tasks/modules/install-modules.yml index 52ae7c0..0f0f747 100644 --- a/tasks/modules/install-modules.yml +++ b/tasks/modules/install-modules.yml @@ -18,4 +18,4 @@ when: modules.xslt | default(false) - import_tasks: install-waf.yml - when: modules.waf | default(false) and type == "plus" + when: modules.waf | default(false) and nginx_type == "plus" diff --git a/tasks/modules/install-njs.yml b/tasks/modules/install-njs.yml index 54ab926..d8b9eea 100644 --- a/tasks/modules/install-njs.yml +++ b/tasks/modules/install-njs.yml @@ -3,13 +3,13 @@ package: name: nginx-module-njs state: present - when: type == "opensource" + when: nginx_type == "opensource" - name: "(Install: All OSs) Install NGINX Plus JavaScript Module" package: name: nginx-plus-module-njs state: present - when: type == "plus" + when: nginx_type == "plus" - name: "(Setup: All NGINX) Load NGINX JavaScript Module" blockinfile: diff --git a/tasks/modules/install-perl.yml b/tasks/modules/install-perl.yml index e14ef06..e30c804 100644 --- a/tasks/modules/install-perl.yml +++ b/tasks/modules/install-perl.yml @@ -3,13 +3,13 @@ package: name: nginx-module-perl state: present - when: type == "opensource" + when: nginx_type == "opensource" - name: "(Install: All OSs) Install NGINX Plus Perl Module" package: name: nginx-plus-module-perl state: present - when: type == "plus" + when: nginx_type == "plus" - name: "(Setup: All NGINX) Load NGINX Perl Module" lineinfile: diff --git a/tasks/modules/install-rtmp.yml b/tasks/modules/install-rtmp.yml index 70c7831..6cd8a1d 100644 --- a/tasks/modules/install-rtmp.yml +++ b/tasks/modules/install-rtmp.yml @@ -3,13 +3,13 @@ package: name: nginx-module-rtmp state: present - when: type == "opensource" + when: nginx_type == "opensource" - name: "(Install: All OSs) Install NGINX Plus RTMP Module" package: name: nginx-plus-module-rtmp state: present - when: type == "plus" + when: nginx_type == "plus" - name: "(Setup: All NGINX) Load NGINX RTMP Module" lineinfile: diff --git a/tasks/modules/install-xslt.yml b/tasks/modules/install-xslt.yml index 270d115..e383c1c 100644 --- a/tasks/modules/install-xslt.yml +++ b/tasks/modules/install-xslt.yml @@ -3,13 +3,13 @@ package: name: nginx-module-xslt state: present - when: type == "opensource" + when: nginx_type == "opensource" - name: "(Install: All OSs) Install NGINX Plus XSLT Module" package: name: nginx-plus-module-xslt state: present - when: type == "plus" + when: nginx_type == "plus" - name: "(Setup: All NGINX) Load NGINX XSLT Module" lineinfile: diff --git a/tasks/opensource/install-oss.yml b/tasks/opensource/install-oss.yml index 2f40f47..aa2d6fd 100644 --- a/tasks/opensource/install-oss.yml +++ b/tasks/opensource/install-oss.yml @@ -34,5 +34,5 @@ package: name: nginx state: present - when: install_from == "os_repository" + when: nginx_install_from == "os_repository" notify: "(Handler: All OSs) Start NGINX" diff --git a/tasks/plus/install-plus.yml b/tasks/plus/install-plus.yml index c71db4d..9755711 100644 --- a/tasks/plus/install-plus.yml +++ b/tasks/plus/install-plus.yml @@ -20,4 +20,4 @@ notify: "(Handler: All OSs) Start NGINX" - import_tasks: delete-license.yml - when: delete_license + when: nginx_delete_license diff --git a/tasks/unit/install-unit.yml b/tasks/unit/install-unit.yml index a616832..4093fe8 100644 --- a/tasks/unit/install-unit.yml +++ b/tasks/unit/install-unit.yml @@ -23,4 +23,4 @@ notify: "(Handler: FreeBSD) Start NGINX Unit" - import_tasks: install-modules.yml - when: unit_modules is defined and unit_modules + when: nginx_unit_modules is defined and nginx_unit_modules diff --git a/tests/playbooks/nginx-push.yml b/tests/playbooks/nginx-push.yml index 92b753b..fb32e18 100644 --- a/tests/playbooks/nginx-push.yml +++ b/tests/playbooks/nginx-push.yml @@ -5,7 +5,7 @@ roles: - ansible-role-nginx vars: - main_push_enable: true - main_push_location: ../files/nginx.conf - http_push_enable: true - http_push_location: ../files/http/*.conf + nginx_main_push_enable: true + nginx_main_push_location: ../files/nginx.conf + nginx_http_push_enable: true + nginx_http_push_location: ../files/http/*.conf diff --git a/tests/playbooks/nginx-stable.yml b/tests/playbooks/nginx-stable.yml index 27ef08c..a6967a2 100644 --- a/tests/playbooks/nginx-stable.yml +++ b/tests/playbooks/nginx-stable.yml @@ -5,4 +5,4 @@ roles: - ansible-role-nginx vars: - branch: stable + nginx_branch: stable diff --git a/tests/playbooks/nginx-template.yml b/tests/playbooks/nginx-template.yml index 1c95862..ba29177 100644 --- a/tests/playbooks/nginx-template.yml +++ b/tests/playbooks/nginx-template.yml @@ -5,6 +5,6 @@ roles: - ansible-role-nginx vars: - http_template_enable: true - http_template_keepalive_timeout: 70 - http_template_listen: 82 + nginx_http_template_enable: true + nginx_http_template_keepalive_timeout: 70 + nginx_http_template_listen: 82 diff --git a/tests/playbooks/nginx-unit.yml b/tests/playbooks/nginx-unit.yml index 762373a..82e4900 100644 --- a/tests/playbooks/nginx-unit.yml +++ b/tests/playbooks/nginx-unit.yml @@ -6,7 +6,7 @@ - ansible-role-nginx vars: nginx_enable: false - unit_enable: true - unit_modules: + nginx_unit_enable: true + nginx_unit_modules: - unit-php - unit-perl From fd3a21f0c023e83cf00622c269c9ade96dcd3193 Mon Sep 17 00:00:00 2001 From: Alessandro Fael Garcia Date: Fri, 14 Sep 2018 17:01:49 -0700 Subject: [PATCH 2/4] Fix repository variables --- defaults/main.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 911d91e..0ffbdf2 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -19,12 +19,12 @@ nginx_install_from: nginx_repository # Defaults are the official NGINX repositories. nginx_repository: debian: - - deb https://nginx.org/packages/{{ (branch == 'mainline') | ternary('mainline/', '') }}{{ ansible_distribution|lower }}/ {{ ansible_distribution_release }} nginx - - deb-src https://nginx.org/packages/{{ (branch == 'mainline') | ternary('mainline/', '') }}{{ ansible_distribution|lower }}/ {{ ansible_distribution_release }} nginx + - deb https://nginx.org/packages/{{ (nginx_branch == 'mainline') | ternary('mainline/', '') }}{{ ansible_distribution|lower }}/ {{ ansible_distribution_release }} nginx + - deb-src https://nginx.org/packages/{{ (nginx_branch == 'mainline') | ternary('mainline/', '') }}{{ ansible_distribution|lower }}/ {{ ansible_distribution_release }} nginx redhat: - - https://nginx.org/packages/{{ (branch == 'mainline') | ternary('mainline/', '') }}{{ (ansible_distribution == "RedHat") | ternary('rhel/', 'centos/') }}{{ ansible_distribution_major_version|int }}/$basearch/ + - https://nginx.org/packages/{{ (nginx_branch == 'mainline') | ternary('mainline/', '') }}{{ (ansible_distribution == "RedHat") | ternary('rhel/', 'centos/') }}{{ ansible_distribution_major_version|int }}/$basearch/ suse: - - https://nginx.org/packages/{{ (branch == 'mainline') | ternary('mainline/', '') }}sles/12 + - https://nginx.org/packages/{{ (nginx_branch == 'mainline') | ternary('mainline/', '') }}sles/12 # Specify which branch of NGINX Open Source you want to install. # Options are 'mainline' or 'stable'. From 9fea52256651c227e8a1742a1e33cc893f6d39dc Mon Sep 17 00:00:00 2001 From: Alessandro Fael Garcia Date: Fri, 14 Sep 2018 17:27:12 -0700 Subject: [PATCH 3/4] Fix more repository variables --- tasks/conf/push-config.yml | 6 +++--- tasks/conf/setup-rest-api.yml | 6 +++--- tasks/conf/setup-status.yml | 4 ++-- tasks/controller/install-controller.yml | 4 ++-- tasks/opensource/install-oss.yml | 2 +- tasks/unit/install-modules.yml | 4 ++-- templates/http/default.conf.j2 | 4 ++-- templates/nginx.conf.j2 | 14 +++++++------- templates/stream/default.conf.j2 | 2 +- 9 files changed, 23 insertions(+), 23 deletions(-) diff --git a/tasks/conf/push-config.yml b/tasks/conf/push-config.yml index e1ab3c7..2768398 100644 --- a/tasks/conf/push-config.yml +++ b/tasks/conf/push-config.yml @@ -1,7 +1,7 @@ --- - name: "(Setup: All NGINX) Upload NGINX Main Configuration File" copy: - src: "{{ main_push_location }}" + src: "{{ nginx_main_push_location }}" dest: /etc/nginx/nginx.conf backup: yes notify: "(Handler: All OSs) Reload NGINX" @@ -19,7 +19,7 @@ dest: /etc/nginx/conf.d/http backup: yes with_fileglob: - - "{{ http_push_location }}" + - "{{ nginx_http_push_location }}" notify: "(Handler: All OSs) Reload NGINX" when: nginx_http_push_enable @@ -35,6 +35,6 @@ dest: /etc/nginx/conf.d/stream backup: yes with_fileglob: - - "{{ stream_push_location }}" + - "{{ nginx_stream_push_location }}" notify: "(Handler: All OSs) Reload NGINX" when: nginx_stream_push_enable diff --git a/tasks/conf/setup-rest-api.yml b/tasks/conf/setup-rest-api.yml index 67abbba..66f69e2 100644 --- a/tasks/conf/setup-rest-api.yml +++ b/tasks/conf/setup-rest-api.yml @@ -1,19 +1,19 @@ --- - name: "(Setup: NGINX Plus) Setup NGINX Plus API" blockinfile: - path: "{{ (http_template_enable) | ternary('/etc/nginx/conf.d/http/api.conf','/etc/nginx/conf.d/api.conf') }}" + path: "{{ (nginx_http_template_enable) | ternary('/etc/nginx/conf.d/http/api.conf','/etc/nginx/conf.d/api.conf') }}" create: yes block: | server { listen 8080; location /api { - {% if rest_api_write %} + {% if nginx_rest_api_write %} api write=on; {% else %} api; {% endif %} } - {% if rest_api_dashboard %} + {% if nginx_rest_api_dashboard %} location = /dashboard.html { root /usr/share/nginx/html; } diff --git a/tasks/conf/setup-status.yml b/tasks/conf/setup-status.yml index 7a373a7..fd4d96c 100644 --- a/tasks/conf/setup-status.yml +++ b/tasks/conf/setup-status.yml @@ -1,7 +1,7 @@ --- - name: "(Setup: NGINX Open Source) Enable NGINX Open Source Status" blockinfile: - path: "{{ (http_template_enable) | ternary('/etc/nginx/conf.d/http/stub_status.conf','/etc/nginx/conf.d/stub_status.conf') }}" + path: "{{ (nginx_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: "{{ (http_template_enable) | ternary('/etc/nginx/conf.d/http/status.conf','/etc/nginx/conf.d/status.conf') }}" + path: "{{ (nginx_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/controller/install-controller.yml b/tasks/controller/install-controller.yml index 0dd4bde..2e818c5 100644 --- a/tasks/controller/install-controller.yml +++ b/tasks/controller/install-controller.yml @@ -26,13 +26,13 @@ lineinfile: dest: /etc/controller-agent/agent.conf regexp: api_key =.* - line: "api_key = {{ controller_api_key }}" + line: "api_key = {{ nginx_controller_api_key }}" - name: "(Setup: All OSs) Configure NGINX Controller Agent API URL" lineinfile: dest: /etc/controller-agent/agent.conf regexp: api_url =.* - line: "api_url = {{ controller_api_endpoint }}" + line: "api_url = {{ nginx_controller_api_endpoint }}" - name: "(Setup: All OSs) Configure NGINX Controller Agent API Hostname" lineinfile: diff --git a/tasks/opensource/install-oss.yml b/tasks/opensource/install-oss.yml index aa2d6fd..a76e7c5 100644 --- a/tasks/opensource/install-oss.yml +++ b/tasks/opensource/install-oss.yml @@ -28,7 +28,7 @@ when: ansible_os_family == "FreeBSD" notify: "(Handler: All OSs) Start NGINX" - when: install_from == "nginx_repository" + when: nginx_install_from == "nginx_repository" - name: "(Install: Debian/Ubuntu/CentOS/RedHat/FreeBSD) Install NGINX" package: diff --git a/tasks/unit/install-modules.yml b/tasks/unit/install-modules.yml index 09d5cec..cc5ce94 100644 --- a/tasks/unit/install-modules.yml +++ b/tasks/unit/install-modules.yml @@ -3,7 +3,7 @@ package: name: "{{ item }}" state: present - with_items: "{{ unit_modules }}" + with_items: "{{ nginx_unit_modules }}" when: ansible_os_family != "FreeBSD" notify: "(Handler: Debian/Ubuntu/CentOS/RedHat) Start NGINX Unit" @@ -11,6 +11,6 @@ portinstall: name: "{{ item }}" state: present - with_items: "{{ unit_modules }}" + with_items: "{{ nginx_unit_modules }}" when: ansible_os_family == "FreeBSD" notify: "(Handler: FreeBSD) Start NGINX Unit" diff --git a/templates/http/default.conf.j2 b/templates/http/default.conf.j2 index 761fef6..0005c36 100644 --- a/templates/http/default.conf.j2 +++ b/templates/http/default.conf.j2 @@ -1,6 +1,6 @@ server { - listen {{ http_template_listen }}; - server_name {{ http_template_server_name }}; + listen {{ nginx_http_template_listen }}; + server_name {{ nginx_http_template_server_name }}; #charset koi8-r; #access_log /var/log/nginx/host.access.log main; diff --git a/templates/nginx.conf.j2 b/templates/nginx.conf.j2 index 153696e..2548773 100644 --- a/templates/nginx.conf.j2 +++ b/templates/nginx.conf.j2 @@ -1,15 +1,15 @@ -user {{ main_template_user }}; -worker_processes {{ main_template_worker_processes }}; +user {{ nginx_main_template_user }}; +worker_processes {{ nginx_main_template_worker_processes }}; -error_log /var/log/nginx/error.log {{ main_template_error_level }}; +error_log /var/log/nginx/error.log {{ nginx_main_template_error_level }}; pid /var/run/nginx.pid; events { - worker_connections {{ main_template_worker_connections }}; + worker_connections {{ nginx_main_template_worker_connections }}; } -{% if http_template_enable %} +{% if nginx_http_template_enable %} http { include /etc/nginx/mime.types; default_type application/octet-stream; @@ -23,7 +23,7 @@ http { sendfile on; #tcp_nopush on; - keepalive_timeout {{ http_template_keepalive_timeout }}; + keepalive_timeout {{ nginx_http_template_keepalive_timeout }}; #gzip on; @@ -31,7 +31,7 @@ http { } {% endif %} -{% if stream_template_enable %} +{% if nginx_stream_template_enable %} stream { include /etc/nginx/conf.d/stream/*.conf; } diff --git a/templates/stream/default.conf.j2 b/templates/stream/default.conf.j2 index 5462c86..e462f29 100644 --- a/templates/stream/default.conf.j2 +++ b/templates/stream/default.conf.j2 @@ -1,3 +1,3 @@ server { - listen {{ stream_template_listen }}; + listen {{ nginx_stream_template_listen }}; } From 27c40696463856026856ec8710cfb7743cf5ea71 Mon Sep 17 00:00:00 2001 From: Alessandro Fael Garcia Date: Fri, 14 Sep 2018 17:53:08 -0700 Subject: [PATCH 4/4] Fix module variable name --- tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/main.yml b/tasks/main.yml index 6544143..1525a2c 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -17,7 +17,7 @@ when: nginx_type == "plus" - import_tasks: modules/install-modules.yml - when: true in modules.values() + when: true in nginx_modules.values() - import_tasks: conf/push-config.yml when: nginx_main_push_enable or nginx_http_push_enable or nginx_stream_push_enable