File tree Expand file tree Collapse file tree 11 files changed +160
-13
lines changed Expand file tree Collapse file tree 11 files changed +160
-13
lines changed Original file line number Diff line number Diff line change 1
1
---
2
+ # safelist - build only on the following branches
3
+ branches :
4
+ only :
5
+ - main
6
+ - staging
2
7
language : python
3
8
services : docker
4
9
jobs :
@@ -18,6 +23,6 @@ install:
18
23
- pip install molecule==3.0.8
19
24
- pip install docker==4.3.1
20
25
script :
21
- - travis_wait 50 molecule lint -s $scenario
26
+ - molecule test -s $scenario
22
27
notifications :
23
28
webhooks : https://galaxy.ansible.com/api/v1/notifications/
Original file line number Diff line number Diff line change 1
1
# Changelog
2
2
3
+ ## 0.2.2 (September 14, 2020)
4
+
5
+ ENHANCEMENTS:
6
+
7
+ * Added molecule tests and verifications
8
+
9
+ BUG FIXES:
10
+
11
+ * Fixed newly appearing linting issues in role
12
+
13
+ ## 0.2.1 (September 11, 2020)
14
+
15
+ ENHANCEMENTS:
16
+
17
+ * Bring docs up to speed with other NGINX roles
18
+ * Move some default variables into the vars subfolder
19
+
3
20
## 0.2.0 (September 10, 2020)
4
21
5
22
BREAKING CHANGES:
Original file line number Diff line number Diff line change @@ -23,6 +23,14 @@ Instructions on how to install Ansible can be found in the [Ansible website](htt
23
23
24
24
Molecule is used to test the various functionalities of the role. Instructions on how to install Molecule can be found in the [ Molecule website] ( https://molecule.readthedocs.io/en/stable/installation.html ) .
25
25
26
+ To run the Molecule tests, you must first add your NGINX repository certificate and key to the local environment. Run the following commands to export these files as base64-encoded variables and execute the Molecule tests:
27
+
28
+ ``` bash
29
+ export NGINX_CRT=$( cat < path to your certificate file> | base64)
30
+ export NGINX_KEY=$( cat < path to your key file> | base64)
31
+ molecule test
32
+ ```
33
+
26
34
Installation
27
35
------------
28
36
Original file line number Diff line number Diff line change 1
1
---
2
2
- name : Converge
3
- hosts : all
3
+ hosts : nap
4
4
tasks :
5
5
- name : Install NGINX App Protect
6
6
include_role :
15
15
nginx_app_protect_log_policy_template_enable : true
16
16
nginx_app_protect_log_policy_filter_request_type : all
17
17
nginx_app_protect_conf_template_enable : true
18
- nginx_app_protect_log_policy_syslog_target : 10.1.10.105:5144
18
+ nginx_app_protect_log_policy_syslog_target : localhost:514
19
19
nginx_app_protect_demo_workload_protocol : http://
20
- nginx_app_protect_demo_workload_host : 10.1.10.105:8080
20
+ nginx_app_protect_demo_workload_host : test-workload:80
21
21
nginx_app_protect_license :
22
22
certificate : " license/nginx-repo.crt"
23
23
key : " license/nginx-repo.key"
24
- nginx_app_protect_delete_license : false
24
+ nginx_app_protect_delete_license : true
25
+ nginx_app_protect_timeout : 300
Original file line number Diff line number Diff line change @@ -6,26 +6,49 @@ lint: |
6
6
yamllint .
7
7
ansible-lint --force-color
8
8
platforms :
9
+ - name : test-workload
10
+ groups :
11
+ - workload
12
+ image : nginxdemos/hello
13
+ privileged : true
14
+ networks :
15
+ - name : molecule-test
9
16
- name : centos-7
17
+ groups :
18
+ - nap
10
19
image : centos:7
11
20
dockerfile : ../Dockerfile.j2
12
21
privileged : true
22
+ networks :
23
+ - name : molecule-test
13
24
volumes :
14
25
- " /sys/fs/cgroup:/sys/fs/cgroup:rw"
15
26
command : " /usr/sbin/init"
16
27
- name : ubuntu-bionic
28
+ groups :
29
+ - nap
17
30
image : ubuntu:bionic
18
31
dockerfile : ../Dockerfile.j2
19
32
privileged : true
33
+ networks :
34
+ - name : molecule-test
20
35
volumes :
21
36
- " /sys/fs/cgroup:/sys/fs/cgroup:rw"
22
37
command : " /sbin/init"
23
38
- name : debian-stretch
39
+ groups :
40
+ - nap
24
41
image : debian:stretch-slim
25
42
dockerfile : ../Dockerfile.j2
26
43
privileged : true
44
+ networks :
45
+ - name : molecule-test
27
46
volumes :
28
47
- " /sys/fs/cgroup:/sys/fs/cgroup:rw"
29
48
command : " /sbin/init"
30
49
provisioner :
31
50
name : ansible
51
+ config_options :
52
+ defaults :
53
+ no_target_syslog : true
54
+ log : false
Original file line number Diff line number Diff line change
1
+ ---
2
+ - name : Prepare
3
+ hosts : localhost
4
+ connection : local
5
+ gather_facts : false
6
+ vars :
7
+ nginx_license :
8
+ certificate : " ./license/nginx-repo.crt"
9
+ key : " ./license/nginx-repo.key"
10
+
11
+ tasks :
12
+ - name : Create license directory
13
+ file :
14
+ path : " ./license"
15
+ state : directory
16
+ mode : 0755
17
+
18
+ - name : Create ephemeral license certificate file from b64 decoded env var
19
+ copy :
20
+ content : " {{ lookup('env','NGINX_CRT') | b64decode }}"
21
+ dest : " {{ nginx_license.certificate }}"
22
+ mode : 0444
23
+
24
+ - name : Create ephemeral license key file from b64 decoded env var
25
+ copy :
26
+ content : " {{ lookup('env','NGINX_KEY') | b64decode }}"
27
+ dest : " {{ nginx_license.key }}"
28
+ mode : 0444
29
+
30
+ - name : Set up rsyslog server for verifying NAP syslog events
31
+ hosts : nap
32
+ vars :
33
+ rsyslog_receiver : true
34
+ rsyslog_remote_tcp : true
35
+ rsyslog_remote_port : 514
36
+ roles :
37
+ - role : robertdebock.rsyslog
38
+
39
+ - name : Prepare workload for tests
40
+ hosts : workload
41
+ gather_facts : false
42
+ tasks :
43
+ - name : Start nginx on test workload
44
+ raw : nohup nginx </dev/null >/dev/null 2>&1 & sleep 1
45
+ changed_when : false
Original file line number Diff line number Diff line change
1
+ ---
2
+ roles :
3
+ - robertdebock.rsyslog
Original file line number Diff line number Diff line change 1
1
---
2
2
- name : Verify
3
- hosts : all
3
+ hosts : nap
4
4
tasks :
5
5
- name : Check if NGINX is installed
6
6
package :
7
7
name : nginx-plus
8
- check_mode : yes
8
+ check_mode : true
9
+ register : install
10
+ failed_when : (install is changed) or (install is failed)
11
+
12
+ - name : Check if NGINX App Protect is installed
13
+ package :
14
+ name : app-protect
15
+ check_mode : true
16
+ register : install
17
+ failed_when : (install is changed) or (install is failed)
18
+
19
+ - name : Check if NGINX App Protect Signatures is installed
20
+ package :
21
+ name : app-protect-attack-signatures
22
+ check_mode : true
23
+ register : install
24
+ failed_when : (install is changed) or (install is failed)
25
+
26
+ - name : Check if NGINX App Protect Threat Campaigns is installed
27
+ package :
28
+ name : app-protect-threat-campaigns
29
+ check_mode : true
9
30
register : install
10
31
failed_when : (install is changed) or (install is failed)
11
32
12
33
- name : Check if NGINX service is running
13
34
service :
14
35
name : nginx
15
36
state : started
16
- enabled : yes
17
- check_mode : yes
37
+ enabled : true
38
+ check_mode : true
18
39
register : service
19
40
failed_when : (service is changed) or (service is failed)
41
+
42
+ - name : Check that a page returns a status 200 and fail if the words Hello World are not in the page contents
43
+ uri :
44
+ url : " http://localhost"
45
+ return_content : true
46
+ register : this
47
+ failed_when : " 'Hello World' not in this.content"
48
+
49
+ - name : Check that a page returns a status 200 and fail if the words Request Rejected are not in the page contents
50
+ uri :
51
+ url : " http://localhost/?v=<script>"
52
+ return_content : true
53
+ register : this
54
+ failed_when : " 'Request Rejected' not in this.content"
55
+
56
+ - name : Ensure /var/log/messages contains block event from above test
57
+ shell : grep -c "Non-browser Client,Abuse of Functionality,Cross Site Scripting (XSS)" /var/log/messages || true
58
+ register : event
59
+ changed_when : false
60
+ failed_when : event.stdout == "0"
Original file line number Diff line number Diff line change 1
1
---
2
- - name : " Ensure NGINX main directory exists"
2
+ - name : Ensure NGINX main directory exists
3
3
file :
4
4
path : " {{ nginx_app_protect_conf_template.out_file_location }}"
5
5
state : directory
8
8
or nginx_app_protect_log_policy_template_enable | bool
9
9
or nginx_app_protect_conf_template_enable | bool
10
10
11
- - name : " Dynamically generate NGINX App Protect security policy file"
11
+ - name : Dynamically generate NGINX App Protect security policy file
12
12
template :
13
13
src : " {{ nginx_app_protect_security_policy_template.template_file }}"
14
14
dest : " {{ nginx_app_protect_security_policy_template.out_file_location }}{{ nginx_app_protect_security_policy_template.out_file_name }}"
15
15
mode : 0644
16
16
backup : true
17
17
when : nginx_app_protect_security_policy_template_enable | bool
18
18
19
- - name : " Dynamically generate NGINX App Protect log policy file"
19
+ - name : Dynamically generate NGINX App Protect log policy file
20
20
template :
21
21
src : " {{ nginx_app_protect_log_policy_template.template_file }}"
22
22
dest : " {{ nginx_app_protect_log_policy_template.out_file_location }}{{ nginx_app_protect_log_policy_template.out_file_name }}"
49
49
path : /etc/nginx/nginx.conf
50
50
regexp : ' ^([ \t]*load_module.*ngx_http_app_protect_module.so;)'
51
51
replace : ' # \1'
52
+ mode : preserve
52
53
53
54
- name : Comment out NGINX App Protect directives in nginx.conf
54
55
replace :
55
56
path : /etc/nginx/nginx.conf
56
57
regexp : ' ^([ \t]*app_protect_)'
57
58
replace : ' # \1'
59
+ mode : preserve
58
60
when : nginx_app_protect_state == "absent"
59
61
60
62
- name : Reload NGINX
Original file line number Diff line number Diff line change 3
3
apt_repository :
4
4
repo : deb [arch=amd64] https://plus-pkgs.nginx.com/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} nginx-plus
5
5
filename : nginx-app-protect
6
+ mode : 0644
6
7
update_cache : false
7
8
state : " {{ nginx_app_protect_license_status | default ('present') }}"
8
9
9
10
- name : Setup Debian and Ubuntu NGINX App Protect security updates repository
10
11
apt_repository :
11
12
repo : deb [arch=amd64] https://app-protect-security-updates.nginx.com/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} nginx-plus
12
13
filename : app-protect-security-updates
14
+ mode : 0644
13
15
update_cache : false
14
16
state : " {{ nginx_app_protect_license_status | default ('present') }}"
15
17
You can’t perform that action at this time.
0 commit comments