Skip to content

Commit 03ed41e

Browse files
authored
Improve workflow for building NGINX from source (#573)
1 parent 713f63b commit 03ed41e

File tree

5 files changed

+78
-40
lines changed

5 files changed

+78
-40
lines changed

CHANGELOG.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,37 @@
22

33
## 0.23.3 (Unreleased)
44

5+
BREAKING CHANGES:
6+
7+
* When building from source the various libraries required to build NGINX from source, you will no longer need to specify the name of the package, only the version:
8+
9+
```yaml
10+
pcre_version: pcre2-10.42
11+
```
12+
13+
is now:
14+
15+
```yaml
16+
pcre_version: 10.42
17+
```
18+
19+
* The `nginx_install_source_<package>: false` parameters have been reversed. Setting `nginx_install_source_pcre: true` will now build PCRE from source, instead of using the default package manager. The previous behavior was unintuitive at best.
20+
521
FEATURES:
622

723
* Add AlmaLinux, Oracle Linux and Rocky Linux to the list of NGINX OSS and NGINX Plus tested and supported platforms.
824
* Add Alpine Linux 3.17 to the NGINX list of tested and supported platforms (and remove Alpine Linux 3.13 from the list of NGINX OSS supported platforms).
925

1026
ENHANCEMENTS:
1127

12-
Bump the Ansible `community.general` collection to `6.2.0`, `community.crypto` collection to `2.10.0` and `community.docker` collection to `3.4.0`.
28+
* Bump the Ansible `community.general` collection to `6.2.0`, `community.crypto` collection to `2.10.0` and `community.docker` collection to `3.4.0`.
29+
* Use the official GitHub repositories as the source for the various packages required to compile NGINX OSS from source.
1330

1431
BUG FIXES:
1532

1633
* Fix an issue when installing the GeoIP2 module on an UBI 7 container where the the `libmaxminddb` package dependency might not be available via `yum` (if it's not available, `libmaxminddb` is installed from an external source).
1734
* GitHub actions should now correctly skip \*plus\* scenarios only when the NGINX Plus license secrets are not present.
35+
* Update the versions of the various packages required to build NGINX from source. The version of `zlib` listed in the role was no longer available.
1836

1937
TESTS:
2038

defaults/main/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ nginx_install_from: nginx_repository
4646
# Specify source install options for NGINX Open Source.
4747
# Options represent whether to install from source also or to install from packages (default).
4848
# These only apply if 'nginx_install_from' is set to 'source'.
49-
# For the tools, true means we will install from a package and false means install from source.
5049
# 'nginx_install_source_build_tools' will install compiler and build tools from packages.
51-
# If false, you need to have these present.
50+
# If set to false, you need to have these present.
51+
# For the required libraries, true means we will install from source and false means we will install using the default package manager.
5252
nginx_install_source_build_tools: true
5353
nginx_install_source_pcre: false
5454
nginx_install_source_openssl: true

molecule/source/converge.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
nginx_branch: stable
1111
nginx_static_modules: [http_ssl_module]
1212
nginx_install_source_build_tools: true
13-
nginx_install_source_pcre: true
14-
nginx_install_source_openssl: true
15-
nginx_install_source_zlib: true
13+
nginx_install_source_pcre: false
14+
nginx_install_source_openssl: false
15+
nginx_install_source_zlib: false

tasks/opensource/install-source.yml

Lines changed: 51 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -92,21 +92,21 @@
9292
block:
9393
- name: Check for PCRE install
9494
ansible.builtin.stat:
95-
path: /tmp/{{ pcre_version }}
95+
path: /tmp/pcre-{{ pcre_version }}
9696
register: pcre_result
9797

9898
- name: Check for ZLib install
9999
ansible.builtin.stat:
100-
path: /tmp/{{ zlib_version }}
100+
path: /tmp/zlib-{{ zlib_version }}
101101
register: zlib_result
102102

103103
- name: Check for OpenSSL install
104104
ansible.builtin.stat:
105-
path: /tmp/{{ openssl_version }}
105+
path: /tmp/openssl-{{ openssl_version }}
106106
register: openssl_result
107107

108108
- name: Install PCRE dependecy from package
109-
when: nginx_install_source_pcre | bool
109+
when: not nginx_install_source_pcre | bool
110110
block:
111111
- name: (Alpine Linux) Install PCRE dependency from package
112112
community.general.apk:
@@ -135,40 +135,47 @@
135135
- name: Install PCRE dependence from source
136136
when:
137137
- not pcre_result.stat.exists | bool
138-
- not nginx_install_source_pcre | bool
138+
- nginx_install_source_pcre | bool
139139
- not ansible_check_mode | bool
140140
block:
141141
- name: Download PCRE dependency
142142
ansible.builtin.get_url:
143-
url: "{{ (pcre_release == 2) | ternary('https://github.com/PCRE2Project/pcre2/releases/download/' ~ pcre_version ~ '/' ~ pcre_version ~ '.tar.gz', 'https://ftp.exim.org/pub/pcre/' ~ pcre_version ~ '.tar.gz') }}"
144-
dest: /tmp/{{ pcre_version }}.tar.gz
143+
url: "{{ (pcre_release == 2) | ternary('https://github.com/PCRE2Project/pcre2/releases/download/pcre2-' ~ pcre_version ~ '/pcre2-' ~ pcre_version ~ '.tar.gz', 'https://ftp.exim.org/pub/pcre/pcre-' ~ pcre_version ~ '.tar.gz') }}"
144+
dest: /tmp
145145
mode: 0600
146146
register: pcre_source
147147

148+
- name: Ensure PCRE directory exists
149+
ansible.builtin.file:
150+
path: /tmp/pcre-{{ pcre_version }}
151+
state: directory
152+
mode: 0700
153+
148154
- name: Unpack PCRE dependency
149155
ansible.builtin.unarchive:
150156
copy: false
151-
dest: /tmp/
152157
src: "{{ pcre_source.dest }}"
158+
dest: /tmp/pcre-{{ pcre_version }}/
153159
mode: 0700
160+
extra_opts: [--strip-components=1]
154161

155162
- name: Configure PCRE dependency
156163
ansible.builtin.command: ./configure
157164
args:
158-
chdir: /tmp/{{ pcre_version }}
165+
chdir: /tmp/pcre-{{ pcre_version }}
159166
creates: /tmp/makefile
160167

161168
- name: Make PCRE dependency
162169
community.general.make:
163-
chdir: /tmp/{{ pcre_version }}
170+
chdir: /tmp/pcre-{{ pcre_version }}
164171

165172
- name: Install PCRE dependency
166173
community.general.make:
167-
chdir: /tmp/{{ pcre_version }}
174+
chdir: /tmp/pcre-{{ pcre_version }}
168175
target: install
169176

170177
- name: Install ZLib dependency from package
171-
when: nginx_install_source_zlib | bool
178+
when: not nginx_install_source_zlib | bool
172179
block:
173180
- name: (Alpine Linux) Install ZLib dependency from package
174181
community.general.apk:
@@ -197,41 +204,47 @@
197204
- name: Install ZLib dependency from source
198205
when:
199206
- not zlib_result.stat.exists | bool
200-
- not nginx_install_source_zlib | bool
207+
- nginx_install_source_zlib | bool
201208
- not ansible_check_mode | bool
202209
block:
203210
- name: Download ZLib dependency
204211
ansible.builtin.get_url:
205-
url: https://zlib.net/{{ zlib_version }}.tar.gz
206-
dest: /tmp/{{ zlib_version }}.tar.gz
212+
url: https://github.com/madler/zlib/releases/download/v{{ zlib_version }}/zlib-{{ zlib_version }}.tar.gz
213+
dest: /tmp
207214
mode: 0600
208215
register: zlib_source
209216

217+
- name: Ensure ZLib directory exists
218+
ansible.builtin.file:
219+
path: /tmp/zlib-{{ zlib_version }}
220+
state: directory
221+
mode: 0700
222+
210223
- name: Unpack ZLib dependency
211224
ansible.builtin.unarchive:
212225
copy: false
213-
dest: /tmp/
214226
src: "{{ zlib_source.dest }}"
227+
dest: /tmp/zlib-{{ zlib_version }}
215228
mode: 0700
229+
extra_opts: [--strip-components=1]
216230

217231
- name: Configure ZLib dependency
218232
ansible.builtin.command: ./configure
219233
args:
220-
chdir: /tmp/{{ zlib_version }}
234+
chdir: /tmp/zlib-{{ zlib_version }}
221235
creates: /tmp/makefile
222236

223237
- name: Make ZLib dependency
224238
community.general.make:
225-
chdir: /tmp/{{ zlib_version }}
239+
chdir: /tmp/zlib-{{ zlib_version }}
226240

227241
- name: Install ZLib dependency
228242
community.general.make:
229-
chdir: /tmp/{{ zlib_version }}
243+
chdir: /tmp/zlib-{{ zlib_version }}
230244
target: install
231245

232-
233246
- name: Install OpenSSL dependency from package
234-
when: nginx_install_source_openssl | bool
247+
when: not nginx_install_source_openssl | bool
235248
block:
236249
- name: (Alpine Linux) Install OpenSSL dependency from package
237250
community.general.apk:
@@ -260,36 +273,43 @@
260273
- name: Install OpenSSL dependency from source
261274
when:
262275
- not openssl_result.stat.exists | bool
263-
- not nginx_install_source_openssl | bool
276+
- nginx_install_source_openssl | bool
264277
- not ansible_check_mode | bool
265278
block:
266279
- name: Download OpenSSL dependency
267280
ansible.builtin.get_url:
268-
url: https://www.openssl.org/source/{{ openssl_version }}.tar.gz
281+
url: https://github.com/openssl/openssl/archive/refs/tags/openssl-{{ openssl_version }}.tar.gz
269282
dest: /tmp/{{ openssl_version }}.tar.gz
270283
mode: 0600
271284
register: openssl_source
272285

286+
- name: Ensure OpenSSL directory exists
287+
ansible.builtin.file:
288+
path: /tmp/openssl-{{ openssl_version }}
289+
state: directory
290+
mode: 0700
291+
273292
- name: Unpack OpenSSL dependency
274293
ansible.builtin.unarchive:
275294
copy: false
276-
dest: /tmp/
277295
src: "{{ openssl_source.dest }}"
296+
dest: /tmp/openssl-{{ openssl_version }}
278297
mode: 0700
298+
extra_opts: [--strip-components=1]
279299

280300
- name: Configure OpenSSL dependency
281301
ansible.builtin.command: ./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl shared zlib
282302
args:
283-
chdir: /tmp/{{ openssl_version }}
303+
chdir: /tmp/openssl-{{ openssl_version }}
284304
creates: /tmp/makefile
285305

286306
- name: Make OpenSSL dependency
287307
community.general.make:
288-
chdir: /tmp/{{ openssl_version }}
308+
chdir: /tmp/openssl-{{ openssl_version }}
289309

290310
- name: Install OpenSSL dependency
291311
community.general.make:
292-
chdir: /tmp/{{ openssl_version }}
312+
chdir: /tmp/openssl-{{ openssl_version }}
293313
target: install
294314

295315
- name: Get NGINX version
@@ -338,8 +358,8 @@
338358
- name: Unpack NGINX
339359
ansible.builtin.unarchive:
340360
copy: false
341-
dest: /tmp/
342361
src: "{{ nginx_source.dest }}"
362+
dest: /tmp
343363
mode: 0755
344364

345365
- name: Set static modules
@@ -360,9 +380,9 @@
360380
--user=nginx
361381
--with-mail=dynamic
362382
--with-stream
363-
{{ nginx_install_source_pcre | ternary('', '--with-pcre=../' + pcre_version) }}
364-
{{ nginx_install_source_zlib | ternary('', '--with-zlib=../' + zlib_version) }}
365-
{{ nginx_install_source_openssl | ternary('', '--with-openssl=../' + openssl_version) }}
383+
{{ nginx_install_source_pcre | ternary('--with-pcre=../pcre-' + pcre_version | string, '') }}
384+
{{ nginx_install_source_zlib | ternary('--with-zlib=../zlib-' + zlib_version | string, '') }}
385+
{{ nginx_install_source_openssl | ternary('--with-openssl=../openssl-' + openssl_version | string, '') }}
366386
{{ nginx_install_source_static_modules | default('') }}
367387
args:
368388
chdir: /tmp/{{ nginx_version }}

vars/main.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ nginx_freebsd_dependencies: [
7474
# Default locations and versions when 'nginx_install_from' is set to 'source'.
7575
# Set 'pcre_release' to 1 to install PCRE 1, modify the 'openssl_version' to move back to 1.1.1.
7676
pcre_release: 2
77-
pcre_version: pcre2-10.40
78-
zlib_version: zlib-1.2.12
79-
openssl_version: openssl-3.0.5
77+
pcre_version: 10.42
78+
zlib_version: 1.2.13
79+
openssl_version: 3.0.7
8080

8181
# Supported NGINX Open Source dynamic modules
8282
nginx_modules_list: [

0 commit comments

Comments
 (0)