Skip to content

Commit c0597cb

Browse files
authored
Merge pull request #1 from nginxinc/ga
GA release of the role
2 parents b852f24 + 81842f5 commit c0597cb

19 files changed

+378
-154
lines changed

README.md

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
![NGINX App Protect logo](images/nap-logo.png)
1+
<img src="images/nap-logo.png" width="60">
22

33
NGINX App Protect Ansible Role
44
==============================
@@ -37,15 +37,34 @@ Use `git clone https://github.com/nginxinc/ansible-role-nginx-app-protect.git` t
3737
Platforms
3838
---------
3939

40-
The NGINX Ansible role supports all platforms supported by [NGINX Plus](https://www.nginx.com/products/technical-specs/):
41-
42-
43-
**NGINX Plus**
40+
The NGINX App Protect Ansible role supports all platforms supported by [NGINX Plus](https://www.nginx.com/products/technical-specs/) that intersect with the following list:
4441

4542
```yaml
4643
CentOS:
4744
versions:
4845
- 7.4
46+
- 7.5
47+
- 7.6
48+
- 7.7
49+
- 7.8
50+
- 8.0
51+
- 8.1
52+
- 8.2
53+
Debian:
54+
versions:
55+
- 9.0
56+
- 9.1
57+
- 9.2
58+
- 9.3
59+
- 9.4
60+
- 9.5
61+
- 9.6
62+
- 9.7
63+
- 9.8
64+
- 9.9
65+
- 9.10
66+
- 9.11
67+
- 9.12
4968
```
5069
5170
Role Variables
@@ -59,7 +78,7 @@ Dependencies
5978

6079
- Since this role uses the [package_facts](https://docs.ansible.com/ansible/latest/modules/package_facts_module.html) module, on debian-based systems the `python-apt` package must be installed on targeted hosts.
6180

62-
- NGINX+ R18-R20 must already be installed on the target system
81+
- NGINX+ R19-R21 must already be installed on the target system
6382

6483
Example Playbook
6584
----------------
@@ -73,11 +92,26 @@ This is a sample playbook file for using the role to install NGINX App Protect o
7392
become: true
7493
vars:
7594
# Installs NGINX App Protect and all dependencies to the target host
76-
app_protect_install: true
95+
app_protect_enable: true
96+
97+
# Specify whether you want to maintain your version of NGINX App Protect, upgrade to the latest version, or remove NGINX App Protect.
98+
# Can be used with `app_protect_version` to achieve fine grained control on which version of NGINX App Protect is installed/used on each playbook execution.
99+
# Using 'present' will install the latest version (or 'app_protect_version') of NGINX App Protect on a fresh install.
100+
# Using 'latest' will upgrade NGINX App Protect to the latest version (that matches your 'app_protect_version') of NGINX App Protect on every playbook execution.
101+
# Using 'absent' will remove NGINX App Protect from your system.
102+
# Default is present.
103+
app_protect_state: present
104+
105+
# The installation of NGINX App Protect includes a base signature set, which may be out of date.
106+
# This option installs the latest NGINX App Protect signatures.
107+
app_protect_install_signatures: true
77108

78109
# Creates basic configuration files and enables NGINX App Protect on the target host
79110
app_protect_configure: true
80111

112+
# Removes the license (certificate and key) for the NGINX App Protect repositories on the target host(s) when playbook run is complete.
113+
app_protect_delete_license: true
114+
81115
# For use with the app_protect_configure option to determine if the default security policy will be written to the target host
82116
# Used when `app_protect_configure: true`.
83117
app_protect_security_policy_template_enable: true
@@ -90,7 +124,7 @@ This is a sample playbook file for using the role to install NGINX App Protect o
90124
# Used when `app_protect_configure: true`.
91125
app_protect_log_policy_template_enable: true
92126

93-
# Which violation types to log. Possible values: TBD
127+
# Which violation types to log. Possible values: all, illegal, blocked
94128
# Used when `app_protect_configure: true` and `app_protect_log_policy_template_enable: true`.
95129
log_policy_filter_request_type: all
96130

@@ -109,8 +143,10 @@ This is a sample playbook file for using the role to install NGINX App Protect o
109143
# Used when `nginx_conf_template_enable: true`.
110144
nginx_demo_workload: http://10.1.10.105:8080
111145

112-
# Determines whether or not to clean up tmp files created during the installation and configuration steps.
113-
cleanup_when_done: true
146+
# The location of the certificate and key to be used when downloading the packages onto the host
147+
nginx_license:
148+
certificate: "{{playbook_dir}}/license/nginx-repo.crt"
149+
key: "{{playbook_dir}}/license/nginx-repo.key"
114150

115151
roles:
116152
- role: ansible-role-nginx-app-protect

defaults/main.yml

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,63 @@
11
---
22
# defaults file for ansible-role-nginx-app-protect
33

4-
app_protect_install: true
5-
app_protect_configure: true
4+
# Installs NGINX App Protect and all dependencies to the target host
5+
app_protect_enable: true
66

7-
tmp_dir: /tmp/app-protect
8-
cleanup_when_done: true
7+
# Specify whether you want to maintain your version of NGINX App Protect, upgrade to the latest version, or remove NGINX App Protect.
8+
# Can be used with `app_protect_version` to achieve fine grained control on which version of NGINX App Protect is installed/used on each playbook execution.
9+
# Using 'present' will install the latest version (or 'app_protect_version') of NGINX App Protect on a fresh install.
10+
# Using 'latest' will upgrade NGINX App Protect to the latest version (that matches your 'app_protect_version') of NGINX App Protect on every playbook execution.
11+
# Using 'absent' will remove NGINX App Protect from your system.
12+
# Default is present.
13+
app_protect_state: present
914

10-
# Start NGINX service.
15+
# # OPTIONAL - Installs a specific version of NGINX App Protect
16+
# app_protect_version: 20
17+
18+
# The installation of NGINX App Protect includes a base signature set, which may be out of date.
19+
# This option installs the latest NGINX App Protect signatures.
20+
app_protect_install_signatures: true
21+
22+
# Creates basic configuration files and enables NGINX App Protect on the target host
23+
app_protect_configure: false
24+
25+
# Removes the license (certificate and key) for the NGINX App Protect repositories on the target host(s) when playbook run is complete.
26+
app_protect_delete_license: true
27+
28+
# Start/Restart NGINX service when App Protect related changes are complete.
1129
# Default is true.
1230
nginx_start: true
1331

32+
# Choose where to fetch the NGINX App Protect signing key from.
33+
# Default is the official NGINX App Protect signing key host.
34+
# app_protect_signing_key: https://cs.nginx.com/static/keys/app-protect.key
35+
1436
# populate this dictionary of lists with appropriate values from the ansible_os_family and ansible_distribution_version facts
1537
app_protect_linux_families:
16-
RedHat:
38+
CentOS:
1739
- 7.4
40+
- 7.5
41+
- 7.6
42+
- 7.7
43+
- 7.8
44+
- 8.0
45+
- 8.1
46+
- 8.2
47+
Debian:
48+
- 9.0
49+
- 9.1
50+
- 9.2
51+
- 9.3
52+
- 9.4
53+
- 9.5
54+
- 9.6
55+
- 9.7
56+
- 9.8
57+
- 9.9
58+
- 9.10
59+
- 9.11
60+
- 9.12
1861

1962
app_protect_security_policy_template_enable: true
2063
app_protect_security_policy_template:
@@ -37,7 +80,7 @@ nginx_conf_template:
3780
# possible values: transparent, blocking
3881
security_policy_enforcement_mode: transparent
3982

40-
# possible values: TBD
83+
# possible values: all, illegal, blocked
4184
log_policy_filter_request_type: all
4285

4386
log_policy_syslog_target: 127.0.0.1:514

handlers/main.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
service:
88
name: nginx
99
state: started
10-
enabled: yes
10+
enabled: true
1111

12-
- name: "(Handler: All OSs) Reload NGINX"
12+
- name: "(Handler: All OSs) Restart NGINX"
1313
service:
1414
name: nginx
15-
state: reloaded
15+
state: restarted
1616

1717
when:
1818
- nginx_start | bool

images/nap-logo.png

6.5 KB
Loading

meta/main.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,14 @@ galaxy_info:
99
min_ansible_version: 2.7
1010

1111
platforms:
12-
- name: EL
12+
- name: CentOS
1313
versions:
14-
- 7.4
14+
- 7
15+
- 8
16+
- name: Debian
17+
versions:
18+
- stretch
19+
- buster
1520

1621
galaxy_tags:
1722
- waf

tasks/configure-app-protect.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,32 @@
99
copy:
1010
src: "{{ nginx_conf_template.out_file_location }}{{ nginx_conf_template.out_file_name }}"
1111
dest: "{{ nginx_conf_template.out_file_location }}{{ nginx_conf_template.out_file_name }}.orig"
12-
remote_src: yes
12+
remote_src: true
1313
when: nginx_conf_template_enable
1414

1515
- name: "Dynamically Generate NGINX App Protect security policy file"
1616
template:
1717
src: "{{ app_protect_security_policy_template.template_file }}"
1818
dest: "{{ app_protect_security_policy_template.out_file_location }}{{ app_protect_security_policy_template.out_file_name }}"
19-
backup: yes
19+
backup: true
2020
when: app_protect_security_policy_template_enable
2121

2222
- name: "Dynamically Generate NGINX App Protect log policy file"
2323
template:
2424
src: "{{ app_protect_log_policy_template.template_file }}"
2525
dest: "{{ app_protect_log_policy_template.out_file_location }}{{ app_protect_log_policy_template.out_file_name }}"
26-
backup: yes
26+
backup: true
2727
when: app_protect_log_policy_template_enable
2828

2929
- name: "Dynamically Generate NGINX conf file"
3030
template:
3131
src: "{{ nginx_conf_template.template_file }}"
3232
dest: "{{ nginx_conf_template.out_file_location }}{{ nginx_conf_template.out_file_name }}"
33-
backup: yes
33+
backup: true
3434
when: nginx_conf_template_enable
3535

3636
- name: "Reload NGINX"
3737
debug:
38-
msg: "trigger nginx reloaded if needed"
39-
notify: "(Handler: All OSs) Reload NGINX"
38+
msg: "trigger nginx reload if needed"
39+
notify: "(Handler: All OSs) Restart NGINX"
4040
changed_when: app_protect_security_policy_template_enable or app_protect_log_policy_template_enable or nginx_conf_template_enable

tasks/delete-license.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
- name: "(Setup: All OSs) Set NGINX App Protect License State"
3+
set_fact:
4+
key_value: "" # appeasing the linter
5+
nginx_license_status: absent
6+
7+
- name: "(Setup: All OSs) Delete NGINX App Protect License"
8+
file:
9+
path: /etc/ssl/nginx
10+
state: absent
11+
when: ansible_distribution != "Alpine"
12+
13+
- import_tasks: setup-debian.yml
14+
when: ansible_os_family == "Debian"
15+
16+
- import_tasks: setup-redhat.yml
17+
when: ansible_os_family == "RedHat"

0 commit comments

Comments
 (0)