Skip to content

Commit ed7cfed

Browse files
authored
Support all the currently supported NAP WAF distributions (#272)
1 parent f26729c commit ed7cfed

File tree

11 files changed

+146
-38
lines changed

11 files changed

+146
-38
lines changed

CHANGELOG.md

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

33
## 0.9.1 (Unreleased)
44

5+
FEATURES:
6+
7+
- Add support for installing NGINX App Protect WAF on Alpine Linux 3.16/3.17, RHEL 9, and Ubuntu jammy.
8+
- Remove support for installing NGINX App Protect WAF on Ubuntu bionic.
9+
510
ENHANCEMENTS:
611

712
- Bump the Ansible `ansible.posix` collection to `1.5.4`, `community.general` collection to `6.4.0`, `community.crypto` collection to `2.14.1` and `community.docker` collection to `3.4.7`.

meta/main.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,16 @@ galaxy_info:
1212
platforms:
1313
- name: Alpine
1414
versions: [all]
15-
- name: Amazon Linux 2
16-
versions: [all]
17-
- name: EL
18-
versions: ["7", "8"]
15+
- name: Amazon Linux
16+
versions: ['2']
1917
- name: Debian
2018
versions: [bullseye]
19+
- name: EL
20+
versions: ['7', '8', '9']
21+
- name: OracleLinux
22+
versions: ['8']
2123
- name: Ubuntu
22-
versions: [bionic, focal]
24+
versions: [focal, jammy]
2325

2426
galaxy_tags:
2527
- waf

molecule/default/molecule.yml

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@
22
driver:
33
name: docker
44
platforms:
5+
- name: alpine-3.16
6+
image: alpine:3.16
7+
platform: amd64
8+
dockerfile: ../common/Dockerfile.j2
9+
privileged: true
10+
cgroupns_mode: host
11+
volumes:
12+
- /sys/fs/cgroup:/sys/fs/cgroup:rw
13+
command: /sbin/init
14+
- name: alpine-3.17
15+
image: alpine:3.17
16+
platform: amd64
17+
dockerfile: ../common/Dockerfile.j2
18+
privileged: true
19+
cgroupns_mode: host
20+
volumes:
21+
- /sys/fs/cgroup:/sys/fs/cgroup:rw
22+
command: /sbin/init
523
- name: amazonlinux-2
624
image: amazonlinux:2
725
platform: amd64
@@ -56,15 +74,17 @@ platforms:
5674
volumes:
5775
- /sys/fs/cgroup:/sys/fs/cgroup:rw
5876
command: /usr/sbin/init
59-
- name: ubuntu-bionic
60-
image: ubuntu:bionic
77+
- name: rhel-9
78+
image: redhat/ubi9:9.1.0
79+
env:
80+
SMDEV_CONTAINER_OFF: "1"
6181
platform: amd64
6282
dockerfile: ../common/Dockerfile.j2
6383
privileged: true
6484
cgroupns_mode: host
6585
volumes:
6686
- /sys/fs/cgroup:/sys/fs/cgroup:rw
67-
command: /sbin/init
87+
command: /usr/sbin/init
6888
- name: ubuntu-focal
6989
image: ubuntu:focal
7090
platform: amd64
@@ -74,6 +94,15 @@ platforms:
7494
volumes:
7595
- /sys/fs/cgroup:/sys/fs/cgroup:rw
7696
command: /sbin/init
97+
- name: ubuntu-jammy
98+
image: ubuntu:jammy
99+
platform: amd64
100+
dockerfile: ../common/Dockerfile.j2
101+
privileged: true
102+
cgroupns_mode: host
103+
volumes:
104+
- /sys/fs/cgroup:/sys/fs/cgroup:rw
105+
command: /sbin/init
77106
provisioner:
78107
name: ansible
79108
playbooks:

molecule/uninstall/molecule.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
driver:
33
name: docker
4-
platforms: # Ubuntu bionic results in a segmentation fault error as of Ansible core 2.13
4+
platforms:
55
- name: centos-7
66
image: centos:7
77
platform: amd64

tasks/common/install/setup-license.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
- name: (Debian/Red Hat OSs) Check that NGINX App Protect WAF/DoS license is valid
8989
ansible.builtin.assert:
9090
that:
91-
- "{{ not cert['expired'] | bool }}"
92-
- "{{ cert['public_key'] == key['public_key'] }}"
91+
- not cert['expired'] | bool
92+
- cert['public_key'] == key['public_key']
9393
success_msg: Your NGINX App Protect WAF/DoS license is valid!
9494
fail_msg: Something went wrong! Make sure your NGINX App Protect WAF/DoS license is valid!

tasks/common/keys/setup-keys.yml

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,51 @@
11
---
2-
- name: (Alpine Linux) Set up NGINX App Protect DoS signing key
2+
- name: (Alpine Linux) Set up NGINX App Protect and security updates signing key
33
when: ansible_facts['os_family'] == "Alpine"
44
block:
5-
- name: (Alpine Linux) Set up NGINX App Protect DoS signing key URL
5+
- name: (Alpine Linux) Set up NGINX App Protect WAF/DoS signing key URL
66
ansible.builtin.set_fact:
77
keysite: "{{ nginx_app_protect_signing_key['nginx_plus'] | default(nginx_app_protect_default_signing_key_rsa_pub) }}"
88

9-
- name: (Alpine Linux) Download NGINX App Protect DoS signing key
9+
- name: (Alpine Linux) Download NGINX App Protect WAF/DoS signing key
1010
ansible.builtin.get_url:
1111
url: "{{ keysite }}"
1212
dest: /etc/apk/keys/nginx_signing.rsa.pub
1313
mode: "0400"
1414

15+
- name: (Alpine Linux) Set up NGINX App Protect WAF security updates signing key URL
16+
ansible.builtin.set_fact:
17+
keysite_security_updates: "{{ nginx_app_protect_signing_key['waf_security_updates'] | default(nginx_app_protect_waf_security_updates_default_signing_key_rsa_pub) }}"
18+
when: nginx_app_protect_waf_enable | bool
19+
20+
- name: (Alpine Linux) Download NGINX App Protect WAF security updates signing key
21+
ansible.builtin.get_url:
22+
url: "{{ keysite_security_updates }}"
23+
dest: /etc/apk/keys/app-protect-security-updates.rsa.pub
24+
mode: "0400"
25+
when: nginx_app_protect_waf_enable | bool
26+
1527
- name: (Debian/Ubuntu) Set up NGINX App Protect and security updates signing key
1628
when: ansible_facts['os_family'] == "Debian"
1729
block:
18-
- name: (Debian/Ubuntu) Add NGINX Plus signing key
30+
- name: (Debian/Ubuntu) Add NGINX App Protect WAF/DoS signing key
1931
ansible.builtin.apt_key:
2032
keyring: /usr/share/keyrings/nginx-archive-keyring.gpg
2133
url: "{{ nginx_app_protect_signing_key['nginx_plus'] | default(nginx_app_protect_default_signing_key_pgp) }}"
2234

23-
- name: (Debian/Ubuntu) Add NGINX App Protect security updates signing key
35+
- name: (Debian/Ubuntu) Add NGINX App Protect WAF security updates signing key
2436
ansible.builtin.apt_key:
2537
keyring: /usr/share/keyrings/nginx-archive-keyring.gpg
2638
url: "{{ nginx_app_protect_waf_signing_key['waf_security_updates'] | default(nginx_app_protect_waf_security_updates_default_signing_key_pgp) }}"
27-
when: (nginx_app_protect_waf_install_signatures | bool) or (nginx_app_protect_waf_install_threat_campaigns | bool)
39+
when: nginx_app_protect_waf_enable | bool
2840

2941
- name: (Amazon Linux/CentOS/RHEL) Set up NGINX App Protect and security updates signing key
3042
when: ansible_facts['os_family'] == "RedHat"
3143
block:
32-
- name: (CentOS/RHEL) Add NGINX Plus signing key
44+
- name: (CentOS/RHEL) Add NGINX WAF/DoS signing key
3345
ansible.builtin.rpm_key:
3446
key: "{{ nginx_app_protect_signing_key['nginx_plus'] | default(nginx_app_protect_default_signing_key_pgp) }}"
3547

36-
- name: (Amazon Linux/CentOS/RHEL) Add NGINX App Protect security updates signing key
48+
- name: (Amazon Linux/CentOS/RHEL) Add NGINX App Protect WAF security updates signing key
3749
ansible.builtin.rpm_key:
3850
key: "{{ nginx_app_protect_waf_signing_key['waf_security_updates'] | default(nginx_app_protect_waf_security_updates_default_signing_key_pgp) }}"
39-
when: (nginx_app_protect_waf_install_signatures | bool) or (nginx_app_protect_waf_install_threat_campaigns | bool)
51+
when: nginx_app_protect_waf_enable | bool

tasks/common/prerequisites/install-dependencies.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@
7878
- ansible_facts['distribution_major_version'] is version('7', '==')
7979
- nginx_app_protect_use_rhel_subscription_repos | bool
8080

81-
- name: (RHEL 8) Set up RHEL dependencies from RHEL official repositories
81+
- name: (RHEL 8/9) Set up RHEL dependencies from RHEL official repositories
8282
community.general.rhsm_repository:
83-
name: codeready-builder-for-rhel-8-x86_64-rpms
83+
name: codeready-builder-for-rhel-{{ ansible_facts['distribution_major_version'] }}-x86_64-rpms
8484
when:
85-
- ansible_facts['distribution_major_version'] is version('8', '==')
85+
- ansible_facts['distribution_major_version'] is version('8', '>=')
8686
- nginx_app_protect_use_rhel_subscription_repos | bool
8787

8888
- name: (Oracle Linux) Set up Oracle Linux specific repositories

tasks/common/validate/validate.yml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
- name: (WAF) Check whether you are using a supported NGINX App Protect WAF distribution
33
ansible.builtin.assert:
44
that:
5-
- "{{ ansible_facts['distribution'] | lower in nginx_app_protect_waf_distributions.keys() | list }}"
6-
- "{{ (ansible_facts['distribution_version'] | regex_search('\\d+\\.?\\d*') in nginx_app_protect_waf_distributions[ansible_facts['distribution'] | lower]['versions'] | string)
7-
if ansible_facts['distribution'] | lower in ['ubuntu'] else ansible_facts['distribution_major_version'] in nginx_app_protect_waf_distributions[ansible_facts['distribution'] | lower]['versions'] | string }}"
8-
- "{{ ansible_facts['architecture'] in nginx_app_protect_waf_distributions[ansible_facts['distribution'] | lower]['architectures'] }}"
5+
- ansible_facts['distribution'] | lower in nginx_app_protect_waf_distributions.keys() | list
6+
- (ansible_facts['distribution_version'] | regex_search('\\d+\\.?\\d*') in nginx_app_protect_waf_distributions[ansible_facts['distribution'] | lower]['versions'] | string if ansible_facts['distribution'] | lower in ['ubuntu'] else ansible_facts['distribution_major_version'] in nginx_app_protect_waf_distributions[ansible_facts['distribution'] | lower]['versions'] | string)
7+
- ansible_facts['architecture'] in nginx_app_protect_waf_distributions[ansible_facts['distribution'] | lower]['architectures']
98
success_msg: Your distribution, {{ nginx_app_protect_waf_distributions[ansible_facts['distribution'] | lower]['name'] }} {{ ansible_facts['distribution_version'] }} ({{ ansible_facts['architecture'] }}), is supported by NGINX App Protect WAF.
109
fail_msg: Your distribution, {{ nginx_app_protect_waf_distributions[ansible_facts['distribution'] | lower]['name'] }} {{ ansible_facts['distribution_version'] }} ({{ ansible_facts['architecture'] }}), is not supported by NGINX App Protect WAF.
1110
when:
@@ -16,10 +15,9 @@
1615
- name: (DoS) Check whether you are using a supported NGINX App Protect DoS distribution
1716
ansible.builtin.assert:
1817
that:
19-
- "{{ ansible_facts['distribution'] | lower in nginx_app_protect_dos_distributions.keys() | list }}"
20-
- "{{ (ansible_facts['distribution_version'] | regex_search('\\d+\\.?\\d*') in nginx_app_protect_dos_distributions[ansible_facts['distribution'] | lower]['versions'] | string)
21-
if ansible_facts['distribution'] | lower in ['alpine', 'ubuntu'] else ansible_facts['distribution_major_version'] in nginx_app_protect_dos_distributions[ansible_facts['distribution'] | lower]['versions'] | string }}"
22-
- "{{ ansible_facts['architecture'] in nginx_app_protect_dos_distributions[ansible_facts['distribution'] | lower]['architectures'] }}"
18+
- ansible_facts['distribution'] | lower in nginx_app_protect_dos_distributions.keys() | list
19+
- (ansible_facts['distribution_version'] | regex_search('\\d+\\.?\\d*') in nginx_app_protect_dos_distributions[ansible_facts['distribution'] | lower]['versions'] | string if ansible_facts['distribution'] | lower in ['alpine', 'ubuntu'] else ansible_facts['distribution_major_version'] in nginx_app_protect_dos_distributions[ansible_facts['distribution'] | lower]['versions'] | string)
20+
- ansible_facts['architecture'] in nginx_app_protect_dos_distributions[ansible_facts['distribution'] | lower]['architectures']
2321
success_msg: Your distribution, {{ nginx_app_protect_dos_distributions[ansible_facts['distribution'] | lower]['name'] }} {{ ansible_facts['distribution_version'] }} ({{ ansible_facts['architecture'] }}), is supported by NGINX App Protect DoS.
2422
fail_msg: Your distribution, {{ nginx_app_protect_dos_distributions[ansible_facts['distribution'] | lower]['name'] }} {{ ansible_facts['distribution_version'] }} ({{ ansible_facts['architecture'] }}), is not supported by NGINX App Protect DoS.
2523
when:
@@ -53,8 +51,8 @@
5351
- name: Check that the variables for 'nginx_app_protect_security_policy_file_enable' are defined
5452
ansible.builtin.assert:
5553
that:
56-
- "{{ item }} is defined"
57-
- "{{ item }} | length > 0"
54+
- item is defined
55+
- item | length > 0
5856
fail_msg: If you want to publish a security policy file, don't forget to define at least one 'src' and 'dest' variables
5957
loop:
6058
- nginx_app_protect_security_policy_file.0.src
@@ -65,8 +63,8 @@
6563
- name: Check that the variables for 'nginx_app_protect_log_policy_file_enable' are defined
6664
ansible.builtin.assert:
6765
that:
68-
- "{{ item }} is defined"
69-
- "{{ item }} | length > 0"
66+
- item is defined
67+
- item | length > 0
7068
fail_msg: If you want to publish a log policy file, don't forget to define at least one 'src' and 'dest' variables
7169
loop:
7270
- nginx_app_protect_log_policy_file.0.src

tasks/dos/install-alpine.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
- name: (Alpine Linux) {{ nginx_app_protect_dos_setup | capitalize }} NGINX App Protect DoS
2828
community.general.apk:
2929
name: app-protect-dos{{ (nginx_app_protect_dos_state == 'absent') | ternary(',nginx-plus-module-appprotectdos', '') }}
30-
repository: "{{ nginx_app_protect_dos_repository | default(nginx_app_protect_dos_default_repository_alpine) }}"
3130
state: "{{ nginx_app_protect_dos_state }}"
3231
ignore_errors: "{{ ansible_check_mode }}"
3332
when: nginx_app_protect_license_status is not defined

tasks/waf/install-alpine.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
- name: (Alpine Linux) {{ nginx_app_protect_license_status is defined | ternary('Remove', 'Configure') }} NGINX Plus repository
3+
ansible.builtin.lineinfile:
4+
path: /etc/apk/repositories
5+
insertafter: EOF
6+
line: "{{ nginx_plus_repository | default(nginx_plus_default_repository_alpine) }}"
7+
state: "{{ nginx_app_protect_license_status | default((nginx_app_protect_waf_setup == 'uninstall') | ternary('absent', 'present')) }}"
8+
when: nginx_app_protect_waf_manage_repo | bool
9+
10+
- name: (Alpine Linux) {{ nginx_app_protect_license_status is defined | ternary('Remove', 'Configure') }} NGINX App Protect WAF repository
11+
ansible.builtin.lineinfile:
12+
path: /etc/apk/repositories
13+
insertafter: EOF
14+
line: "{{ nginx_app_protect_waf_repository | default(nginx_app_protect_waf_default_repository_alpine) }}"
15+
state: "{{ nginx_app_protect_license_status | default((nginx_app_protect_waf_setup == 'uninstall') | ternary('absent', 'present')) }}"
16+
when: nginx_app_protect_waf_manage_repo | bool
17+
18+
- name: (Alpine Linux) {{ nginx_app_protect_license_status is defined | ternary('Remove', 'Configure') }} NGINX App Protect WAF security updates repository
19+
ansible.builtin.lineinfile:
20+
path: /etc/apk/repositories
21+
insertafter: EOF
22+
line: "{{ nginx_app_protect_waf_security_updates_repository | default(nginx_app_protect_waf_security_updates_default_repository_alpine) }}"
23+
state: "{{ nginx_app_protect_license_status | default((nginx_app_protect_waf_setup == 'uninstall') | ternary('absent', 'present')) }}"
24+
when: nginx_app_protect_waf_manage_repo | bool
25+
26+
- name: (Alpine Linux) {{ nginx_app_protect_waf_setup | capitalize }} NGINX Plus
27+
community.general.apk:
28+
name: nginx-plus
29+
repository: "{{ nginx_plus_repository | default(nginx_plus_default_repository_alpine) }}"
30+
state: "{{ nginx_app_protect_waf_state }}"
31+
ignore_errors: "{{ ansible_check_mode }}"
32+
when: nginx_app_protect_license_status is not defined
33+
notify: (Handler - NGINX App Protect) Run NGINX
34+
35+
- name: (Alpine Linux) {{ nginx_app_protect_waf_setup | capitalize }} NGINX App Protect WAF
36+
community.general.apk:
37+
name: app-protect
38+
state: "{{ nginx_app_protect_waf_state }}"
39+
ignore_errors: "{{ ansible_check_mode }}"
40+
when: nginx_app_protect_license_status is not defined
41+
notify: (Handler - NGINX App Protect) Run NGINX
42+
43+
- name: (Alpine Linux) {{ nginx_app_protect_waf_setup | capitalize }} NGINX App Protect WAF signatures {{ nginx_app_protect_waf_signatures_version is defined | ternary(nginx_app_protect_signatures_version, '') }}
44+
community.general.apk:
45+
name: app-protect-attack-signatures{{ nginx_app_protect_waf_signatures_version | default('') }}
46+
state: "{{ nginx_app_protect_waf_state }}"
47+
ignore_errors: "{{ ansible_check_mode }}"
48+
when: nginx_app_protect_license_status is not defined
49+
notify: (Handler - NGINX App Protect) Run NGINX
50+
51+
- name: (Alpine Linux) {{ nginx_app_protect_waf_setup | capitalize }} NGINX App Protect WAF threat campaigns {{ nginx_app_protect_waf_signatures_version is defined | ternary(nginx_app_protect_signatures_version, '') }}
52+
community.general.apk:
53+
name: app-protect-threat-campaigns{{ nginx_app_protect_waf_threat_campaigns_version | default('') }}
54+
state: "{{ nginx_app_protect_waf_state }}"
55+
ignore_errors: "{{ ansible_check_mode }}"
56+
when: nginx_app_protect_license_status is not defined
57+
notify: (Handler - NGINX App Protect) Run NGINX

0 commit comments

Comments
 (0)