Skip to content

Commit 2b9364c

Browse files
committed
Keep working on tests
And refactor all the things
1 parent 3bda56c commit 2b9364c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+556
-709
lines changed

.ansible-lint

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
skip_list:
2+
- '106'

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,3 @@ default.pem
3636

3737
# Scratch Directory
3838
scratch/
39-
40-
# nginx keys
41-
sample-playbook/license/nginx-repo.*

.travis.yml

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,23 @@
11
---
22
language: python
3-
python: "2.7"
4-
5-
# Use the new container infrastructure
6-
sudo: false
7-
8-
# Install ansible
9-
addons:
10-
apt:
11-
packages:
12-
- python-pip
13-
3+
services: docker
4+
jobs:
5+
include:
6+
- name: "Lint role"
7+
env:
8+
scenario: default
9+
before_install:
10+
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
11+
- sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
12+
- sudo apt-get update
13+
- sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce
1414
install:
15-
# Install ansible
16-
- pip install ansible
17-
18-
# Check ansible version
19-
- ansible --version
20-
21-
# Create ansible.cfg with correct roles_path
22-
- printf '[defaults]\nroles_path=../' >ansible.cfg
23-
15+
- pip install ansible==2.9.13
16+
- pip install ansible-lint==4.3.4
17+
- pip install yamllint==1.24.2
18+
- pip install molecule==3.0.8
19+
- pip install docker==4.3.1
2420
script:
25-
# Basic role syntax check
26-
- ansible-playbook tests/test.yml -i tests/inventory --syntax-check
27-
21+
- travis_wait 50 molecule lint -s $scenario
2822
notifications:
29-
webhooks: https://galaxy.ansible.com/api/v1/notifications/
23+
webhooks: https://galaxy.ansible.com/api/v1/notifications/

.yamllint

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
---
2-
# Based on ansible-lint config
32
extends: default
43

54
rules:
@@ -9,25 +8,6 @@ rules:
98
brackets:
109
max-spaces-inside: 1
1110
level: error
12-
colons:
13-
max-spaces-after: -1
14-
level: error
15-
commas:
16-
max-spaces-after: -1
17-
level: error
18-
comments: disable
1911
comments-indentation: disable
20-
document-start: disable
21-
empty-lines:
22-
max: 3
23-
level: error
24-
hyphens:
25-
level: error
26-
indentation: disable
27-
key-duplicates: enable
2812
line-length: disable
29-
new-line-at-end-of-file: disable
30-
new-lines:
31-
type: unix
32-
trailing-spaces: disable
3313
truthy: disable

README.md

Lines changed: 79 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
NGINX App Protect Ansible Role
44
==============================
55

6-
<!-- [![Ansible Galaxy](https://img.shields.io/badge/galaxy-nginxinc.nginx-5bbdbf.svg)](https://galaxy.ansible.com/nginxinc/nginx) -->
7-
<!-- [![Build Status](https://travis-ci.org/nginxinc/ansible-role-nginx-app-protect.svg?branch=master)](https://travis-ci.org/nginxinc/ansible-role-nginx-app-protect) -->
6+
[![Ansible Galaxy](https://img.shields.io/badge/galaxy-nginxinc.nginx-5bbdbf.svg)](https://galaxy.ansible.com/nginxinc/nginx_app_protect)
7+
[![Build Status](https://travis-ci.org/nginxinc/ansible-role-nginx-app-protect.svg?branch=main)](https://travis-ci.org/nginxinc/ansible-role-nginx-app-protect)
88

99
This role installs and configures NGINX App Protect (WAF) for NGINX Plus on your target host.
1010

@@ -41,149 +41,116 @@ The NGINX App Protect Ansible role supports all platforms supported by [NGINX Pl
4141

4242
```yaml
4343
CentOS:
44-
versions:
45-
- 7.4
46-
- 7.5
47-
- 7.6
48-
- 7.7
49-
- 7.8
50-
- 8.0
51-
- 8.1
52-
- 8.2
44+
- 7.4+
5345
RHEL:
54-
versions:
55-
- 7.4
56-
- 7.5
57-
- 7.6
58-
- 7.7
59-
- 7.8
60-
- 8.0
61-
- 8.1
62-
- 8.2
46+
- 7.4+
6347
Debian:
64-
versions:
65-
- 9.0
66-
- 9.1
67-
- 9.2
68-
- 9.3
69-
- 9.4
70-
- 9.5
71-
- 9.6
72-
- 9.7
73-
- 9.8
74-
- 9.9
75-
- 9.10
76-
- 9.11
77-
- 9.12
48+
- 9
7849
Ubuntu:
79-
versions:
80-
- 18.04
50+
- 18.04
8151
```
8252
8353
Role Variables
8454
--------------
8555
86-
This role has multiple variables. The descriptions and defaults for all these variables can be found in the **[defaults/main.yml](./defaults/main.yml)`**.
87-
56+
This role has multiple variables. The descriptions and defaults for all these variables can be found in the **[defaults/main.yml](https://github.com/nginxinc/ansible-role-nginx-app-protect/blob/main/defaults/main.yml)**.
8857
8958
Dependencies
9059
------------
9160
92-
- 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.
61+
- 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.
9362

94-
- If NGINX+ is *not* already installed on the system, this role will install the version of NGINX+ that is dependent on the version of NGINX App Protect set with the `app_protect_version` variable. If none is specified, the latest version of NGINX+ and NGINX App Protect will be installed.
63+
- If NGINX Plus is *not* already installed on the system, this role will install the version of NGINX Plus that is dependent on the version of NGINX App Protect set with the `nginx_app_protect_version` variable. If none is specified, the latest version of NGINX Plus and NGINX App Protect will be installed.
9564

96-
- When using the `app_protect_version` variable, a specific version of NGINX+ must already be installed on the target system.
65+
- When using the `nginx_app_protect_version` variable, a specific version of NGINX Plus must already be installed on the target system.
9766

9867
Example Playbook
9968
----------------
10069

101-
10270
This is a sample playbook file for using the role to install NGINX App Protect on NGINX Plus and configure it using basic settings to all `wafs` inventory hosts.
10371

10472
A copy of this is in the sample-playbook directory in this repo.
10573

10674
First create a file for all the variables as `nginx-app-protect-vars.yml`
75+
10776
```yaml
10877
---
109-
110-
# Specify whether you want to maintain your version of NGINX App Protect, upgrade to the latest version, or remove NGINX App Protect.
111-
# 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.
112-
# Using 'present' will install the latest version (or 'app_protect_version') of NGINX App Protect on a fresh install.
113-
# 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.
114-
# Using 'absent' will remove NGINX App Protect from your system.
115-
# Default is present.
116-
app_protect_state: present
117-
118-
# OPTIONAL: Installs a specific version of NGINX App Protect
119-
app_protect_version: 22
120-
121-
# The installation of NGINX App Protect includes a base signature set, which may be out of date.
122-
# This option installs the latest NGINX App Protect signatures.
123-
app_protect_install_signatures: true
124-
125-
# The installation of NGINX App Protect can include a page of frequently-updated, high-accuracy signatures called Threat Campaigns.
126-
# This option installs the latest NGINX App Protect Threat Campaigns signatures.
127-
app_protect_install_threat_campaigns: true
128-
129-
# Creates basic configuration files and enables NGINX App Protect on the target host
130-
app_protect_configure: true
131-
132-
# Removes the license (certificate and key) for the NGINX App Protect repositories on the target host(s) when playbook run is complete.
133-
app_protect_delete_license: true
134-
135-
# If you have a RHEL subscription, NGINX App Protect's dependencies will use subscription repos.
136-
# Otherwise, it will source packages from CentOS' repositories.
137-
app_protect_use_rhel_subscription_repos: false
138-
139-
# For use with the app_protect_configure option to determine if the default security policy will be written to the target host
140-
# Used when `app_protect_configure: true`.
141-
app_protect_security_policy_template_enable: true
142-
143-
# Default app protect enforcement mode. Values can be `blocking` or `transparent`.
144-
# Used when `app_protect_configure: true` and `app_protect_security_policy_template_enable: true`.
145-
security_policy_enforcement_mode: blocking
146-
147-
# For use with the app_protect_configure option to determine if the default log policy will be written to the target host.
148-
# Used when `app_protect_configure: true`.
149-
app_protect_log_policy_template_enable: true
150-
151-
# Which violation types to log. Possible values: all, illegal, blocked
152-
# Used when `app_protect_configure: true` and `app_protect_log_policy_template_enable: true`.
153-
log_policy_filter_request_type: all
154-
155-
# For use with the app_protect_configure option to determine if the sample nginx.conf will be written to the target host.
156-
# Since this can be dangerous, this value is default to false in the role defaults.
157-
# Used when `app_protect_configure: true`.
158-
nginx_conf_template_enable: true
159-
160-
# For use with the app_protect_configure option to determine the syslog target to be injected
161-
# into the default log policy that will be written to the target host.
162-
# Used when `nginx_conf_template_enable: true`.
163-
log_policy_syslog_target: 10.1.1.8:5144
164-
165-
# DEPRECATED: A proxy pass workload used in the sample nginx.conf for demo purposes.
166-
# Will be removed from this role in the future.
167-
# Used when `nginx_conf_template_enable: true`.
168-
nginx_demo_workload: http://10.1.10.105:8080
169-
170-
# The location of the certificate and key to be used when downloading the packages onto the host
171-
nginx_license:
172-
certificate: "{{playbook_dir}}/license/nginx-repo.crt"
173-
key: "{{playbook_dir}}/license/nginx-repo.key"
174-
78+
# Specify whether you want to maintain your version of NGINX App Protect, upgrade to the latest version, or remove NGINX App Protect.
79+
# Can be used with `nginx_app_protect_version` to achieve fine grained control on which version of NGINX App Protect is installed/used on each playbook execution.
80+
# Using 'present' will install the latest version (or 'nginx_app_protect_version') of NGINX App Protect on a fresh install.
81+
# Using 'latest' will upgrade NGINX App Protect to the latest version (that matches your 'nginx_app_protect_version') of NGINX App Protect on every playbook execution.
82+
# Using 'absent' will remove NGINX App Protect from your system.
83+
# Default is present.
84+
nginx_app_protect_state: present
85+
86+
# OPTIONAL: Installs a specific version of NGINX App Protect
87+
nginx_app_protect_version: 22
88+
89+
# The installation of NGINX App Protect includes a base signature set, which may be out of date.
90+
# This option installs the latest NGINX App Protect signatures.
91+
nginx_app_protect_install_signatures: true
92+
93+
# The installation of NGINX App Protect can include a page of frequently-updated, high-accuracy signatures called Threat Campaigns.
94+
# This option installs the latest NGINX App Protect Threat Campaigns signatures.
95+
nginx_app_protect_install_threat_campaigns: true
96+
97+
# Creates basic configuration files and enables NGINX App Protect on the target host
98+
nginx_app_protect_configure: true
99+
100+
# Removes the license (certificate and key) for the NGINX App Protect repositories on the target host(s) when playbook run is complete.
101+
nginx_app_protect_delete_license: true
102+
103+
# If you have a RHEL subscription, NGINX App Protect's dependencies will use subscription repos.
104+
# Otherwise, it will source packages from CentOS' repositories.
105+
nginx_app_protect_use_rhel_subscription_repos: false
106+
107+
# For use with the nginx_app_protect_configure option to determine if the default security policy will be written to the target host
108+
# Used when `nginx_app_protect_configure: true`.
109+
nginx_app_protect_security_policy_template_enable: true
110+
111+
# Default app protect enforcement mode. Values can be `blocking` or `transparent`.
112+
# Used when `nginx_app_protect_configure: true` and `nginx_app_protect_security_policy_template_enable: true`.
113+
nginx_app_protect_security_policy_enforcement_mode: blocking
114+
115+
# For use with the nginx_app_protect_configure option to determine if the default log policy will be written to the target host.
116+
# Used when `nginx_app_protect_configure: true`.
117+
nginx_app_protect_log_policy_template_enable: true
118+
119+
# Which violation types to log. Possible values: all, illegal, blocked
120+
# Used when `nginx_app_protect_configure: true` and `nginx_app_protect_log_policy_template_enable: true`.
121+
nginx_app_protect_log_policy_filter_request_type: all
122+
123+
# For use with the nginx_app_protect_configure option to determine if the sample nginx.conf will be written to the target host.
124+
# Since this can be dangerous, this value is default to false in the role defaults.
125+
# Used when `nginx_app_protect_configure: true`.
126+
nginx_app_protect_conf_template_enable: true
127+
128+
# For use with the nginx_app_protect_configure option to determine the syslog target to be injected
129+
# into the default log policy that will be written to the target host.
130+
# Used when `nginx_app_protect_conf_template_enable: true`.
131+
nginx_app_protect_log_policy_syslog_target: 10.1.1.8:5144
132+
133+
# DEPRECATED: A proxy pass workload used in the sample nginx.conf for demo purposes.
134+
# Will be removed from this role in the future.
135+
# Used when `nginx_app_protect_conf_template_enable: true`.
136+
nginx_app_protect_demo_workload: http://10.1.10.105:8080
137+
138+
# The location of the certificate and key to be used when downloading the packages onto the host.
139+
nginx_app_protect_license:
140+
certificate: "{{ playbook_dir }}/license/nginx-repo.crt"
141+
key: "{{ playbook_dir }}/license/nginx-repo.crt"
175142
```
176143
177144
This is a sample playbook file for deploying the Ansible Galaxy NGINX App Protect role in a localhost and installing NGINX App Protect on NGINX Plus.
178145
179146
```yaml
180147
---
181148
- hosts: wafs
182-
remote_user: centos
149+
remote_user: centos
183150
pre_tasks:
184151
- name: load the vars
185-
include_vars:
186-
file: "{{playbook_dir}}/nginx-app-protect-vars.yml"
152+
include_vars:
153+
file: "{{ playbook_dir }}/nginx-app-protect-vars.yml"
187154
roles:
188155
- nginxinc.nginx_app_protect
189156
```
@@ -201,7 +168,7 @@ You can find an Ansible collection of roles to help you install and configure NG
201168
License
202169
-------
203170

204-
[Apache License, Version 2.0](LICENSE)
171+
[Apache License, Version 2.0](https://github.com/nginxinc/ansible-role-nginx-app-protect/blob/master/LICENSE)
205172

206173
Author Information
207174
------------------

0 commit comments

Comments
 (0)