Add separate variables for installing and configuring NGINX (#284)

This commit is contained in:
Alessandro Fael Garcia 2020-07-13 18:05:03 +02:00 committed by GitHub
parent 968bf3e10c
commit e9b6c59733
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 58 additions and 46 deletions

View File

@ -12,10 +12,11 @@ FEATURES:
* Add support to configure logrotate * Add support to configure logrotate
* Add support for Ubuntu Focal * Add support for Ubuntu Focal
* Add support to configure SELinux * Add support to configure SELinux
* Two new variables have been introduced -- `nginx_install` and `nginx_configure` -- to let you choose whether you want to install NGINX, configure NGINX, or both
ENHANCEMENTS: ENHANCEMENTS:
* Use `include_tasks` instead of `import_tasks` when possible to speed up the role's execution time * The role now uses `include_tasks` instead of `import_tasks` when possible to speed up the role's execution time
* Improve configuration templating capabilities: * Improve configuration templating capabilities:
* Add support for unix upstreams * Add support for unix upstreams
* Add PID templating option * Add PID templating option

View File

@ -7,7 +7,7 @@ nginx_linux_families: ['Alpine', 'Debian', 'RedHat', 'Suse']
# RedHat={Amazon,CentOS,OracleLinux,RHEL} Debian={Ubuntu,Debian} # RedHat={Amazon,CentOS,OracleLinux,RHEL} Debian={Ubuntu,Debian}
nginx_plus_linux_families: ['Alpine', 'Debian', 'RedHat', 'Suse'] nginx_plus_linux_families: ['Alpine', 'Debian', 'RedHat', 'Suse']
# Default locations and versions for install from source # Default locations and versions when 'nginx_install_from; is set to 'source'
pcre_version: pcre-8.43 pcre_version: pcre-8.43
zlib_version: zlib-1.2.11 zlib_version: zlib-1.2.11
openssl_version: openssl-1.1.1c openssl_version: openssl-1.1.1c

View File

@ -1,8 +1,18 @@
--- ---
# Install NGINX. # Enable NGINX options -- `nginx_install` and `nginx_configure`.
# Default is true. # Default is true.
nginx_enable: true nginx_enable: true
# Install NGINX and NGINX modules.
# Variables for these options can be found below.
# Default is true.
nginx_install: true
# Enable NGINX configuration options.
# Variables for these options can be found in `./template.yml` and `./upload.yml`.
# Default is true.
nginx_configure: true
# Start NGINX service. # Start NGINX service.
# Default is true. # Default is true.
nginx_start: true nginx_start: true
@ -22,7 +32,7 @@ nginx_type: opensource
# nginx_version: "-20*" # nginx_version: "-20*"
# Specify whether you want to maintain your version of NGINX, upgrade to the latest version, or remove NGINX. # Specify whether you want to maintain your version of NGINX, upgrade to the latest version, or remove NGINX.
# Can be used with `nginx_version` to achieve fine tune control on which version of NGINX is installed/used on each playbook execution. # Can be used with `nginx_version` to fine tune control on which version of NGINX is installed/used on each playbook execution.
# Using 'present' will install the latest version (or 'nginx_version') of NGINX on a fresh install. # Using 'present' will install the latest version (or 'nginx_version') of NGINX on a fresh install.
# Using 'latest' will upgrade NGINX to the latest version (that matches your 'nginx_version') of NGINX on every playbook execution. # Using 'latest' will upgrade NGINX to the latest version (that matches your 'nginx_version') of NGINX on every playbook execution.
# Using 'absent' will remove NGINX from your system. # Using 'absent' will remove NGINX from your system.
@ -36,14 +46,11 @@ nginx_state: present
nginx_install_from: nginx_repository nginx_install_from: nginx_repository
# Specify source install options for NGINX Open Source. # Specify source install options for NGINX Open Source.
# Options represent whether to install from source also # Options represent whether to install from source also or to install from packages (default).
# or to install from packages (default). These only apply # These only apply if 'nginx_install_from' is set to 'source'.
# if 'nginx_install_from' is set to 'source' # For the tools, true means we will install from a package and false means install from source.
# For the tools, true means we will install from a package # 'nginx_install_source_build_tools' will install compiler and build tools from packages.
# and false means install from source. # If false, you need to have these present.
# 'nginx_install_source_build_tools' will install compiler
# and build tools from packages. If false, you need to have
# these present.
nginx_install_source_build_tools: true nginx_install_source_build_tools: true
nginx_install_source_pcre: false nginx_install_source_pcre: false
nginx_install_source_openssl: true nginx_install_source_openssl: true

View File

@ -30,6 +30,7 @@
- 80 - 80
- 443 - 443
nginx_version: "{{ version }}" nginx_version: "{{ version }}"
nginx_configure: false
nginx_logrotate_conf_enable: true nginx_logrotate_conf_enable: true
nginx_logrotate_conf: nginx_logrotate_conf:
paths: paths:

View File

@ -18,46 +18,50 @@
- name: "(Install: Debian/Ubuntu/CentOS/RedHat/FreeBSD) Install NGINX" - name: "(Install: Debian/Ubuntu/CentOS/RedHat/FreeBSD) Install NGINX"
block: block:
- include_tasks: "{{ role_path }}/tasks/opensource/install-oss.yml" - block:
when: nginx_type == "opensource" - include_tasks: "{{ role_path }}/tasks/opensource/install-oss.yml"
tags: nginx_install_oss when: nginx_type == "opensource"
tags: nginx_install_oss
- include_tasks: "{{ role_path }}/tasks/plus/install-plus.yml" - include_tasks: "{{ role_path }}/tasks/plus/install-plus.yml"
when: nginx_type == "plus" when: nginx_type == "plus"
tags: nginx_install_plus tags: nginx_install_plus
- include_tasks: "{{ role_path }}/tasks/conf/cleanup-config.yml" - include_tasks: "{{ role_path }}/tasks/modules/install-modules.yml"
when: nginx_cleanup_config | bool when: true in nginx_modules.values()
tags: nginx_cleanup_config tags: nginx_install_modules
- include_tasks: "{{ role_path }}/tasks/conf/upload-config.yml" - include_tasks: "{{ role_path }}/tasks/plus/delete-license.yml"
when: nginx_main_upload_enable when:
or nginx_http_upload_enable - nginx_type == "plus"
or nginx_stream_upload_enable - nginx_delete_license
or nginx_html_upload_enable tags: nginx_delete_license
or nginx_ssl_upload_enable when: nginx_install | bool
tags: nginx_upload_config
- include_tasks: "{{ role_path }}/tasks/conf/template-config.yml" - block:
when: nginx_main_template_enable - include_tasks: "{{ role_path }}/tasks/conf/cleanup-config.yml"
or nginx_http_template_enable when: nginx_cleanup_config | bool
or nginx_stream_template_enable tags: nginx_cleanup_config
or nginx_rest_api_enable
tags: nginx_template_config
- include_tasks: "{{ role_path }}/tasks/conf/setup-status.yml" - include_tasks: "{{ role_path }}/tasks/conf/upload-config.yml"
when: nginx_status_enable | bool when: nginx_main_upload_enable
tags: nginx_setup_status or nginx_http_upload_enable
or nginx_stream_upload_enable
or nginx_html_upload_enable
or nginx_ssl_upload_enable
tags: nginx_upload_config
- include_tasks: "{{ role_path }}/tasks/modules/install-modules.yml" - include_tasks: "{{ role_path }}/tasks/conf/template-config.yml"
when: true in nginx_modules.values() when: nginx_main_template_enable
tags: nginx_install_modules or nginx_http_template_enable
or nginx_stream_template_enable
or nginx_rest_api_enable
tags: nginx_template_config
- include_tasks: "{{ role_path }}/tasks/plus/delete-license.yml" - include_tasks: "{{ role_path }}/tasks/conf/setup-status.yml"
when: when: nginx_status_enable | bool
- nginx_type == "plus" tags: nginx_setup_status
- nginx_delete_license when: nginx_configure | bool
tags: nginx_delete_license
- name: "(Config: All OSs) Ensure NGINX is Running" - name: "(Config: All OSs) Ensure NGINX is Running"
meta: flush_handlers meta: flush_handlers
@ -69,7 +73,6 @@
- include_tasks: "{{ role_path }}/tasks/conf/logrotate.yml" - include_tasks: "{{ role_path }}/tasks/conf/logrotate.yml"
when: nginx_logrotate_conf_enable | bool when: nginx_logrotate_conf_enable | bool
tags: nginx_logrotate_config tags: nginx_logrotate_config
when: nginx_enable | bool when: nginx_enable | bool
- include_tasks: "{{ role_path }}/tasks/amplify/install-amplify.yml" - include_tasks: "{{ role_path }}/tasks/amplify/install-amplify.yml"