From c57e0a79d2c2de96fa1523d901ec59b1640eb5c8 Mon Sep 17 00:00:00 2001 From: Alessandro Fael Garcia Date: Wed, 11 Jul 2018 15:41:10 -0700 Subject: [PATCH 1/3] Add nginx_enable variable Users can now choose to only install NGINX Unit --- README.md | 16 +++++---- defaults/main.yml | 16 +++++---- tasks/main.yml | 61 +++++++++++++++++--------------- tasks/opensource/install-oss.yml | 2 +- 4 files changed, 54 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index 2e644f9..120bd8e 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,10 @@ Role Variables This role has multiple variables. The defaults for all these variables are the following: --- + # Install NGINX. + # Default is true. + nginx_enable: true + # Specify which version of NGINX you want to install. # Options are 'opensource' or 'plus'. # Default is 'opensource'. @@ -131,12 +135,6 @@ This role has multiple variables. The defaults for all these variables are the f # Default is mainline. branch: mainline - # Install NGINX Unit and NGINX Unit modules. - # Use a list of supported NGINX Unit modules. - # Default is false. - unit_enable: false - unit_modules: null - # Install NGINX JavaScript, Perl, ModSecurity WAF (NGINX Plus only), GeoIP, Image-Filter, RTMP Media Streaming, and/or XSLT modules. # Default is false. modules: @@ -195,6 +193,12 @@ This role has multiple variables. The defaults for all these variables are the f stream_template_enable: false stream_template_listen: 12345 + # Install NGINX Unit and NGINX Unit modules. + # Use a list of supported NGINX Unit modules. + # Default is false. + unit_enable: false + unit_modules: null + Dependencies ------------ diff --git a/defaults/main.yml b/defaults/main.yml index 93b0d37..29d5404 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,4 +1,8 @@ --- +# Install NGINX. +# Default is true. +nginx_enable: true + # Specify which version of NGINX you want to install. # Options are 'opensource' or 'plus'. # Default is 'opensource'. @@ -28,12 +32,6 @@ nginx_repository: # Default is mainline. branch: mainline -# Install NGINX Unit and NGINX Unit modules. -# Use a list of supported NGINX Unit modules. -# Default is false. -unit_enable: false -unit_modules: null - # Install NGINX JavaScript, Perl, ModSecurity WAF (NGINX Plus only), GeoIP, Image-Filter, RTMP Media Streaming, and/or XSLT modules. # Default is false. modules: @@ -91,3 +89,9 @@ http_template_listen: 80 http_template_server_name: localhost stream_template_enable: false stream_template_listen: 12345 + +# Install NGINX Unit and NGINX Unit modules. +# Use a list of supported NGINX Unit modules. +# Default is false. +unit_enable: false +unit_modules: null diff --git a/tasks/main.yml b/tasks/main.yml index 2572896..a85c2ed 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -5,47 +5,52 @@ - import_tasks: keys/rpm-key.yml when: ansible_os_family == "RedHat" or ansible_os_family == "Suse" -- import_tasks: opensource/install-oss.yml - when: type == "opensource" +- name: "(Install: Debian/Ubuntu/CentOS/RedHat/FreeBSD) Install NGINX" + block: -- import_tasks: plus/install-plus.yml - when: type == "plus" + - import_tasks: opensource/install-oss.yml + when: type == "opensource" -- import_tasks: modules/install-njs.yml - when: modules.njs + - import_tasks: plus/install-plus.yml + when: type == "plus" -- import_tasks: modules/install-perl.yml - when: modules.perl + - import_tasks: modules/install-njs.yml + when: modules.njs -- import_tasks: modules/install-geoip.yml - when: modules.geoip + - import_tasks: modules/install-perl.yml + when: modules.perl -- import_tasks: modules/install-image-filter.yml - when: modules.image_filter + - import_tasks: modules/install-geoip.yml + when: modules.geoip -- import_tasks: modules/install-rtmp.yml - when: modules.rtmp + - import_tasks: modules/install-image-filter.yml + when: modules.image_filter -- import_tasks: modules/install-xslt.yml - when: modules.xslt + - import_tasks: modules/install-rtmp.yml + when: modules.rtmp -- import_tasks: modules/install-waf.yml - when: modules.waf and type == "plus" + - import_tasks: modules/install-xslt.yml + when: modules.xslt -- import_tasks: conf/push-config.yml - when: main_push_enable or http_push_enable or stream_push_enable + - import_tasks: modules/install-waf.yml + when: modules.waf and type == "plus" -- import_tasks: conf/template-config.yml - when: main_template_enable or http_template_enable or stream_template_enable + - import_tasks: conf/push-config.yml + when: main_push_enable or http_push_enable or stream_push_enable -- import_tasks: conf/setup-status.yml - when: status_enable + - import_tasks: conf/template-config.yml + when: main_template_enable or http_template_enable or stream_template_enable -- import_tasks: conf/setup-rest-api.yml - when: rest_api_enable and type == "plus" + - import_tasks: conf/setup-status.yml + when: status_enable -- import_tasks: amplify/install-amplify.yml - when: amplify_enable and amplify_key is defined and amplify_key + - import_tasks: conf/setup-rest-api.yml + when: rest_api_enable and type == "plus" + + - import_tasks: amplify/install-amplify.yml + when: amplify_enable and amplify_key is defined and amplify_key + + when: nginx_enable - import_tasks: unit/install-unit.yml when: unit_enable diff --git a/tasks/opensource/install-oss.yml b/tasks/opensource/install-oss.yml index d19e5a5..2f40f47 100644 --- a/tasks/opensource/install-oss.yml +++ b/tasks/opensource/install-oss.yml @@ -1,5 +1,5 @@ --- -- name: "" +- name: "(Install: Debian/Ubuntu/CentOS/RedHat/FreeBSD) Install NGINX" block: - import_tasks: setup-debian.yml From 8aad2bcb941201b0a793500b1821fdcbc46d0ef2 Mon Sep 17 00:00:00 2001 From: Alessandro Fael Garcia Date: Wed, 11 Jul 2018 15:44:36 -0700 Subject: [PATCH 2/3] Do not install NGINX in the NGINX Unit test playbooks --- tests/playbooks/nginx-unit.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/playbooks/nginx-unit.yml b/tests/playbooks/nginx-unit.yml index cd0472e..762373a 100644 --- a/tests/playbooks/nginx-unit.yml +++ b/tests/playbooks/nginx-unit.yml @@ -5,6 +5,7 @@ roles: - ansible-role-nginx vars: + nginx_enable: false unit_enable: true unit_modules: - unit-php From 31c86e3a07939b3cf3641d0eae0c9de05276d25f Mon Sep 17 00:00:00 2001 From: Alessandro Fael Garcia Date: Wed, 11 Jul 2018 17:05:23 -0700 Subject: [PATCH 3/3] Update .travis.yml Do not check localhost when running the NGINX Unit test playbook --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6521269..15ea710 100644 --- a/.travis.yml +++ b/.travis.yml @@ -133,7 +133,7 @@ script: | grep -q 'changed=0.*failed=0' && (echo 'Idempotence test: pass' && exit 0) || (echo 'Idempotence test: fail' && exit 1) - - 'sudo docker exec "$(cat ${container_id})" curl http://localhost/' + - 'if [${playbook} != "unit"]; then sudo docker exec "$(cat ${container_id})" curl http://localhost/; fi' - 'sudo docker rm -f "$(cat ${container_id})"' notifications: webhooks: https://galaxy.ansible.com/api/v1/notifications/