Skip to content

Add RHEL distro to Molecule tests #498

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 4 commits into from
Mar 17, 2022
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## 0.23.1 (Unreleased)

FEATURES:

Add Molecule testing infrastructure for RHEL 7/8.

BUG FIXES:

Ansible check mode runs will no longer fail if NGINX has not yet been installed.
Expand Down
26 changes: 13 additions & 13 deletions defaults/main/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ nginx_type: opensource
# Default is true.
nginx_start: true

# Specify whether you want to maintain your version of NGINX, upgrade to the latest version, or remove NGINX.
# Specify whether you want to install NGINX, upgrade to the latest version, or remove NGINX.
# Can be used with `nginx_version` to fine tune control which version of NGINX is installed/used on each playbook execution.
# Using 'install' will install the latest version (or 'nginx_version') of NGINX on a fresh install.
# Using 'upgrade' will upgrade NGINX to the latest version (that matches your 'nginx_version') of NGINX on every playbook execution. Does not work on Alpine Linux.
Expand All @@ -42,12 +42,6 @@ nginx_manage_repo: true
# Default is nginx_repository.
nginx_install_from: nginx_repository

# Specify whether or not you want this role to install the epel-release package.
# Using 'true' will install epel-release if other criteria are met.
# Using 'false' will not install epel-release.
# Default is true.
nginx_install_epel_release: true

# Specify source install options for NGINX Open Source.
# Options represent whether to install from source also or to install from packages (default).
# These only apply if 'nginx_install_from' is set to 'source'.
Expand All @@ -59,6 +53,13 @@ nginx_install_source_pcre: false
nginx_install_source_openssl: true
nginx_install_source_zlib: false

# Specify source install module for NGINX Open Source.
# You can select any of the static modules listed on http://nginx.org/en/docs/configure.html.
# Format is '--with-*' where '*' should be used as static module name in the list below. (see an example below).
# Default is 'http_ssl_module'. (DO NOT remove it if you need SSL support).
nginx_static_modules: ['http_ssl_module']
# nginx_static_modules: ['http_v2_module'] # Example for '--with-http_v2_module'

# (Optional) Choose where to fetch the NGINX signing key from.
# Default is the official NGINX signing key host.
# nginx_signing_key: http://nginx.org/keys/nginx_signing.key
Expand Down Expand Up @@ -88,12 +89,11 @@ nginx_setup_license: true
# Default is true.
nginx_remove_license: true

# Install NGINX Static Modules.
# You can select any of the static modules listed on http://nginx.org/en/docs/configure.html.
# Format is '--with-*' where '*' should be used as static module name in the list below. (see an example below).
# Default is 'http_ssl_module'. (DO NOT remove it if you need SSL support).
nginx_static_modules: ['http_ssl_module']
# nginx_static_modules: ['http_v2_module'] # Example for '--with-http_v2_module'
# Specify whether or not you want this role to install the EPEL package when installing certain NGINX Plus modules.
# Using 'true' will install EPEL.
# Using 'false' will not install EPEL.
# Default is true.
nginx_install_epel_release: true

# Install NGINX Dynamic Modules.
# You can select any of the dynamic modules listed below. Beware of NGINX Plus only dynamic modules (these are marked).
Expand Down
2 changes: 1 addition & 1 deletion molecule/common/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ RUN \
&& dnf clean all; \
elif [ $(command -v yum) ]; then \
yum makecache fast \
&& yum install -y bash iproute initscripts 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 http://mirror.centos.org/centos/7/os/x86_64/Packages/pcre2-10.23-2.el7.x86_64.rpm \
&& sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf \
&& yum clean all; \
elif [ $(command -v zypper) ]; then \
Expand Down
14 changes: 4 additions & 10 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,20 @@
when: ansible_facts['os_family'] == "Debian"
- name: Set repo if Red Hat
set_fact:
version: "-1.21.5-1.{{ (ansible_facts['distribution']=='Amazon') | ternary('amzn2', ('el' + ansible_facts['distribution_major_version'] | string)) }}.ngx"
version: "-1.21.5-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:
args:
cmd: dnf module info nginx | grep -q 'Stream.*\[e\]' && echo -n ENABLED || dnf module enable -y nginx # noqa command-instead-of-module
register: dnf_module_enable
changed_when: dnf_module_enable.stdout != 'ENABLED'
when: ansible_facts['os_family'] == "RedHat" and ansible_facts['distribution_major_version'] is version('8', '==')
tasks:
- name: Install NGINX
include_role:
name: ansible-role-nginx
vars:
nginx_debug_output: true
nginx_version: "{{ version }}"
nginx_service_modify: true
nginx_service_timeout: 95
nginx_selinux: true
nginx_selinux_tcp_ports:
- 80
- 443
nginx_version: "{{ version }}"
nginx_logrotate_conf_enable: true
nginx_logrotate_conf:
paths:
Expand Down
14 changes: 14 additions & 0 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,20 @@ platforms:
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/usr/sbin/init"
- name: rhel-7
image: registry.access.redhat.com/ubi7/ubi:7.9
dockerfile: ../common/Dockerfile.j2
privileged: true
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/usr/sbin/init"
- name: rhel-8
image: registry.access.redhat.com/ubi8/ubi:8.5
dockerfile: ../common/Dockerfile.j2
privileged: true
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/usr/sbin/init"
- name: debian-buster
image: debian:buster-slim
dockerfile: ../common/Dockerfile.j2
Expand Down
2 changes: 1 addition & 1 deletion molecule/downgrade/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
when: ansible_facts['os_family'] == "Debian"
- name: Set repo if Red Hat
set_fact:
version: "-1.20.2-1.{{ (ansible_facts['distribution']=='Amazon') | ternary('amzn2', ('el' + ansible_facts['distribution_major_version'] | string)) }}.ngx"
version: "-1.20.2-1.{{ (ansible_facts['distribution'] == 'Amazon') | ternary('amzn2', ('el' + ansible_facts['distribution_major_version'] | string)) }}.ngx"
when: ansible_facts['os_family'] == "RedHat"
tasks:
- name: Install NGINX
Expand Down
21 changes: 21 additions & 0 deletions molecule/downgrade/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ platforms:
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/sbin/init"
- name: alpine-3.15
image: alpine:3.15
dockerfile: ../common/Dockerfile.j2
privileged: true
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/sbin/init"
- name: amazonlinux-2
image: amazonlinux:2
dockerfile: ../common/Dockerfile.j2
Expand All @@ -41,6 +48,20 @@ platforms:
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/usr/sbin/init"
- name: rhel-7
image: registry.access.redhat.com/ubi7/ubi:7.9
dockerfile: ../common/Dockerfile.j2
privileged: true
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/usr/sbin/init"
- name: rhel-8
image: registry.access.redhat.com/ubi8/ubi:8.5
dockerfile: ../common/Dockerfile.j2
privileged: true
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/usr/sbin/init"
- name: debian-buster
image: debian:buster-slim
dockerfile: ../common/Dockerfile.j2
Expand Down
13 changes: 3 additions & 10 deletions molecule/downgrade/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,16 @@
pre_tasks:
- name: Set repo if Alpine
set_fact:
version: "=1.21.4-r1"
version: "=1.21.5-r1"
when: ansible_facts['os_family'] == "Alpine"
- name: Set repo if Debian
set_fact:
version: "=1.21.4-1~{{ ansible_facts['distribution_release'] }}"
version: "=1.21.5-1~{{ ansible_facts['distribution_release'] }}"
when: ansible_facts['os_family'] == "Debian"
- name: Set repo if Red Hat
set_fact:
version: "-1.21.4-1.{{ (ansible_facts['distribution']=='Amazon') | ternary('amzn2', ('el' + ansible_facts['distribution_major_version'] | string)) }}.ngx"
version: "-1.21.5-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:
args:
cmd: dnf module info nginx | grep -q 'Stream.*\[e\]' && echo -n ENABLED || dnf module enable -y nginx # noqa command-instead-of-module
register: dnf_module_enable
changed_when: dnf_module_enable.stdout != 'ENABLED'
when: ansible_facts['os_family'] == "RedHat" and ansible_facts['distribution_major_version'] is version('8', '==')
tasks:
- name: Install NGINX
include_role:
Expand Down
10 changes: 0 additions & 10 deletions molecule/module/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,11 @@
include_role:
name: ansible-role-nginx
vars:
nginx_debug_output: true

nginx_service_modify: true
nginx_service_timeout: 95
nginx_selinux: true
nginx_selinux_tcp_ports:
- 80
- 443

nginx_modules:
- brotli
- geoip
- image-filter
- name: njs
# version: =1.19.4+0.4.4-1~bionic
state: present
- perl
- xslt
14 changes: 14 additions & 0 deletions molecule/module/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,20 @@ platforms:
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/usr/sbin/init"
- name: rhel-7
image: registry.access.redhat.com/ubi7/ubi:7.9
dockerfile: ../common/Dockerfile.j2
privileged: true
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/usr/sbin/init"
- name: rhel-8
image: registry.access.redhat.com/ubi8/ubi:8.5
dockerfile: ../common/Dockerfile.j2
privileged: true
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/usr/sbin/init"
- name: debian-buster
image: debian:buster-slim
dockerfile: ../common/Dockerfile.j2
Expand Down
14 changes: 14 additions & 0 deletions molecule/plus/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,20 @@ platforms:
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/usr/sbin/init"
- name: rhel-7
image: registry.access.redhat.com/ubi7/ubi:7.9
dockerfile: ../common/Dockerfile.j2
privileged: true
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/usr/sbin/init"
- name: rhel-8
image: registry.access.redhat.com/ubi8/ubi:8.5
dockerfile: ../common/Dockerfile.j2
privileged: true
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/usr/sbin/init"
- name: debian-buster
image: debian:buster-slim
dockerfile: ../common/Dockerfile.j2
Expand Down
2 changes: 0 additions & 2 deletions molecule/source/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
include_role:
name: ansible-role-nginx
vars:
nginx_debug_output: true

nginx_install_from: source
nginx_branch: stable
nginx_static_modules: ['http_ssl_module']
Expand Down
14 changes: 14 additions & 0 deletions molecule/source/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,20 @@ platforms:
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/usr/sbin/init"
- name: rhel-7
image: registry.access.redhat.com/ubi7/ubi:7.9
dockerfile: ../common/Dockerfile.j2
privileged: true
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/usr/sbin/init"
- name: rhel-8
image: registry.access.redhat.com/ubi8/ubi:8.5
dockerfile: ../common/Dockerfile.j2
privileged: true
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/usr/sbin/init"
- name: debian-buster
image: debian:buster-slim
dockerfile: ../common/Dockerfile.j2
Expand Down
14 changes: 14 additions & 0 deletions molecule/uninstall/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,20 @@ platforms:
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/usr/sbin/init"
- name: rhel-7
image: registry.access.redhat.com/ubi7/ubi:7.9
dockerfile: ../common/Dockerfile.j2
privileged: true
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/usr/sbin/init"
- name: rhel-8
image: registry.access.redhat.com/ubi8/ubi:8.5
dockerfile: ../common/Dockerfile.j2
privileged: true
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/usr/sbin/init"
- name: debian-buster
image: debian:buster-slim
dockerfile: ../common/Dockerfile.j2
Expand Down
2 changes: 1 addition & 1 deletion molecule/uninstall_plus/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
include_role:
name: ansible-role-nginx
vars:
nginx_setup: uninstall
nginx_type: plus
nginx_setup_license: false
nginx_setup: uninstall
14 changes: 14 additions & 0 deletions molecule/uninstall_plus/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,20 @@ platforms:
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/usr/sbin/init"
- name: rhel-7
image: registry.access.redhat.com/ubi7/ubi:7.9
dockerfile: ../common/Dockerfile.j2
privileged: true
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/usr/sbin/init"
- name: rhel-8
image: registry.access.redhat.com/ubi8/ubi:8.5
dockerfile: ../common/Dockerfile.j2
privileged: true
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/usr/sbin/init"
- name: debian-buster
image: debian:buster-slim
dockerfile: ../common/Dockerfile.j2
Expand Down
14 changes: 14 additions & 0 deletions molecule/upgrade/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ platforms:
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/usr/sbin/init"
- name: rhel-7
image: registry.access.redhat.com/ubi7/ubi:7.9
dockerfile: ../common/Dockerfile.j2
privileged: true
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/usr/sbin/init"
- name: rhel-8
image: registry.access.redhat.com/ubi8/ubi:8.5
dockerfile: ../common/Dockerfile.j2
privileged: true
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
command: "/usr/sbin/init"
- name: debian-buster
image: debian:buster-slim
dockerfile: ../common/Dockerfile.j2
Expand Down
9 changes: 1 addition & 8 deletions molecule/upgrade/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,8 @@
when: ansible_facts['os_family'] == "Debian"
- name: Set repo if Red Hat
set_fact:
version: "-1.21.5-1.{{ (ansible_facts['distribution']=='Amazon') | ternary('amzn2', ('el' + ansible_facts['distribution_major_version'] | string)) }}.ngx"
version: "-1.21.5-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:
args:
cmd: dnf module info nginx | grep -q 'Stream.*\[e\]' && echo -n ENABLED || dnf module enable -y nginx # noqa command-instead-of-module
register: dnf_module_enable
changed_when: dnf_module_enable.stdout != 'ENABLED'
when: ansible_facts['os_family'] == "RedHat" and ansible_facts['distribution_major_version'] is version('8', '==')
tasks:
- name: Install NGINX
include_role:
Expand Down
Loading