Skip to content

Commit 0cb89b4

Browse files
authored
feat: Allow overriding distribution package name (#877)
1 parent 12c1e2a commit 0cb89b4

File tree

5 files changed

+30
-7
lines changed

5 files changed

+30
-7
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## 0.25.1 (Unreleased)
44

5+
FEATURES:
6+
7+
- Add a parameter, `nginx_distribution_package`, to override the default NGINX package name when installing NGINX from your distribution/OS repository.
8+
59
BUG FIXES:
610

711
- Fix Ansible and Jinja versions validation tasks in ansible check mode.

defaults/main/main.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ nginx_manage_repo: true
4646
# Default is nginx_repository.
4747
nginx_install_from: nginx_repository
4848

49+
# (Optional) Specify repository for NGINX Open Source or NGINX Plus.
50+
# Only works if 'install_from' is set to 'nginx_repository' when installing NGINX Open Source.
51+
# Defaults are the official NGINX repositories.
52+
# nginx_repository: deb https://nginx.org/packages/mainline/debian/ buster nginx
53+
4954
# Specify source install options for NGINX Open Source.
5055
# Options represent whether to install from source also or to install from packages (default).
5156
# These only apply if 'nginx_install_from' is set to 'source'.
@@ -57,22 +62,20 @@ nginx_install_source_pcre: false
5762
nginx_install_source_openssl: true
5863
nginx_install_source_zlib: false
5964

60-
# Specify source install module for NGINX Open Source.
65+
# Specify source install modules for NGINX Open Source.
6166
# You can select any of the static modules listed on http://nginx.org/en/docs/configure.html.
6267
# Format is '--with-*' where '*' should be used as static module name in the list below. (see an example below).
6368
# Default is 'http_ssl_module'. (DO NOT remove it if you need SSL support).
6469
nginx_static_modules: [http_ssl_module]
6570
# nginx_static_modules: ['http_v2_module'] # Example for '--with-http_v2_module'
6671

72+
# (Optional) Specify NGINX package name when installing nginx from an 'os_repository'.
73+
# nginx_distribution_package: @nginx:1.24/common
74+
6775
# (Optional) Choose where to fetch the NGINX signing key from.
6876
# Default is the official NGINX signing key host.
6977
# nginx_signing_key: http://nginx.org/keys/nginx_signing.key
7078

71-
# (Optional) Specify repository for NGINX Open Source or NGINX Plus.
72-
# Only works if 'install_from' is set to 'nginx_repository' when installing NGINX Open Source.
73-
# Defaults are the official NGINX repositories.
74-
# nginx_repository: deb https://nginx.org/packages/mainline/debian/ buster nginx
75-
7679
# Specify which branch of NGINX Open Source you want to install.
7780
# Options are 'mainline' or 'stable'.
7881
# Only works if 'install_from' is set to 'nginx_repository' or 'source'.

molecule/distribution/converge.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
---
22
- name: Converge
33
hosts: all
4+
pre_tasks:
5+
- name: Set package name if Debian
6+
ansible.builtin.set_fact:
7+
nginx_package_name: nginx-core
8+
when: ansible_facts['os_family'] == "Debian"
49
tasks:
510
- name: Install NGINX
611
ansible.builtin.include_role:
712
name: ansible-role-nginx
813
vars:
914
nginx_install_from: os_repository
15+
nginx_distribution_package: "{{ nginx_package_name }}"

molecule/distribution/verify.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@
88
state: present
99
check_mode: true
1010
register: install
11+
when: ansible_facts['os_family'] != 'Debian'
12+
failed_when: (install is changed) or (install is failed)
13+
14+
- name: Check if NGINX is installed
15+
ansible.builtin.package:
16+
name: nginx-core
17+
state: present
18+
check_mode: true
19+
register: install
20+
when: ansible_facts['os_family'] == 'Debian'
1121
failed_when: (install is changed) or (install is failed)
1222

1323
- name: Check if NGINX service is running

tasks/opensource/install-distribution.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99

1010
- name: "{{ nginx_setup | capitalize }} NGINX from the distribution's package repository"
1111
ansible.builtin.package:
12-
name: nginx{{ nginx_version | default('') }}
12+
name: "{{ nginx_distribution_package | default('nginx' + (nginx_version | default(''))) }}"
1313
state: "{{ nginx_state }}"
1414
notify: (Handler) Run NGINX

0 commit comments

Comments
 (0)