Skip to content

Commit 175f456

Browse files
committed
fixes
1 parent ecb5e67 commit 175f456

File tree

9 files changed

+290
-28
lines changed

9 files changed

+290
-28
lines changed

.github/workflows/molecule.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ jobs:
3333
- uninstall-plus
3434
- upgrade
3535
- upgrade-plus
36+
- version
3637
steps:
3738
- name: Check out the codebase
3839
if: ${{ !(contains(matrix.scenario, 'plus')) || (env.NGINX_CRT != 0 && env.NGINX_KEY != 0) }}

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ TESTS:
4444
* Explicitly specify `x86_64`/`amd64` as the platform used in the Amazon Linux 2/CentOS/Oracle Linux/RHEL 7/SLES 15 Molecule Docker images. This will ensure that tests work when run on different host architectures (e.g. newer Macbooks with `aarch64`/`arm64` processors) when running tests in distributions that only support `x86_64`/`amd64` (either due to lack of support for a `cgroups` v2 backport or due to lack of builds for `aarch64`/`arm64`).
4545
* Explicitly test some distributions using `aarch64` and `s390x` as the Molecule platform. This should ensure the role works as intended across the various architectures that are officially supported.
4646
* Combine the `module` Molecule scenario with the `default` scenario.
47-
* Add `stable` Molecule scenario.
47+
* Add `stable` and `version` Molecule scenario.
4848
* Replace underscores with dashes in Molecule scenario names to improve naming consistency across the role.
4949

5050
## 0.23.2 (September 28, 2022)

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ Working functional playbook examples can be found in the **[`molecule/`](https:/
200200
| **[`uninstall-plus/converge.yml`](https://github.com/nginxinc/ansible-role-nginx/blob/main/molecule/uninstall-plus/converge.yml)** | Uninstall NGINX Plus |
201201
| **[`upgrade/converge.yml`](https://github.com/nginxinc/ansible-role-nginx/blob/main/molecule/upgrade/converge.yml)** | Upgrade NGINX |
202202
| **[`upgrade-plus/converge.yml`](https://github.com/nginxinc/ansible-role-nginx/blob/main/molecule/upgrade-plus/converge.yml)** | Upgrade NGINX Plus |
203+
| **[`version/converge.yml`](https://github.com/nginxinc/ansible-role-nginx/blob/main/molecule/version/converge.yml)** | Install a specific version of NGINX and various NGINX modules |
203204

204205
Do note that if you install this repository via Ansible Galaxy, you will have to replace the role variable in the sample playbooks from `ansible-role-nginx` to `nginxinc.nginx`.
205206

molecule/default/converge.yml

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,16 @@
11
---
22
- name: Converge
33
hosts: all
4-
pre_tasks:
5-
- name: Set repo if Alpine
6-
ansible.builtin.set_fact:
7-
ngx_version: =1.23.2-r1
8-
njs: =1.23.2.7.9-r1
9-
when: ansible_facts['os_family'] == "Alpine"
10-
- name: Set repo if Debian
11-
ansible.builtin.set_fact:
12-
ngx_version: =1.23.2-1~{{ ansible_facts['distribution_release'] }}
13-
njs_version: =1.23.2+0.7.9-1~{{ ansible_facts['distribution_release'] }}
14-
when: ansible_facts['os_family'] == "Debian"
15-
- name: Set repo if Red Hat
16-
ansible.builtin.set_fact:
17-
ngx_version: -1.23.2-1.{{ (ansible_facts['distribution'] == "Amazon") | ternary('amzn2', ('el' + ansible_facts['distribution_major_version'] | string)) }}.ngx
18-
njs_version: -1.23.2+0.7.9-1.{{ (ansible_facts['distribution'] == "Amazon") | ternary('amzn2', ('el' + ansible_facts['distribution_major_version'] | string)) }}.ngx
19-
when: ansible_facts['os_family'] == "RedHat"
20-
- name: Set repo if SLES
21-
ansible.builtin.set_fact:
22-
ngx_version: =1.23.2-1.sles{{ ansible_facts['distribution_major_version'] }}.ngx
23-
njs_version: =1.23.2+0.7.9-1.sles{{ ansible_facts['distribution_major_version'] }}.ngx
24-
when: ansible_facts['os_family'] == "Suse"
254
tasks:
265
- name: Install NGINX
276
ansible.builtin.include_role:
287
name: ansible-role-nginx
298
vars:
30-
nginx_version: "{{ ngx_version }}"
319
nginx_modules:
3210
- brotli
3311
- geoip
3412
- image-filter
35-
- name: njs
36-
state: present
37-
version: "{{ njs_version }}"
13+
- njs
3814
- perl
3915
- xslt
4016
nginx_service_modify: true

molecule/default/verify.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@
3030
chdir: "{{ ((ansible_facts['system'] | lower is not search('bsd')) | ternary('/etc/nginx', '/usr/local/sbin')) }}"
3131
changed_when: false
3232
register: version
33-
failed_when: version is not search('1.23.2')
33+
failed_when: version is not search('1.23.3')

molecule/version/converge.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
- name: Converge
3+
hosts: all
4+
pre_tasks:
5+
- name: Set repo if Alpine
6+
ansible.builtin.set_fact:
7+
ngx_version: =1.23.2-r1
8+
njs: =1.23.2.7.9-r1
9+
when: ansible_facts['os_family'] == "Alpine"
10+
- name: Set repo if Debian
11+
ansible.builtin.set_fact:
12+
ngx_version: =1.23.2-1~{{ ansible_facts['distribution_release'] }}
13+
njs_version: =1.23.2+0.7.9-1~{{ ansible_facts['distribution_release'] }}
14+
when: ansible_facts['os_family'] == "Debian"
15+
- name: Set repo if Red Hat
16+
ansible.builtin.set_fact:
17+
ngx_version: -1.23.2-1.{{ (ansible_facts['distribution'] == "Amazon") | ternary('amzn2', ('el' + ansible_facts['distribution_major_version'] | string)) }}.ngx
18+
njs_version: -1.23.2+0.7.9-1.{{ (ansible_facts['distribution'] == "Amazon") | ternary('amzn2', ('el' + ansible_facts['distribution_major_version'] | string)) }}.ngx
19+
when: ansible_facts['os_family'] == "RedHat"
20+
- name: Set repo if SLES
21+
ansible.builtin.set_fact:
22+
ngx_version: =1.23.2-1.sles{{ ansible_facts['distribution_major_version'] }}.ngx
23+
njs_version: =1.23.2+0.7.9-1.sles{{ ansible_facts['distribution_major_version'] }}.ngx
24+
when: ansible_facts['os_family'] == "Suse"
25+
tasks:
26+
- name: Install NGINX
27+
ansible.builtin.include_role:
28+
name: ansible-role-nginx
29+
vars:
30+
nginx_version: "{{ ngx_version }}"
31+
nginx_modules:
32+
- name: brotli
33+
version: "{{ ngx_version }}"
34+
- name: geoip
35+
version: "{{ ngx_version }}"
36+
- name: image-filter
37+
version: "{{ ngx_version }}"
38+
- name: njs
39+
state: present
40+
version: "{{ njs_version }}"
41+
- name: perl
42+
version: "{{ ngx_version }}"
43+
- name: xslt
44+
version: "{{ ngx_version }}"
45+
nginx_service_modify: true
46+
nginx_service_timeout: 95
47+
nginx_logrotate_conf_enable: true
48+
nginx_logrotate_conf:
49+
paths:
50+
- /var/log/nginx/*.log
51+
options:
52+
- daily
53+
- missingok
54+
- rotate 14
55+
- compress
56+
- delaycompress
57+
- notifempty
58+
- sharedscripts

molecule/version/molecule.yml

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
---
2+
driver:
3+
name: docker
4+
lint: |
5+
set -e
6+
ansible-lint --force-color
7+
platforms:
8+
- name: almalinux-8
9+
image: almalinux:8
10+
dockerfile: ../common/Dockerfile.j2
11+
privileged: true
12+
cgroupns_mode: host
13+
volumes:
14+
- /sys/fs/cgroup:/sys/fs/cgroup:rw
15+
command: /usr/sbin/init
16+
- name: almalinux-9
17+
image: almalinux:9
18+
dockerfile: ../common/Dockerfile.j2
19+
privileged: true
20+
cgroupns_mode: host
21+
volumes:
22+
- /sys/fs/cgroup:/sys/fs/cgroup:rw
23+
command: /usr/sbin/init
24+
- name: alpine-3.14
25+
image: alpine:3.14
26+
dockerfile: ../common/Dockerfile.j2
27+
privileged: true
28+
cgroupns_mode: host
29+
volumes:
30+
- /sys/fs/cgroup:/sys/fs/cgroup:rw
31+
command: /sbin/init
32+
- name: alpine-3.15
33+
image: alpine:3.15
34+
dockerfile: ../common/Dockerfile.j2
35+
privileged: true
36+
cgroupns_mode: host
37+
volumes:
38+
- /sys/fs/cgroup:/sys/fs/cgroup:rw
39+
command: /sbin/init
40+
- name: alpine-3.16
41+
image: alpine:3.16
42+
platform: x86_64
43+
dockerfile: ../common/Dockerfile.j2
44+
privileged: true
45+
cgroupns_mode: host
46+
volumes:
47+
- /sys/fs/cgroup:/sys/fs/cgroup:rw
48+
command: /sbin/init
49+
- name: alpine-3.17
50+
image: alpine:3.17
51+
platform: aarch64
52+
dockerfile: ../common/Dockerfile.j2
53+
privileged: true
54+
cgroupns_mode: host
55+
volumes:
56+
- /sys/fs/cgroup:/sys/fs/cgroup:rw
57+
command: /sbin/init
58+
- name: amazonlinux-2
59+
image: amazonlinux:2
60+
platform: x86_64
61+
dockerfile: ../common/Dockerfile.j2
62+
privileged: true
63+
cgroupns_mode: host
64+
volumes:
65+
- /sys/fs/cgroup:/sys/fs/cgroup:rw
66+
command: /usr/sbin/init
67+
- name: centos-7
68+
image: centos:7
69+
platform: x86_64
70+
dockerfile: ../common/Dockerfile.j2
71+
privileged: true
72+
cgroupns_mode: host
73+
volumes:
74+
- /sys/fs/cgroup:/sys/fs/cgroup:rw
75+
command: /usr/sbin/init
76+
- name: debian-bullseye
77+
image: debian:bullseye-slim
78+
dockerfile: ../common/Dockerfile.j2
79+
privileged: true
80+
cgroupns_mode: host
81+
volumes:
82+
- /sys/fs/cgroup:/sys/fs/cgroup:rw
83+
command: /sbin/init
84+
- name: oraclelinux-7
85+
image: oraclelinux:7
86+
platform: x86_64
87+
dockerfile: ../common/Dockerfile.j2
88+
privileged: true
89+
cgroupns_mode: host
90+
volumes:
91+
- /sys/fs/cgroup:/sys/fs/cgroup:rw
92+
command: /usr/sbin/init
93+
- name: oraclelinux-8
94+
image: oraclelinux:8
95+
dockerfile: ../common/Dockerfile.j2
96+
privileged: true
97+
cgroupns_mode: host
98+
volumes:
99+
- /sys/fs/cgroup:/sys/fs/cgroup:rw
100+
command: /usr/sbin/init
101+
- name: oraclelinux-9
102+
image: oraclelinux:9
103+
dockerfile: ../common/Dockerfile.j2
104+
privileged: true
105+
cgroupns_mode: host
106+
volumes:
107+
- /sys/fs/cgroup:/sys/fs/cgroup:rw
108+
command: /usr/sbin/init
109+
- name: rhel-7
110+
image: registry.access.redhat.com/ubi7:7.9
111+
platform: x86_64
112+
dockerfile: ../common/Dockerfile.j2
113+
privileged: true
114+
cgroupns_mode: host
115+
volumes:
116+
- /sys/fs/cgroup:/sys/fs/cgroup:rw
117+
command: /usr/sbin/init
118+
- name: rhel-8
119+
image: redhat/ubi8:8.7
120+
platform: s390x
121+
dockerfile: ../common/Dockerfile.j2
122+
privileged: true
123+
cgroupns_mode: host
124+
volumes:
125+
- /sys/fs/cgroup:/sys/fs/cgroup:rw
126+
command: /usr/sbin/init
127+
- name: rhel-9
128+
image: redhat/ubi9:9.1.0
129+
platform: aarch64
130+
dockerfile: ../common/Dockerfile.j2
131+
privileged: true
132+
cgroupns_mode: host
133+
volumes:
134+
- /sys/fs/cgroup:/sys/fs/cgroup:rw
135+
command: /usr/sbin/init
136+
- name: rockylinux-8
137+
image: rockylinux:8
138+
dockerfile: ../common/Dockerfile.j2
139+
privileged: true
140+
cgroupns_mode: host
141+
volumes:
142+
- /sys/fs/cgroup:/sys/fs/cgroup:rw
143+
command: /usr/sbin/init
144+
- name: rockylinux-9
145+
image: rockylinux:9.0.20220720
146+
dockerfile: ../common/Dockerfile.j2
147+
privileged: true
148+
cgroupns_mode: host
149+
volumes:
150+
- /sys/fs/cgroup:/sys/fs/cgroup:rw
151+
command: /usr/sbin/init
152+
- name: sles15
153+
image: registry.suse.com/bci/bci-base:15.4
154+
platform: x86_64
155+
dockerfile: ../common/Dockerfile.j2
156+
privileged: true
157+
cgroupns_mode: host
158+
volumes:
159+
- /sys/fs/cgroup:/sys/fs/cgroup:rw
160+
command: /usr/sbin/init
161+
- name: ubuntu-bionic
162+
image: ubuntu:bionic
163+
platform: x86_64
164+
dockerfile: ../common/Dockerfile.j2
165+
privileged: true
166+
cgroupns_mode: host
167+
volumes:
168+
- /sys/fs/cgroup:/sys/fs/cgroup:rw
169+
command: /sbin/init
170+
- name: ubuntu-focal
171+
image: ubuntu:focal
172+
platform: s390x
173+
dockerfile: ../common/Dockerfile.j2
174+
privileged: true
175+
cgroupns_mode: host
176+
volumes:
177+
- /sys/fs/cgroup:/sys/fs/cgroup:rw
178+
command: /sbin/init
179+
- name: ubuntu-jammy
180+
image: ubuntu:jammy
181+
platform: aarch64
182+
dockerfile: ../common/Dockerfile.j2
183+
privileged: true
184+
cgroupns_mode: host
185+
volumes:
186+
- /sys/fs/cgroup:/sys/fs/cgroup:rw
187+
command: /sbin/init
188+
provisioner:
189+
name: ansible
190+
log: true
191+
playbooks:
192+
converge: converge.yml
193+
verify: verify.yml

molecule/version/verify.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
- name: Verify
3+
hosts: all
4+
tasks:
5+
- name: Check if NGINX is installed
6+
ansible.builtin.package:
7+
name: nginx
8+
state: present
9+
check_mode: true
10+
register: install
11+
failed_when: (install is changed) or (install is failed)
12+
13+
- name: Check if NGINX service is running
14+
ansible.builtin.service:
15+
name: nginx
16+
state: started
17+
enabled: true
18+
check_mode: true
19+
register: service
20+
failed_when: (service is changed) or (service is failed)
21+
22+
- name: Verify NGINX is up and running
23+
ansible.builtin.uri:
24+
url: http://localhost
25+
status_code: 200
26+
27+
- name: Verify correct version of NGINX has been installed
28+
ansible.builtin.command: nginx -v
29+
args:
30+
chdir: "{{ ((ansible_facts['system'] | lower is not search('bsd')) | ternary('/etc/nginx', '/usr/local/sbin')) }}"
31+
changed_when: false
32+
register: version
33+
failed_when: version is not search('1.23.2')

tasks/modules/install-modules.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
- ansible_facts['distribution_version'] | regex_search('^[0-9]+\\.[0-9]+') is version('3.17', '==')
4848
- ('"encrypted-sessions" in nginx_modules') or ('"lua" in nginx_modules') or ('"set-misc" in nginx_modules')
4949

50-
- name: Setup NGINX modules
50+
- name: Install NGINX modules
5151
ansible.builtin.package:
5252
name: "nginx-{{ (nginx_type == 'plus') | ternary('plus-', '') }}module-{{ item.name | default(item) }}\
5353
{{ (nginx_repository is not defined and ansible_facts['os_family'] == 'Alpine' and nginx_type != 'plus') | ternary('@nginx', '') }}{{ item.version | default('') }}"

0 commit comments

Comments
 (0)