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
## 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)
BREAKING CHANGES:

View File

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

View File

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

View File

@ -17,7 +17,7 @@ ENV {{ var }} {{ value }}
RUN \
if [ $(command -v apt-get) ]; then \
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; \
elif [ $(command -v dnf) ]; then \
dnf makecache \
@ -25,7 +25,7 @@ RUN \
&& dnf clean all; \
elif [ $(command -v yum) ]; then \
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 \
&& yum clean all; \
elif [ $(command -v zypper) ]; then \

View File

@ -4,15 +4,15 @@
pre_tasks:
- name: Set repo if Alpine
set_fact:
version: "=1.19.8-r1"
version: "=1.21.1-r1"
when: ansible_facts['os_family'] == "Alpine"
- name: Set repo if Debian
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"
- name: Set repo if Red Hat
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"
- name: Enable NGINX @CentOS-AppStream dnf modules
shell:

View File

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

View File

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

View File

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

View File

@ -34,6 +34,13 @@ platforms:
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
image: centos:7
dockerfile: ../common/Dockerfile.j2

View File

@ -6,13 +6,6 @@ lint: |
yamllint .
ansible-lint --force-color
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
image: alpine:3.11
dockerfile: ../common/Dockerfile.j2
@ -34,6 +27,20 @@ platforms:
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
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
image: centos:7
dockerfile: ../common/Dockerfile.j2
@ -55,8 +62,8 @@ platforms:
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/sbin/init"
- name: ubuntu-xenial
image: ubuntu:xenial
- name: debian-bullseye
image: debian:bullseye-slim
dockerfile: ../common/Dockerfile.j2
privileged: true
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:
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
enabled: true
gpgcheck: true
mode: 0644
when:
- ansible_facts['distribution_major_version'] is version('8', '<')
- nginx_manage_repo | bool
module_hotfixes: true
when: nginx_manage_repo | bool
- name: (CentOS/RHEL 8) Configure NGINX repository
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
- name: (Amazon Linux/CentOS/RHEL) Install NGINX
yum:
name: "nginx{{ nginx_version | default('') }}"
state: "{{ nginx_state }}"
disablerepo: "*"
enablerepo: nginx
update_cache: true
ignore_errors: "{{ ansible_check_mode }}"
notify: (Handler) Run NGINX

View File

@ -2,7 +2,7 @@
# Supported NGINX Open Source distributions
# https://nginx.org/en/docs/install.html
nginx_distributions: [
'Alpine', 'CentOS', 'Debian', 'FreeBSD', 'RedHat', 'SLES', 'Ubuntu',
'Alpine', 'Amazon', 'CentOS', 'Debian', 'FreeBSD', 'RedHat', 'SLES', 'Ubuntu',
'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
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"
nginx_default_repository_amazon: "https://nginx.org/packages/{{ (nginx_branch == 'mainline') | ternary('mainline/', '') }}/amzn2/$releasever/$basearch"
nginx_default_repository_debian:
- "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"
@ -53,7 +54,7 @@ nginx_debian_dependencies: [
# Red Hat dependencies
nginx_redhat_dependencies: [
'ca-certificates', 'openssl',
'ca-certificates', 'openssl', 'yum-utils',
]
# SLES dependencies