Skip to content

Commit e6f5dda

Browse files
authored
Add RHEL distro to Molecule tests (#498)
1 parent 16d1d18 commit e6f5dda

File tree

20 files changed

+167
-58
lines changed

20 files changed

+167
-58
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## 0.23.1 (Unreleased)
44

5+
FEATURES:
6+
7+
Add Molecule testing infrastructure for RHEL 7/8.
8+
59
BUG FIXES:
610

711
Ansible check mode runs will no longer fail if NGINX has not yet been installed.

defaults/main/main.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ nginx_type: opensource
2222
# Default is true.
2323
nginx_start: true
2424

25-
# Specify whether you want to maintain your version of NGINX, upgrade to the latest version, or remove NGINX.
25+
# Specify whether you want to install NGINX, upgrade to the latest version, or remove NGINX.
2626
# Can be used with `nginx_version` to fine tune control which version of NGINX is installed/used on each playbook execution.
2727
# Using 'install' will install the latest version (or 'nginx_version') of NGINX on a fresh install.
2828
# 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.
@@ -42,12 +42,6 @@ nginx_manage_repo: true
4242
# Default is nginx_repository.
4343
nginx_install_from: nginx_repository
4444

45-
# Specify whether or not you want this role to install the epel-release package.
46-
# Using 'true' will install epel-release if other criteria are met.
47-
# Using 'false' will not install epel-release.
48-
# Default is true.
49-
nginx_install_epel_release: true
50-
5145
# Specify source install options for NGINX Open Source.
5246
# Options represent whether to install from source also or to install from packages (default).
5347
# These only apply if 'nginx_install_from' is set to 'source'.
@@ -59,6 +53,13 @@ nginx_install_source_pcre: false
5953
nginx_install_source_openssl: true
6054
nginx_install_source_zlib: false
6155

56+
# Specify source install module for NGINX Open Source.
57+
# You can select any of the static modules listed on http://nginx.org/en/docs/configure.html.
58+
# Format is '--with-*' where '*' should be used as static module name in the list below. (see an example below).
59+
# Default is 'http_ssl_module'. (DO NOT remove it if you need SSL support).
60+
nginx_static_modules: ['http_ssl_module']
61+
# nginx_static_modules: ['http_v2_module'] # Example for '--with-http_v2_module'
62+
6263
# (Optional) Choose where to fetch the NGINX signing key from.
6364
# Default is the official NGINX signing key host.
6465
# nginx_signing_key: http://nginx.org/keys/nginx_signing.key
@@ -88,12 +89,11 @@ nginx_setup_license: true
8889
# Default is true.
8990
nginx_remove_license: true
9091

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

9898
# Install NGINX Dynamic Modules.
9999
# You can select any of the dynamic modules listed below. Beware of NGINX Plus only dynamic modules (these are marked).

molecule/common/Dockerfile.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ RUN \
2525
&& dnf clean all; \
2626
elif [ $(command -v yum) ]; then \
2727
yum makecache fast \
28-
&& yum install -y bash iproute initscripts sudo /usr/bin/python /usr/bin/python2-config vim yum-plugin-ovl \
28+
&& 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 \
2929
&& sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf \
3030
&& yum clean all; \
3131
elif [ $(command -v zypper) ]; then \

molecule/default/converge.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,20 @@
1212
when: ansible_facts['os_family'] == "Debian"
1313
- name: Set repo if Red Hat
1414
set_fact:
15-
version: "-1.21.5-1.{{ (ansible_facts['distribution']=='Amazon') | ternary('amzn2', ('el' + ansible_facts['distribution_major_version'] | string)) }}.ngx"
15+
version: "-1.21.5-1.{{ (ansible_facts['distribution'] == 'Amazon') | ternary('amzn2', ('el' + ansible_facts['distribution_major_version'] | string)) }}.ngx"
1616
when: ansible_facts['os_family'] == "RedHat"
17-
- name: Enable NGINX @CentOS-AppStream dnf modules
18-
shell:
19-
args:
20-
cmd: dnf module info nginx | grep -q 'Stream.*\[e\]' && echo -n ENABLED || dnf module enable -y nginx # noqa command-instead-of-module
21-
register: dnf_module_enable
22-
changed_when: dnf_module_enable.stdout != 'ENABLED'
23-
when: ansible_facts['os_family'] == "RedHat" and ansible_facts['distribution_major_version'] is version('8', '==')
2417
tasks:
2518
- name: Install NGINX
2619
include_role:
2720
name: ansible-role-nginx
2821
vars:
29-
nginx_debug_output: true
22+
nginx_version: "{{ version }}"
23+
nginx_service_modify: true
24+
nginx_service_timeout: 95
3025
nginx_selinux: true
3126
nginx_selinux_tcp_ports:
3227
- 80
3328
- 443
34-
nginx_version: "{{ version }}"
3529
nginx_logrotate_conf_enable: true
3630
nginx_logrotate_conf:
3731
paths:

molecule/default/molecule.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,20 @@ platforms:
4848
volumes:
4949
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
5050
command: "/usr/sbin/init"
51+
- name: rhel-7
52+
image: registry.access.redhat.com/ubi7/ubi:7.9
53+
dockerfile: ../common/Dockerfile.j2
54+
privileged: true
55+
volumes:
56+
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
57+
command: "/usr/sbin/init"
58+
- name: rhel-8
59+
image: registry.access.redhat.com/ubi8/ubi:8.5
60+
dockerfile: ../common/Dockerfile.j2
61+
privileged: true
62+
volumes:
63+
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
64+
command: "/usr/sbin/init"
5165
- name: debian-buster
5266
image: debian:buster-slim
5367
dockerfile: ../common/Dockerfile.j2

molecule/downgrade/converge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
when: ansible_facts['os_family'] == "Debian"
1313
- name: Set repo if Red Hat
1414
set_fact:
15-
version: "-1.20.2-1.{{ (ansible_facts['distribution']=='Amazon') | ternary('amzn2', ('el' + ansible_facts['distribution_major_version'] | string)) }}.ngx"
15+
version: "-1.20.2-1.{{ (ansible_facts['distribution'] == 'Amazon') | ternary('amzn2', ('el' + ansible_facts['distribution_major_version'] | string)) }}.ngx"
1616
when: ansible_facts['os_family'] == "RedHat"
1717
tasks:
1818
- name: Install NGINX

molecule/downgrade/molecule.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ platforms:
2727
volumes:
2828
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
2929
command: "/sbin/init"
30+
- name: alpine-3.15
31+
image: alpine:3.15
32+
dockerfile: ../common/Dockerfile.j2
33+
privileged: true
34+
volumes:
35+
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
36+
command: "/sbin/init"
3037
- name: amazonlinux-2
3138
image: amazonlinux:2
3239
dockerfile: ../common/Dockerfile.j2
@@ -41,6 +48,20 @@ platforms:
4148
volumes:
4249
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
4350
command: "/usr/sbin/init"
51+
- name: rhel-7
52+
image: registry.access.redhat.com/ubi7/ubi:7.9
53+
dockerfile: ../common/Dockerfile.j2
54+
privileged: true
55+
volumes:
56+
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
57+
command: "/usr/sbin/init"
58+
- name: rhel-8
59+
image: registry.access.redhat.com/ubi8/ubi:8.5
60+
dockerfile: ../common/Dockerfile.j2
61+
privileged: true
62+
volumes:
63+
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
64+
command: "/usr/sbin/init"
4465
- name: debian-buster
4566
image: debian:buster-slim
4667
dockerfile: ../common/Dockerfile.j2

molecule/downgrade/prepare.yml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,16 @@
44
pre_tasks:
55
- name: Set repo if Alpine
66
set_fact:
7-
version: "=1.21.4-r1"
7+
version: "=1.21.5-r1"
88
when: ansible_facts['os_family'] == "Alpine"
99
- name: Set repo if Debian
1010
set_fact:
11-
version: "=1.21.4-1~{{ ansible_facts['distribution_release'] }}"
11+
version: "=1.21.5-1~{{ ansible_facts['distribution_release'] }}"
1212
when: ansible_facts['os_family'] == "Debian"
1313
- name: Set repo if Red Hat
1414
set_fact:
15-
version: "-1.21.4-1.{{ (ansible_facts['distribution']=='Amazon') | ternary('amzn2', ('el' + ansible_facts['distribution_major_version'] | string)) }}.ngx"
15+
version: "-1.21.5-1.{{ (ansible_facts['distribution'] == 'Amazon') | ternary('amzn2', ('el' + ansible_facts['distribution_major_version'] | string)) }}.ngx"
1616
when: ansible_facts['os_family'] == "RedHat"
17-
- name: Enable NGINX @CentOS-AppStream dnf modules
18-
shell:
19-
args:
20-
cmd: dnf module info nginx | grep -q 'Stream.*\[e\]' && echo -n ENABLED || dnf module enable -y nginx # noqa command-instead-of-module
21-
register: dnf_module_enable
22-
changed_when: dnf_module_enable.stdout != 'ENABLED'
23-
when: ansible_facts['os_family'] == "RedHat" and ansible_facts['distribution_major_version'] is version('8', '==')
2417
tasks:
2518
- name: Install NGINX
2619
include_role:

molecule/module/converge.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,11 @@
66
include_role:
77
name: ansible-role-nginx
88
vars:
9-
nginx_debug_output: true
10-
11-
nginx_service_modify: true
12-
nginx_service_timeout: 95
13-
nginx_selinux: true
14-
nginx_selinux_tcp_ports:
15-
- 80
16-
- 443
17-
189
nginx_modules:
1910
- brotli
2011
- geoip
2112
- image-filter
2213
- name: njs
23-
# version: =1.19.4+0.4.4-1~bionic
2414
state: present
2515
- perl
2616
- xslt

molecule/module/molecule.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,20 @@ platforms:
4848
volumes:
4949
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
5050
command: "/usr/sbin/init"
51+
- name: rhel-7
52+
image: registry.access.redhat.com/ubi7/ubi:7.9
53+
dockerfile: ../common/Dockerfile.j2
54+
privileged: true
55+
volumes:
56+
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
57+
command: "/usr/sbin/init"
58+
- name: rhel-8
59+
image: registry.access.redhat.com/ubi8/ubi:8.5
60+
dockerfile: ../common/Dockerfile.j2
61+
privileged: true
62+
volumes:
63+
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
64+
command: "/usr/sbin/init"
5165
- name: debian-buster
5266
image: debian:buster-slim
5367
dockerfile: ../common/Dockerfile.j2

0 commit comments

Comments
 (0)