diff --git a/CHANGELOG.md b/CHANGELOG.md index 92c6ccaa5..f2935ac88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## 0.25.1 (Unreleased) +FEATURES: + +- Add a parameter, `nginx_distribution_package`, to override the default NGINX package name when installing NGINX from your distribution/OS repository. + BUG FIXES: - Fix Ansible and Jinja versions validation tasks in ansible check mode. diff --git a/defaults/main/main.yml b/defaults/main/main.yml index 6ec521c08..bf29eff0e 100644 --- a/defaults/main/main.yml +++ b/defaults/main/main.yml @@ -46,6 +46,11 @@ nginx_manage_repo: true # Default is nginx_repository. nginx_install_from: nginx_repository +# (Optional) Specify repository for NGINX Open Source or NGINX Plus. +# Only works if 'install_from' is set to 'nginx_repository' when installing NGINX Open Source. +# Defaults are the official NGINX repositories. +# nginx_repository: deb https://nginx.org/packages/mainline/debian/ buster nginx + # Specify source install options for NGINX Open Source. # Options represent whether to install from source also or to install from packages (default). # These only apply if 'nginx_install_from' is set to 'source'. @@ -57,22 +62,20 @@ nginx_install_source_pcre: false nginx_install_source_openssl: true nginx_install_source_zlib: false -# Specify source install module for NGINX Open Source. +# Specify source install modules for NGINX Open Source. # You can select any of the static modules listed on http://nginx.org/en/docs/configure.html. # Format is '--with-*' where '*' should be used as static module name in the list below. (see an example below). # Default is 'http_ssl_module'. (DO NOT remove it if you need SSL support). nginx_static_modules: [http_ssl_module] # nginx_static_modules: ['http_v2_module'] # Example for '--with-http_v2_module' +# (Optional) Specify NGINX package name when installing nginx from an 'os_repository'. +# nginx_distribution_package: @nginx:1.24/common + # (Optional) Choose where to fetch the NGINX signing key from. # Default is the official NGINX signing key host. # nginx_signing_key: http://nginx.org/keys/nginx_signing.key -# (Optional) Specify repository for NGINX Open Source or NGINX Plus. -# Only works if 'install_from' is set to 'nginx_repository' when installing NGINX Open Source. -# Defaults are the official NGINX repositories. -# nginx_repository: deb https://nginx.org/packages/mainline/debian/ buster nginx - # Specify which branch of NGINX Open Source you want to install. # Options are 'mainline' or 'stable'. # Only works if 'install_from' is set to 'nginx_repository' or 'source'. diff --git a/molecule/distribution/converge.yml b/molecule/distribution/converge.yml index f0b0c0d95..ec952744f 100644 --- a/molecule/distribution/converge.yml +++ b/molecule/distribution/converge.yml @@ -1,9 +1,15 @@ --- - name: Converge hosts: all + pre_tasks: + - name: Set package name if Debian + ansible.builtin.set_fact: + nginx_package_name: nginx-core + when: ansible_facts['os_family'] == "Debian" tasks: - name: Install NGINX ansible.builtin.include_role: name: ansible-role-nginx vars: nginx_install_from: os_repository + nginx_distribution_package: "{{ nginx_package_name }}" diff --git a/molecule/distribution/verify.yml b/molecule/distribution/verify.yml index 3e6cc4bc4..a0f19faee 100644 --- a/molecule/distribution/verify.yml +++ b/molecule/distribution/verify.yml @@ -8,6 +8,16 @@ state: present check_mode: true register: install + when: ansible_facts['os_family'] != 'Debian' + failed_when: (install is changed) or (install is failed) + + - name: Check if NGINX is installed + ansible.builtin.package: + name: nginx-core + state: present + check_mode: true + register: install + when: ansible_facts['os_family'] == 'Debian' failed_when: (install is changed) or (install is failed) - name: Check if NGINX service is running diff --git a/tasks/opensource/install-distribution.yml b/tasks/opensource/install-distribution.yml index aabcd28f7..b5fe9a299 100644 --- a/tasks/opensource/install-distribution.yml +++ b/tasks/opensource/install-distribution.yml @@ -9,6 +9,6 @@ - name: "{{ nginx_setup | capitalize }} NGINX from the distribution's package repository" ansible.builtin.package: - name: nginx{{ nginx_version | default('') }} + name: "{{ nginx_distribution_package | default('nginx' + (nginx_version | default(''))) }}" state: "{{ nginx_state }}" notify: (Handler) Run NGINX