Skip to content

Commit 70c6ec1

Browse files
Add support for nginx_version when compiling NGINX from source (#661)
1 parent a4867f3 commit 70c6ec1

File tree

7 files changed

+249
-14
lines changed

7 files changed

+249
-14
lines changed

.github/workflows/molecule.yml

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ jobs:
5050
- downgrade-plus
5151
- plus
5252
- source
53+
- source-version
5354
- stable
5455
- uninstall
5556
- uninstall-plus

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ FEATURES:
88
- Remove Ubuntu kinetic from the list of NGINX OSS tested and supported distributions.
99
- Remove Alpine Linux 3.14 and Ubuntu bionic from the list of NGINX Plus tested and supported distributions.
1010
- The `geoip2` module for NGINX Plus is no longer supported on Amazon Linux.
11+
- Add support for specific version for NGINX OSS install from source
1112

1213
CI/CD:
1314

defaults/main/main.yml

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ nginx_type: opensource
1818
# nginx_version: "=1.23.2-1~jammy"
1919
# For NGINX Plus you'll need to specify the R* release like below (Ubuntu jammy example).
2020
# nginx_version: "=28-1~jammy"
21+
# For Open source and from source the version should be of the following format 1.25.1
22+
# As in https://nginx.org/download/ `nginx-<version>.<extension>`
23+
# nginx_version: "1.25.1"
2124

2225
# Start NGINX service.
2326
# Default is true.

molecule/source-version/converge.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
- name: Converge
3+
hosts: all
4+
tasks:
5+
- name: Install NGINX from source
6+
ansible.builtin.include_role:
7+
name: nginxinc.nginx
8+
vars:
9+
nginx_install_from: source
10+
nginx_branch: stable
11+
nginx_version: "1.25.1"
12+
nginx_static_modules: [http_ssl_module]
13+
nginx_install_source_build_tools: true
14+
nginx_install_source_pcre: false
15+
nginx_install_source_openssl: false
16+
nginx_install_source_zlib: false

molecule/source-version/molecule.yml

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

molecule/source-version/verify.yml

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

tasks/opensource/install-source.yml

+15-14
Original file line numberDiff line numberDiff line change
@@ -314,24 +314,25 @@
314314
chdir: /tmp/openssl-{{ openssl_version }}
315315
target: install
316316

317-
- name: Get NGINX version
317+
- name: Get latest NGINX version
318+
when: nginx_version is undefined
318319
block:
319-
- name: Fetch NGINX version
320+
- name: Fetch NGINX latest version
320321
ansible.builtin.uri:
321322
url: https://version.nginx.com/nginx/{{ nginx_branch }}
322323
return_content: true
323324
check_mode: false
324-
register: nginx_versions
325+
register: nginx_latest_version
325326

326327
- name: Set NGINX version
327328
ansible.builtin.set_fact:
328-
nginx_version: "{{ 'nginx-' + (nginx_versions['content'] | regex_search('([0-9]+\\.){2}[0-9]+')) }}"
329+
nginx_version: "{{ (nginx_latest_version['content'] | regex_search('([0-9]+\\.){2}[0-9]+')) }}"
329330

330-
- name: Check for NGINX install
331-
ansible.builtin.stat:
332-
path: /usr/sbin/nginx
333-
follow: true
334-
register: nginx_result
331+
- name: Check for NGINX install
332+
ansible.builtin.stat:
333+
path: /usr/sbin/nginx
334+
follow: true
335+
register: nginx_result
335336

336337
- name: Add NGINX group
337338
ansible.builtin.group:
@@ -352,8 +353,8 @@
352353
block:
353354
- name: Download NGINX
354355
ansible.builtin.get_url:
355-
url: https://nginx.org/download/{{ nginx_version }}.tar.gz
356-
dest: /tmp/{{ nginx_version }}.tar.gz
356+
url: https://nginx.org/download/nginx-{{ nginx_version }}.tar.gz
357+
dest: /tmp/nginx-{{ nginx_version }}.tar.gz
357358
mode: "0600"
358359
register: nginx_source
359360

@@ -387,17 +388,17 @@
387388
{{ nginx_install_source_zlib | ternary('--with-zlib=../zlib-' + zlib_version | string, '') }}
388389
{{ nginx_install_source_openssl | ternary('--with-openssl=../openssl-' + openssl_version | string, '') }}
389390
{{ nginx_install_source_static_modules | default('') }}
390-
chdir: /tmp/{{ nginx_version }}
391+
chdir: /tmp/nginx-{{ nginx_version }}
391392
creates: /tmp/makefile
392393
register: nginx_configure
393394

394395
- name: Make NGINX
395396
community.general.make:
396-
chdir: /tmp/{{ nginx_version }}
397+
chdir: /tmp/nginx-{{ nginx_version }}
397398

398399
- name: Install NGINX
399400
community.general.make:
400-
chdir: /tmp/{{ nginx_version }}
401+
chdir: /tmp/nginx-{{ nginx_version }}
401402
target: install
402403

403404
- name: Set up systemd

0 commit comments

Comments
 (0)