Skip to content

Commit 1cabf77

Browse files
authored
Merge pull request #18 from alessfg/parity-tweaks
Add molecule tests
2 parents 46f9e01 + 068bf27 commit 1cabf77

Some content is hidden

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

48 files changed

+625
-708
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'

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To reproduce**
14+
Steps to reproduce the behavior:
15+
1. Deploy NGINX Config role using playbook.yml
16+
2. View output/logs/configuration on '...'
17+
3. See error
18+
19+
**Expected behavior**
20+
A clear and concise description of what you expected to happen.
21+
22+
**Your environment:**
23+
- Version of the NGINX Config Role or specific commit
24+
- Version of Ansible
25+
- Target deployment platform
26+
27+
**Additional context**
28+
Add any other context about the problem here.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.
15+
16+
**Describe alternatives you've considered**
17+
A clear and concise description of any alternative solutions or features you've considered.
18+
19+
**Additional context**
20+
Add any other context or screenshots about the feature request here.

.github/pull_request_template.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
### Proposed changes
2+
Describe the use case and detail of the change. If this PR addresses an issue on GitHub, make sure to include a link to that issue using one of the [supported keywords](https://docs.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue) here in this description (not in the title of the PR).
3+
4+
### Checklist
5+
Before creating a PR, run through this checklist and mark each as complete.
6+
7+
- [ ] I have read the [CONTRIBUTING](https://github.com/nginxinc/ansible-role-nginx-app-protect/blob/main/CONTRIBUTING.md) document
8+
- [ ] I have added Molecule tests that prove my fix is effective or that my feature works
9+
- [ ] I have checked that all Molecule tests pass after adding my changes
10+
- [ ] I have updated any relevant documentation (`defaults/main/*.yml`, `README.md` and `CHANGELOG.md`)

.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 & 107 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,144 +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
44+
- 7.4+
5045
RHEL:
51-
versions:
52-
- 7.4
53-
- 7.5
54-
- 7.6
55-
- 7.7
56-
- 7.8
46+
- 7.4+
5747
Debian:
58-
versions:
59-
- 9.0
60-
- 9.1
61-
- 9.2
62-
- 9.3
63-
- 9.4
64-
- 9.5
65-
- 9.6
66-
- 9.7
67-
- 9.8
68-
- 9.9
69-
- 9.10
70-
- 9.11
71-
- 9.12
72-
- 9.13
48+
- 9
7349
Ubuntu:
74-
versions:
75-
- 18.04
50+
- 18.04
7651
```
7752
7853
Role Variables
7954
--------------
8055
81-
This role has multiple variables. The descriptions and defaults for all these variables can be found in the **[defaults/main.yml](./defaults/main.yml)`**.
82-
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)**.
8357
8458
Dependencies
8559
------------
8660
87-
- 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.
8862

89-
- 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.
9064

91-
- 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.
9266

9367
Example Playbook
9468
----------------
9569

96-
9770
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.
9871

9972
A copy of this is in the sample-playbook directory in this repo.
10073

10174
First create a file for all the variables as `nginx-app-protect-vars.yml`
75+
10276
```yaml
10377
---
104-
105-
# Specify whether you want to maintain your version of NGINX App Protect, upgrade to the latest version, or remove NGINX App Protect.
106-
# 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.
107-
# Using 'present' will install the latest version (or 'app_protect_version') of NGINX App Protect on a fresh install.
108-
# 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.
109-
# Using 'absent' will remove NGINX App Protect from your system.
110-
# Default is present.
111-
app_protect_state: present
112-
113-
# OPTIONAL: Installs a specific version of NGINX App Protect
114-
app_protect_version: 22
115-
116-
# The installation of NGINX App Protect includes a base signature set, which may be out of date.
117-
# This option installs the latest NGINX App Protect signatures.
118-
app_protect_install_signatures: true
119-
120-
# The installation of NGINX App Protect can include a page of frequently-updated, high-accuracy signatures called Threat Campaigns.
121-
# This option installs the latest NGINX App Protect Threat Campaigns signatures.
122-
app_protect_install_threat_campaigns: true
123-
124-
# Creates basic configuration files and enables NGINX App Protect on the target host
125-
app_protect_configure: true
126-
127-
# Removes the license (certificate and key) for the NGINX App Protect repositories on the target host(s) when playbook run is complete.
128-
app_protect_delete_license: true
129-
130-
# If you have a RHEL subscription, NGINX App Protect's dependencies will use subscription repos.
131-
# Otherwise, it will source packages from CentOS' repositories.
132-
app_protect_use_rhel_subscription_repos: false
133-
134-
# For use with the app_protect_configure option to determine if the default security policy will be written to the target host
135-
# Used when `app_protect_configure: true`.
136-
app_protect_security_policy_template_enable: true
137-
138-
# Default app protect enforcement mode. Values can be `blocking` or `transparent`.
139-
# Used when `app_protect_configure: true` and `app_protect_security_policy_template_enable: true`.
140-
security_policy_enforcement_mode: blocking
141-
142-
# For use with the app_protect_configure option to determine if the default log policy will be written to the target host.
143-
# Used when `app_protect_configure: true`.
144-
app_protect_log_policy_template_enable: true
145-
146-
# Which violation types to log. Possible values: all, illegal, blocked
147-
# Used when `app_protect_configure: true` and `app_protect_log_policy_template_enable: true`.
148-
log_policy_filter_request_type: all
149-
150-
# For use with the app_protect_configure option to determine if the sample nginx.conf will be written to the target host.
151-
# Since this can be dangerous, this value is default to false in the role defaults.
152-
# Used when `app_protect_configure: true`.
153-
nginx_conf_template_enable: true
154-
155-
# For use with the app_protect_configure option to determine the syslog target to be injected
156-
# into the default log policy that will be written to the target host.
157-
# Used when `nginx_conf_template_enable: true`.
158-
log_policy_syslog_target: 10.1.1.8:5144
159-
160-
# DEPRECATED: A proxy pass workload used in the sample nginx.conf for demo purposes.
161-
# Will be removed from this role in the future.
162-
# Used when `nginx_conf_template_enable: true`.
163-
nginx_demo_workload: http://10.1.10.105:8080
164-
165-
# The location of the certificate and key to be used when downloading the packages onto the host
166-
nginx_license:
167-
certificate: "{{playbook_dir}}/license/nginx-repo.crt"
168-
key: "{{playbook_dir}}/license/nginx-repo.key"
169-
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"
170142
```
171143
172144
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.
173145
174146
```yaml
175147
---
176148
- hosts: wafs
177-
remote_user: centos
149+
remote_user: centos
178150
pre_tasks:
179151
- name: load the vars
180-
include_vars:
181-
file: "{{playbook_dir}}/nginx-app-protect-vars.yml"
152+
include_vars:
153+
file: "{{ playbook_dir }}/nginx-app-protect-vars.yml"
182154
roles:
183155
- nginxinc.nginx_app_protect
184156
```
@@ -196,7 +168,7 @@ You can find an Ansible collection of roles to help you install and configure NG
196168
License
197169
-------
198170

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

201173
Author Information
202174
------------------

0 commit comments

Comments
 (0)