Add support for installing NGINX OSS in Amazon Linux (#435)

This commit is contained in:
Alessandro Fael Garcia 2021-08-23 16:35:02 +02:00 committed by GitHub
parent e42253f415
commit 894fe47c2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 91 additions and 65 deletions

View File

@ -1,5 +1,16 @@
# Changelog # Changelog
## 0.21.1 (Unreleased)
FEATURES:
Support installing NGINX OSS in Amazon Linux.
ENHANCEMENTS:
* Update the README and Ansible metadata matrix of supported distributions.
* Update the Molecule tests to include the newly supported distributions and remove distributions that are no longer supported.
## 0.21.0 (August 11, 2021) ## 0.21.0 (August 11, 2021)
BREAKING CHANGES: BREAKING CHANGES:

View File

@ -55,15 +55,18 @@ The NGINX Ansible role supports all platforms supported by [NGINX Open Source](h
```yaml ```yaml
Alpine: Alpine:
- 3.10
- 3.11 - 3.11
- 3.12 - 3.12
- 3.13 - 3.13
- 3.14
Amazon Linux:
- 2
CentOS: CentOS:
- 7.4+ - 7.4+
- 8 - 8
Debian: Debian:
- buster - buster
- bullseye
Red Hat: Red Hat:
- 7.4+ - 7.4+
- 8 - 8
@ -71,10 +74,9 @@ SUSE/SLES:
- 12 - 12
- 15 - 15
Ubuntu: Ubuntu:
- xenial
- bionic - bionic
- focal - focal
- groovy - hirsute
``` ```
### NGINX Plus ### NGINX Plus

View File

@ -23,20 +23,22 @@ galaxy_info:
- name: Debian - name: Debian
versions: versions:
- buster - buster
- bullseye
- name: EL - name: EL
versions: versions:
- 7 - 7
- 8 - 8
- name: FreeBSD - name: FreeBSD
versions: versions:
- 11.2 - 11.4
- 12.1 - 12.1
- 13
- name: Ubuntu - name: Ubuntu
versions: versions:
- xenial - xenial
- bionic - bionic
- focal - focal
- groovy - hirsute
- name: SLES - name: SLES
versions: versions:
- 12 - 12

View File

@ -17,7 +17,7 @@ ENV {{ var }} {{ value }}
RUN \ RUN \
if [ $(command -v apt-get) ]; then \ if [ $(command -v apt-get) ]; then \
apt-get update \ apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y aptitude bash ca-certificates curl iproute2 python-apt python3 python3-apt procps sudo systemd systemd-sysv vim \ && DEBIAN_FRONTEND=noninteractive apt-get install -y aptitude bash ca-certificates curl iproute2 python3 python3-apt procps sudo systemd systemd-sysv vim \
&& apt-get clean; \ && apt-get clean; \
elif [ $(command -v dnf) ]; then \ elif [ $(command -v dnf) ]; then \
dnf makecache \ dnf makecache \
@ -25,7 +25,7 @@ RUN \
&& dnf clean all; \ && dnf clean all; \
elif [ $(command -v yum) ]; then \ elif [ $(command -v yum) ]; then \
yum makecache fast \ yum makecache fast \
&& yum install -y bash iproute sudo /usr/bin/python /usr/bin/python2-config vim yum-plugin-ovl \ && yum install -y bash iproute initscripts sudo /usr/bin/python /usr/bin/python2-config vim yum-plugin-ovl \
&& sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf \ && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf \
&& yum clean all; \ && yum clean all; \
elif [ $(command -v zypper) ]; then \ elif [ $(command -v zypper) ]; then \

View File

@ -4,15 +4,15 @@
pre_tasks: pre_tasks:
- name: Set repo if Alpine - name: Set repo if Alpine
set_fact: set_fact:
version: "=1.19.8-r1" version: "=1.21.1-r1"
when: ansible_facts['os_family'] == "Alpine" when: ansible_facts['os_family'] == "Alpine"
- name: Set repo if Debian - name: Set repo if Debian
set_fact: set_fact:
version: "=1.19.8-1~{{ ansible_facts['distribution_release'] }}" version: "=1.21.1-1~{{ ansible_facts['distribution_release'] }}"
when: ansible_facts['os_family'] == "Debian" when: ansible_facts['os_family'] == "Debian"
- name: Set repo if Red Hat - name: Set repo if Red Hat
set_fact: set_fact:
version: "-1.19.8-1.el{{ ansible_facts['distribution_major_version'] }}.ngx" version: "-1.21.1-1.{{ (ansible_facts['distribution']=='Amazon') | ternary('amzn2', ('el' + ansible_facts['distribution_major_version'] | string)) }}.ngx"
when: ansible_facts['os_family'] == "RedHat" when: ansible_facts['os_family'] == "RedHat"
- name: Enable NGINX @CentOS-AppStream dnf modules - name: Enable NGINX @CentOS-AppStream dnf modules
shell: shell:

View File

@ -6,13 +6,6 @@ lint: |
yamllint . yamllint .
ansible-lint --force-color ansible-lint --force-color
platforms: platforms:
- name: alpine-3.10
image: alpine:3.10
dockerfile: ../common/Dockerfile.j2
privileged: true
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/sbin/init"
- name: alpine-3.11 - name: alpine-3.11
image: alpine:3.11 image: alpine:3.11
dockerfile: ../common/Dockerfile.j2 dockerfile: ../common/Dockerfile.j2
@ -34,6 +27,20 @@ platforms:
volumes: volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw" - "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/sbin/init" command: "/sbin/init"
- name: alpine-3.14
image: alpine:3.14
dockerfile: ../common/Dockerfile.j2
privileged: true
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/sbin/init"
- name: amazonlinux
image: amazonlinux:2
dockerfile: ../common/Dockerfile.j2
privileged: true
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/usr/sbin/init"
- name: centos-7 - name: centos-7
image: centos:7 image: centos:7
dockerfile: ../common/Dockerfile.j2 dockerfile: ../common/Dockerfile.j2
@ -55,8 +62,8 @@ platforms:
volumes: volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw" - "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/sbin/init" command: "/sbin/init"
- name: ubuntu-xenial - name: debian-bullseye
image: ubuntu:xenial image: debian:bullseye-slim
dockerfile: ../common/Dockerfile.j2 dockerfile: ../common/Dockerfile.j2
privileged: true privileged: true
volumes: volumes:

View File

@ -6,13 +6,6 @@ lint: |
yamllint . yamllint .
ansible-lint --force-color ansible-lint --force-color
platforms: platforms:
- name: alpine-3.10
image: alpine:3.10
dockerfile: ../common/Dockerfile.j2
privileged: true
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/sbin/init"
- name: alpine-3.11 - name: alpine-3.11
image: alpine:3.11 image: alpine:3.11
dockerfile: ../common/Dockerfile.j2 dockerfile: ../common/Dockerfile.j2
@ -34,6 +27,20 @@ platforms:
volumes: volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw" - "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/sbin/init" command: "/sbin/init"
- name: alpine-3.14
image: alpine:3.14
dockerfile: ../common/Dockerfile.j2
privileged: true
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/sbin/init"
- name: amazonlinux
image: amazonlinux:2
dockerfile: ../common/Dockerfile.j2
privileged: true
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/usr/sbin/init"
- name: centos-7 - name: centos-7
image: centos:7 image: centos:7
dockerfile: ../common/Dockerfile.j2 dockerfile: ../common/Dockerfile.j2
@ -55,8 +62,8 @@ platforms:
volumes: volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw" - "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/sbin/init" command: "/sbin/init"
- name: ubuntu-xenial - name: debian-bullseye
image: ubuntu:xenial image: debian:bullseye-slim
dockerfile: ../common/Dockerfile.j2 dockerfile: ../common/Dockerfile.j2
privileged: true privileged: true
volumes: volumes:

View File

@ -17,12 +17,12 @@
- cookie-flag - cookie-flag
- encrypted-session - encrypted-session
- geoip - geoip
- geoip2 - "{{ ansible_facts['distribution'] == 'Amazon' | ternary('', 'geoip2') }}"
- headers-more - headers-more
- image-filter - image-filter
- lua - lua
- njs - njs
- opentracing - "{{ ansible_facts['distribution'] == 'Amazon' | ternary('', 'opentracing') }}"
- passenger - passenger
- perl - perl
- prometheus - prometheus

View File

@ -34,6 +34,13 @@ platforms:
volumes: volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw" - "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/sbin/init" command: "/sbin/init"
- name: amazonlinux
image: amazonlinux:2
dockerfile: ../common/Dockerfile.j2
privileged: true
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/usr/sbin/init"
- name: centos-7 - name: centos-7
image: centos:7 image: centos:7
dockerfile: ../common/Dockerfile.j2 dockerfile: ../common/Dockerfile.j2

View File

@ -6,13 +6,6 @@ lint: |
yamllint . yamllint .
ansible-lint --force-color ansible-lint --force-color
platforms: platforms:
- name: alpine-3.10
image: alpine:3.10
dockerfile: ../common/Dockerfile.j2
privileged: true
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/sbin/init"
- name: alpine-3.11 - name: alpine-3.11
image: alpine:3.11 image: alpine:3.11
dockerfile: ../common/Dockerfile.j2 dockerfile: ../common/Dockerfile.j2
@ -34,6 +27,20 @@ platforms:
volumes: volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw" - "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/sbin/init" command: "/sbin/init"
- name: alpine-3.14
image: alpine:3.14
dockerfile: ../common/Dockerfile.j2
privileged: true
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/sbin/init"
- name: amazonlinux
image: amazonlinux:2
dockerfile: ../common/Dockerfile.j2
privileged: true
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/usr/sbin/init"
- name: centos-7 - name: centos-7
image: centos:7 image: centos:7
dockerfile: ../common/Dockerfile.j2 dockerfile: ../common/Dockerfile.j2
@ -55,8 +62,8 @@ platforms:
volumes: volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw" - "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/sbin/init" command: "/sbin/init"
- name: ubuntu-xenial - name: debian-bullseye
image: ubuntu:xenial image: debian:bullseye-slim
dockerfile: ../common/Dockerfile.j2 dockerfile: ../common/Dockerfile.j2
privileged: true privileged: true
volumes: volumes:

View File

@ -1,38 +1,20 @@
--- ---
- name: (CentOS/RHEL 6/7) Configure NGINX repository - name: (Amazon Linux/CentOS/RHEL) Configure NGINX repository
yum_repository: yum_repository:
name: nginx name: nginx
baseurl: "{{ nginx_repository | default(nginx_default_repository_redhat) }}" baseurl: "{{ nginx_repository |
default(lookup('vars', 'nginx_default_repository_' + ((ansible_facts['distribution'] == 'Amazon') | ternary('amazon', 'redhat')))) }}"
description: NGINX Repository description: NGINX Repository
enabled: true enabled: true
gpgcheck: true gpgcheck: true
mode: 0644 mode: 0644
when: module_hotfixes: true
- ansible_facts['distribution_major_version'] is version('8', '<') when: nginx_manage_repo | bool
- nginx_manage_repo | bool
- name: (CentOS/RHEL 8) Configure NGINX repository - name: (Amazon Linux/CentOS/RHEL) Install NGINX
blockinfile:
path: /etc/yum.repos.d/nginx.repo
create: true
block: |
[nginx]
baseurl = {{ nginx_repository | default(nginx_default_repository_redhat) }}
enabled = 1
gpgcheck = 1
name = NGINX Repository
module_hotfixes = true
mode: 0644
when:
- ansible_facts['distribution_major_version'] is version('8', '==')
- nginx_manage_repo | bool
- name: (CentOS/RHEL) Install NGINX
yum: yum:
name: "nginx{{ nginx_version | default('') }}" name: "nginx{{ nginx_version | default('') }}"
state: "{{ nginx_state }}" state: "{{ nginx_state }}"
disablerepo: "*"
enablerepo: nginx
update_cache: true update_cache: true
ignore_errors: "{{ ansible_check_mode }}" ignore_errors: "{{ ansible_check_mode }}"
notify: (Handler) Run NGINX notify: (Handler) Run NGINX

View File

@ -2,7 +2,7 @@
# Supported NGINX Open Source distributions # Supported NGINX Open Source distributions
# https://nginx.org/en/docs/install.html # https://nginx.org/en/docs/install.html
nginx_distributions: [ nginx_distributions: [
'Alpine', 'CentOS', 'Debian', 'FreeBSD', 'RedHat', 'SLES', 'Ubuntu', 'Alpine', 'Amazon', 'CentOS', 'Debian', 'FreeBSD', 'RedHat', 'SLES', 'Ubuntu',
'NetBSD', 'OpenBSD', 'DragonFlyBSD', 'HardenedBSD', 'NetBSD', 'OpenBSD', 'DragonFlyBSD', 'HardenedBSD',
] ]
@ -19,6 +19,7 @@ nginx_default_signing_key_pgp: https://nginx.org/keys/nginx_signing.key
# Default NGINX Open Source repositories # Default NGINX Open Source repositories
nginx_default_repository_alpine: "https://nginx.org/packages/{{ (nginx_branch == 'mainline') | ternary('mainline/', '') }}\ nginx_default_repository_alpine: "https://nginx.org/packages/{{ (nginx_branch == 'mainline') | ternary('mainline/', '') }}\
alpine/v{{ ansible_facts['distribution_version'] | regex_search('^[0-9]+\\.[0-9]+') }}/main" alpine/v{{ ansible_facts['distribution_version'] | regex_search('^[0-9]+\\.[0-9]+') }}/main"
nginx_default_repository_amazon: "https://nginx.org/packages/{{ (nginx_branch == 'mainline') | ternary('mainline/', '') }}/amzn2/$releasever/$basearch"
nginx_default_repository_debian: nginx_default_repository_debian:
- "deb [arch={{ (ansible_facts['architecture'] == 'aarch64') | ternary('arm64', 'amd64') }}] https://nginx.org/packages/{{ (nginx_branch == 'mainline') | ternary('mainline/', '') }}\ - "deb [arch={{ (ansible_facts['architecture'] == 'aarch64') | ternary('arm64', 'amd64') }}] https://nginx.org/packages/{{ (nginx_branch == 'mainline') | ternary('mainline/', '') }}\
{{ ansible_facts['distribution'] | lower }}/ {{ ansible_facts['distribution_release'] }} nginx" {{ ansible_facts['distribution'] | lower }}/ {{ ansible_facts['distribution_release'] }} nginx"
@ -53,7 +54,7 @@ nginx_debian_dependencies: [
# Red Hat dependencies # Red Hat dependencies
nginx_redhat_dependencies: [ nginx_redhat_dependencies: [
'ca-certificates', 'openssl', 'ca-certificates', 'openssl', 'yum-utils',
] ]
# SLES dependencies # SLES dependencies