Skip to content

Add support for nginx_version when compiling NGINX from source #661

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ jobs:
- downgrade-plus
- plus
- source
- source-version
- stable
- uninstall
- uninstall-plus
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ FEATURES:
- Remove Ubuntu kinetic from the list of NGINX OSS tested and supported distributions.
- Remove Alpine Linux 3.14 and Ubuntu bionic from the list of NGINX Plus tested and supported distributions.
- The `geoip2` module for NGINX Plus is no longer supported on Amazon Linux.
- Add support for specific version for NGINX OSS install from source

CI/CD:

Expand Down
3 changes: 3 additions & 0 deletions defaults/main/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ nginx_type: opensource
# nginx_version: "=1.23.2-1~jammy"
# For NGINX Plus you'll need to specify the R* release like below (Ubuntu jammy example).
# nginx_version: "=28-1~jammy"
# For Open source and from source the version should be of the following format 1.25.1
# As in https://nginx.org/download/ `nginx-<version>.<extension>`
# nginx_version: "1.25.1"

# Start NGINX service.
# Default is true.
Expand Down
16 changes: 16 additions & 0 deletions molecule/source-version/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
- name: Converge
hosts: all
tasks:
- name: Install NGINX from source
ansible.builtin.include_role:
name: nginxinc.nginx
vars:
nginx_install_from: source
nginx_branch: stable
nginx_version: "1.25.1"
nginx_static_modules: [http_ssl_module]
nginx_install_source_build_tools: true
nginx_install_source_pcre: false
nginx_install_source_openssl: false
nginx_install_source_zlib: false
188 changes: 188 additions & 0 deletions molecule/source-version/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
---
driver:
name: docker
platforms: # Oracle Linux 7 works in local tests but bugs out in GitHub actions for some undetermined reason
- name: almalinux-8
image: almalinux:8
dockerfile: ../common/Dockerfile.j2
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
command: /usr/sbin/init
- name: almalinux-9
image: almalinux:9
dockerfile: ../common/Dockerfile.j2
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
command: /usr/sbin/init
- name: alpine-3.15
image: alpine:3.15
dockerfile: ../common/Dockerfile.j2
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
command: /sbin/init
- name: alpine-3.16
image: alpine:3.16
platform: x86_64
dockerfile: ../common/Dockerfile.j2
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
command: /sbin/init
- name: alpine-3.17
image: alpine:3.17
# platform: aarch64
dockerfile: ../common/Dockerfile.j2
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
command: /sbin/init
- name: alpine-3.18
image: alpine:3.18
dockerfile: ../common/Dockerfile.j2
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
command: /sbin/init
- name: amazonlinux-2
image: amazonlinux:2
platform: x86_64
dockerfile: ../common/Dockerfile.j2
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
command: /usr/sbin/init
- name: centos-7
image: centos:7
platform: x86_64
dockerfile: ../common/Dockerfile.j2
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
command: /usr/sbin/init
- name: debian-bullseye
image: debian:bullseye-slim
dockerfile: ../common/Dockerfile.j2
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
command: /sbin/init
- name: debian-bookworm
image: debian:bookworm-slim
dockerfile: ../common/Dockerfile.j2
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
command: /sbin/init
- name: oraclelinux-8
image: oraclelinux:8
dockerfile: ../common/Dockerfile.j2
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
command: /usr/sbin/init
- name: oraclelinux-9
image: oraclelinux:9
dockerfile: ../common/Dockerfile.j2
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
command: /usr/sbin/init
- name: rhel-7
image: registry.access.redhat.com/ubi7:7.9
platform: x86_64
dockerfile: ../common/Dockerfile.j2
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
command: /usr/sbin/init
- name: rhel-8
image: redhat/ubi8:8.7
# platform: s390x
dockerfile: ../common/Dockerfile.j2
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
command: /usr/sbin/init
- name: rhel-9
image: redhat/ubi9:9.1.0
# platform: aarch64
dockerfile: ../common/Dockerfile.j2
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
command: /usr/sbin/init
- name: rockylinux-8
image: rockylinux:8
dockerfile: ../common/Dockerfile.j2
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
command: /usr/sbin/init
- name: rockylinux-9
image: rockylinux:9.0
dockerfile: ../common/Dockerfile.j2
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
command: /usr/sbin/init
- name: sles15
image: registry.suse.com/bci/bci-base:15.4
platform: x86_64
dockerfile: ../common/Dockerfile.j2
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
command: /usr/sbin/init
- name: ubuntu-focal
image: ubuntu:focal
# platform: s390x
dockerfile: ../common/Dockerfile.j2
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
command: /sbin/init
- name: ubuntu-jammy
image: ubuntu:jammy
# platform: aarch64
dockerfile: ../common/Dockerfile.j2
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
command: /sbin/init
- name: ubuntu-lunar
image: ubuntu:lunar
dockerfile: ../common/Dockerfile.j2
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
command: /sbin/init
provisioner:
name: ansible
log: true
playbooks:
converge: converge.yml
verify: verify.yml
25 changes: 25 additions & 0 deletions molecule/source-version/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
- name: Verify
hosts: all
tasks:
- name: Check if NGINX service is running
ansible.builtin.service:
name: nginx
state: started
enabled: true
check_mode: true
register: service
failed_when: (service is changed) or (service is failed)

- name: Verify NGINX is up and running
ansible.builtin.uri:
url: http://localhost
status_code: 200

- name: Verify the correct version of NGINX has been installed
ansible.builtin.command: nginx -v
args:
chdir: "{{ ((ansible_facts['system'] | lower is not search('bsd')) | ternary('/etc/nginx', '/usr/local/sbin')) }}"
changed_when: false
register: version
failed_when: version is not search('1.25.1')
29 changes: 15 additions & 14 deletions tasks/opensource/install-source.yml
Original file line number Diff line number Diff line change
Expand Up @@ -314,24 +314,25 @@
chdir: /tmp/openssl-{{ openssl_version }}
target: install

- name: Get NGINX version
- name: Get latest NGINX version
when: nginx_version is undefined
block:
- name: Fetch NGINX version
- name: Fetch NGINX latest version
ansible.builtin.uri:
url: https://version.nginx.com/nginx/{{ nginx_branch }}
return_content: true
check_mode: false
register: nginx_versions
register: nginx_latest_version

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

- name: Check for NGINX install
ansible.builtin.stat:
path: /usr/sbin/nginx
follow: true
register: nginx_result
- name: Check for NGINX install
ansible.builtin.stat:
path: /usr/sbin/nginx
follow: true
register: nginx_result

- name: Add NGINX group
ansible.builtin.group:
Expand All @@ -352,8 +353,8 @@
block:
- name: Download NGINX
ansible.builtin.get_url:
url: https://nginx.org/download/{{ nginx_version }}.tar.gz
dest: /tmp/{{ nginx_version }}.tar.gz
url: https://nginx.org/download/nginx-{{ nginx_version }}.tar.gz
dest: /tmp/nginx-{{ nginx_version }}.tar.gz
mode: "0600"
register: nginx_source

Expand Down Expand Up @@ -387,17 +388,17 @@
{{ nginx_install_source_zlib | ternary('--with-zlib=../zlib-' + zlib_version | string, '') }}
{{ nginx_install_source_openssl | ternary('--with-openssl=../openssl-' + openssl_version | string, '') }}
{{ nginx_install_source_static_modules | default('') }}
chdir: /tmp/{{ nginx_version }}
chdir: /tmp/nginx-{{ nginx_version }}
creates: /tmp/makefile
register: nginx_configure

- name: Make NGINX
community.general.make:
chdir: /tmp/{{ nginx_version }}
chdir: /tmp/nginx-{{ nginx_version }}

- name: Install NGINX
community.general.make:
chdir: /tmp/{{ nginx_version }}
chdir: /tmp/nginx-{{ nginx_version }}
target: install

- name: Set up systemd
Expand Down