Skip to content

Commit 9a59211

Browse files
authored
Merge pull request #20 from alessfg/improve-docs-and-use-vars
Bring docs up to speed with other NGINX roles
2 parents 8349d87 + 6df902c commit 9a59211

File tree

8 files changed

+107
-160
lines changed

8 files changed

+107
-160
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ A clear and concise description of what the bug is.
1212

1313
**To reproduce**
1414
Steps to reproduce the behavior:
15-
1. Deploy NGINX Config role using playbook.yml
15+
1. Deploy NGINX App Protect role using playbook.yml
1616
2. View output/logs/configuration on '...'
1717
3. See error
1818

1919
**Expected behavior**
2020
A clear and concise description of what you expected to happen.
2121

2222
**Your environment:**
23-
- Version of the NGINX Config Role or specific commit
23+
- Version of the NGINX App Protect role or specific commit
2424
- Version of Ansible
2525
- Target deployment platform
2626

.github/pull_request_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ Before creating a PR, run through this checklist and mark each as complete.
77
- [ ] I have read the [CONTRIBUTING](https://github.com/nginxinc/ansible-role-nginx-app-protect/blob/main/CONTRIBUTING.md) document
88
- [ ] I have added Molecule tests that prove my fix is effective or that my feature works
99
- [ ] I have checked that all Molecule tests pass after adding my changes
10-
- [ ] I have updated any relevant documentation (`defaults/main/*.yml` and `README.md`)
10+
- [ ] I have updated any relevant documentation (`defaults/main.yml`, `README.md` and `CHANGELOG.md`)

CHANGELOG.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Changelog
2+
3+
## 0.2.0 (September 10, 2020)
4+
5+
BREAKING CHANGES:
6+
7+
* All of the variables have been updated to prevent naming collisions when using other roles. Please see README.MD for new variable names.
8+
* Example playbook has been removed by collection authors in favor of using the Molecule configuration as a 'known-working' implementation.
9+
10+
ENHANCEMENTS:
11+
12+
* Huge refactoring by @alessfg to better unify this role with the structures present in the other nginxinc Ansible roles.
13+
* Update Ansible to 2.9.13 and Ansible Lint to 4.3.4.
14+
* Explicitly defined mode in relevant tasks for breaking changes in Ansible.
15+
* Role refactored to separate install and configure operations in preparation for an upcoming role split.
16+
17+
FEATURES:
18+
19+
* Molecule 3 testing foundation is in the project, and linting is being performed by TravisCI. Now time to write tests!
20+
21+
BUG FIXES:
22+
23+
* The CentOS, RHEL, Debian and Ubuntu repositories have slightly changed to respond to a NAP repository deprecation activity. You may run into some duplication issues when running the role on a preexisting target that already has had NGINX installed using the role. To fix this, manually remove the old repository source.
24+
* The RHEL and CentOS repository setups were incorrectly using a static gpgkey instead of using the variable as a source.
25+
26+
## 0.1.0 (September 9, 2020)
27+
28+
Supports App Protect 2.0, which brings a number of features including support for Ubuntu 18.04.
29+
30+
Release notes for NGINX App Protect 2.0: docs.nginx.com/nginx-app-protect/releases/#release-2-0

CONTRIBUTING.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,25 @@ The following is a set of guidelines for contributing to the NGINX App Protect A
1414
* [Git Guidelines](#git-guidelines)
1515
* [Ansible Guidelines](#ansible-guidelines)
1616

17-
[Code of Conduct](CODE_OF_CONDUCT.md)
17+
[Code of Conduct](https://github.com/nginxinc/ansible-role-nginx-app-protect/blob/main/CODE_OF_CONDUCT.md)
1818

1919
## Ask a Question
2020

21-
Please open an Issue on GitHub with the label `question`.
21+
Don't know how something works? Curious if the role can achieve your desired functionality? Please open an Issue on GitHub with the label `question`.
2222

2323
## Getting Started
2424

25-
Follow our [Installation Guide](README.md#Installation) to install Ansible and Molecule and get ready to use the NGINX App Protect Ansible role.
25+
Follow our [Installation Guide](https://github.com/nginxinc/ansible-role-nginx-app-protect/blob/main/README.md#Installation) to install Ansible and Molecule and get ready to use the NGINX Ansible role.
2626

2727
### Project Structure
2828

29-
* The NGINX App Protect Ansible role is written in `yaml` and supports open source NGINX Plus.
29+
* The NGINX Ansible role is written in `yaml` and supports NGINX App Protect.
3030
* The project follows the standard [Ansible role directory structure](https://docs.ansible.com/ansible/latest/user_guide/playbooks_reuse_roles.html)
31-
* The main code is found at `tasks/`
32-
* The main variables can be found at `defaults/main/`
33-
* Configuration templates for NGINX can be found at `templates/`
31+
* The main code is found in `tasks/`
32+
* The main variables can be found in `defaults/main.yml`
33+
* Configuration templates for NGINX Plus and NGINX App Protect can be found in `templates/`
3434
* [Molecule](https://molecule.readthedocs.io/) tests can be found in `molecule/`.
35-
* CI/CD is done via Travis using `.travis.yml` Deployment yaml files, and Helm files are found at `deployments/`
35+
* CI/CD is done via Travis using `.travis.yml` deployment yaml files
3636

3737
## Contributing
3838

@@ -46,27 +46,27 @@ To suggest an enhancement, please create an issue on GitHub with the label `enha
4646

4747
### Open a Pull Request
4848

49-
* Fork the repo, create a branch, submit a PR when your changes are tested and ready for review
50-
* Fill in [our pull request template](https://github.com/nginxinc/ansible-role-nginx-app-protect/blob/master/.github/PULL_REQUEST_TEMPLATE.md)
49+
* Fork the repo, create a branch, submit a PR when your changes are **tested** (ideally using Molecule) and ready for review
50+
* Fill in [our pull request template](https://github.com/nginxinc/ansible-role-nginx-app-protect/blob/main/.github/PULL_REQUEST_TEMPLATE.md)
5151

5252
Note: if you’d like to implement a new feature, please consider creating a feature request issue first to start a discussion about the feature.
5353

5454
## Code Guidelines
5555

56+
### Ansible Guidelines
57+
58+
* Run `molecule lint` over your code to automatically resolve a lot of `yaml` and Ansible style issues.
59+
* Run `molecule test --all` on your code before you submit a PR to catch any potential issues.
60+
* Follow these guides on some good practices for Ansible:
61+
* <https://www.ansible.com/blog/ansible-best-practices-essentials>
62+
* <https://docs.ansible.com/ansible/latest/user_guide/playbooks_best_practices.html>
63+
5664
### Git Guidelines
5765

5866
* Keep a clean, concise and meaningful git commit history on your branch (within reason), rebasing locally and squashing before submitting a PR
59-
* Follow the guidelines of writing a good commit message as described here <https://chris.beams.io/posts/git-commit/> and summarized in the next few points
67+
* Follow the guidelines of writing a good commit message as described here <https://chris.beams.io/posts/git-commit/> and summarised in the next few points
6068
* In the subject line, use the present tense ("Add feature" not "Added feature")
6169
* In the subject line, use the imperative mood ("Move cursor to..." not "Moves cursor to...")
6270
* Limit the subject line to 72 characters or less
6371
* Reference issues and pull requests liberally after the subject line
6472
* Add more detailed description in the body of the git message (`git commit -a` to give you more space and time in your text editor to write a good message instead of `git commit -am`)
65-
66-
### Ansible Guidelines
67-
68-
* Run `molecule lint` over your code to automatically resolve a lot of `yaml` and Ansible style issues.
69-
* Run `molecule test --all` on your code to catch any other issues.
70-
* Follow these guides on some good practices for Ansible:
71-
* <https://www.ansible.com/blog/ansible-best-practices-essentials>
72-
* <https://docs.ansible.com/ansible/latest/user_guide/playbooks_best_practices.html>

README.md

Lines changed: 18 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,13 @@ Ubuntu:
5353
Role Variables
5454
--------------
5555
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)**.
56+
This role has multiple variables. The descriptions and defaults for all these variables can be found in the **`defaults`** directory in the following files:
57+
58+
- **[defaults/main.yml](https://github.com/nginxinc/ansible-role-nginx-app-protect/blob/main/defaults/main.yml)**: NGINX App Protect installation and configuration variables
59+
60+
Similarly, descriptions and defaults for preset variables can be found in the **`vars`** directory in the following files:
61+
62+
- **[vars/main.yml](https://github.com/nginxinc/ansible-role-nginx-app-protect/blob/main/vars/main.yml):** List of supported NGINX App Protect platforms
5763

5864
Dependencies
5965
------------
@@ -67,119 +73,31 @@ Dependencies
6773
Example Playbook
6874
----------------
6975

70-
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.
71-
72-
A copy of this is in the sample-playbook directory in this repo.
73-
74-
First create a file for all the variables as `nginx-app-protect-vars.yml`
75-
76-
```yaml
77-
---
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-
# OPTIONAL: Choose where to fetch the NGINX App Protect and Security Updates signing keys from.
108-
# Default settings are the official NGINX signing key hosts.
109-
nginx_app_protect_signing_keys:
110-
nginx_plus: https://cs.nginx.com/static/keys/nginx_signing.key
111-
app_protect: https://cs.nginx.com/static/keys/app-protect.key
112-
security_updates: https://cs.nginx.com/static/keys/app-protect-security-updates.key
113-
114-
# For use with the nginx_app_protect_configure option to determine if the default security policy will be written to the target host
115-
# Used when `nginx_app_protect_configure: true`.
116-
nginx_app_protect_security_policy_template_enable: true
117-
118-
# Default app protect enforcement mode. Values can be `blocking` or `transparent`.
119-
# Used when `nginx_app_protect_configure: true` and `nginx_app_protect_security_policy_template_enable: true`.
120-
nginx_app_protect_security_policy_enforcement_mode: blocking
121-
122-
# For use with the nginx_app_protect_configure option to determine if the default log policy will be written to the target host.
123-
# Used when `nginx_app_protect_configure: true`.
124-
nginx_app_protect_log_policy_template_enable: true
125-
126-
# Which violation types to log. Possible values: all, illegal, blocked
127-
# Used when `nginx_app_protect_configure: true` and `nginx_app_protect_log_policy_template_enable: true`.
128-
nginx_app_protect_log_policy_filter_request_type: all
129-
130-
# For use with the nginx_app_protect_configure option to determine if the sample nginx.conf will be written to the target host.
131-
# Since this can be dangerous, this value is default to false in the role defaults.
132-
# Used when `nginx_app_protect_configure: true`.
133-
nginx_app_protect_conf_template_enable: true
134-
135-
# For use with the nginx_app_protect_configure option to determine the syslog target to be injected
136-
# into the default log policy that will be written to the target host.
137-
# Used when `nginx_app_protect_conf_template_enable: true`.
138-
nginx_app_protect_log_policy_syslog_target: 10.1.1.8:5144
139-
140-
# DEPRECATED: A proxy pass workload used in the sample nginx.conf for demo purposes.
141-
# Will be removed from this role in the future.
142-
# Used when `nginx_app_protect_conf_template_enable: true`.
143-
nginx_app_protect_demo_workload: http://10.1.10.105:8080
144-
145-
# The location of the certificate and key to be used when downloading the packages onto the host.
146-
nginx_app_protect_license:
147-
certificate: "{{ playbook_dir }}/license/nginx-repo.crt"
148-
key: "{{ playbook_dir }}/license/nginx-repo.crt"
149-
```
150-
151-
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.
76+
A working functional playbook example can be found in the **`molecule/default`** directory in the following file:
15277

153-
```yaml
154-
---
155-
- hosts: wafs
156-
remote_user: centos
157-
pre_tasks:
158-
- name: load the vars
159-
include_vars:
160-
file: "{{ playbook_dir }}/nginx-app-protect-vars.yml"
161-
roles:
162-
- nginxinc.nginx_app_protect
163-
```
164-
165-
166-
To run any of the above sample playbooks create a `nginx-app-protect-playbook.yml` file and paste the contents. Executing the Ansible Playbook is then as simple as executing `ansible-playbook nginx-app-protect-playbook.yml -b -i inventory`.
167-
168-
Alternatively, you can also clone this repository instead of installing it from Ansible Galaxy. If you decide to do so, replace the role variable in the previous sample playbooks from `nginxinc.nginx_app_protect` to `ansible-role-nginx-app-protect`.
78+
- **[molecule/default/converge.yml](https://github.com/nginxinc/ansible-role-nginx-app_protect/blob/main/molecule/default/converge.yml):** Install and configure NGINX App Protect
16979

17080
Other NGINX Roles
17181
-----------------
17282

83+
You can find an Ansible role to install NGINX [here](https://github.com/nginxinc/ansible-role-nginx)
84+
85+
You can find an Ansible role to configure NGINX [here](https://github.com/nginxinc/ansible-role-nginx-config)
86+
17387
You can find an Ansible collection of roles to help you install and configure NGINX Controller [here](https://github.com/nginxinc/ansible-collection-nginx_controller)
17488

89+
You can find an Ansible role to install NGINX Unit [here](https://github.com/nginxinc/ansible-role-nginx-unit)
90+
17591
License
17692
-------
17793

178-
[Apache License, Version 2.0](https://github.com/nginxinc/ansible-role-nginx-app-protect/blob/master/LICENSE)
94+
[Apache License, Version 2.0](https://github.com/nginxinc/ansible-role-nginx-app-protect/blob/main/LICENSE)
17995

18096
Author Information
18197
------------------
18298

18399
[Daniel Edgar](https://github.com/aknot242)
184100

101+
[Alessandro Fael Garcia](https://github.com/alessfg)
102+
185103
&copy; [F5 Networks, Inc.](https://www.f5.com/) 2020

defaults/main.yml

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -45,38 +45,6 @@ nginx_app_protect_timeout: 180
4545
# App Protect Temporary Directory to use (Default: /tmp)
4646
nginx_app_protect_tempdir: /tmp
4747

48-
# populate this dictionary of lists with appropriate values from the ansible_distribution and ansible_distribution_version facts
49-
nginx_app_protect_linux_families:
50-
CentOS:
51-
- 7.4
52-
- 7.5
53-
- 7.6
54-
- 7.7
55-
- 7.8
56-
RedHat:
57-
- 7.4
58-
- 7.5
59-
- 7.6
60-
- 7.7
61-
- 7.8
62-
Debian:
63-
- 9.0
64-
- 9.1
65-
- 9.2
66-
- 9.3
67-
- 9.4
68-
- 9.5
69-
- 9.6
70-
- 9.7
71-
- 9.8
72-
- 9.9
73-
- 9.10
74-
- 9.11
75-
- 9.12
76-
- 9.13
77-
Ubuntu:
78-
- 18.04
79-
8048
nginx_app_protect_security_policy_template_enable: true
8149
nginx_app_protect_security_policy_template:
8250
template_file: app-protect-security-policy.j2

molecule/Dockerfile.j2

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,27 @@ ENV {{ var }} {{ value }}
1717
RUN \
1818
if [ $(command -v apt-get) ]; then \
1919
apt-get update \
20-
&& DEBIAN_FRONTEND=noninteractive apt-get install -y python3 sudo bash ca-certificates iproute2 python3-apt python-apt aptitude systemd systemd-sysv procps curl \
20+
&& DEBIAN_FRONTEND=noninteractive apt-get install -y aptitude bash ca-certificates curl iproute2 python-apt python3 python3-apt procps sudo systemd systemd-sysv \
2121
&& apt-get clean; \
2222
elif [ $(command -v dnf) ]; then \
2323
dnf makecache \
24-
&& dnf --assumeyes install /usr/bin/python3 /usr/bin/python3-config /usr/bin/dnf-3 bash iproute \
24+
&& dnf --assumeyes install bash iproute /usr/bin/dnf-3 /usr/bin/python3 /usr/bin/python3-config \
2525
&& dnf clean all; \
2626
elif [ $(command -v yum) ]; then \
2727
yum makecache fast \
28-
&& yum install -y /usr/bin/python /usr/bin/python2-config sudo yum-plugin-ovl bash iproute \
28+
&& yum install -y bash iproute /usr/bin/python /usr/bin/python2-config sudo yum-plugin-ovl \
2929
&& sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf \
3030
&& yum clean all; \
3131
elif [ $(command -v zypper) ]; then \
3232
zypper refresh \
33-
&& zypper install -y python3 sudo bash iproute2 \
33+
&& zypper install -y bash iproute2 python3 sudo \
3434
&& zypper clean -a; \
3535
elif [ $(command -v apk) ]; then \
3636
apk update \
37-
&& apk add --no-cache python3 sudo bash ca-certificates curl openrc; \
37+
&& apk add --no-cache bash ca-certificates curl openrc python3 sudo; \
3838
echo 'rc_provide="loopback net"' >> /etc/rc.conf; \
3939
elif [ $(command -v xbps-install) ]; then \
4040
xbps-install -Syu \
41-
&& xbps-install -y python3 sudo bash ca-certificates iproute2 \
41+
&& xbps-install -y bash ca-certificates iproute2 python3 sudo \
4242
&& xbps-remove -O; \
4343
fi

vars/main.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,32 @@
11
---
2+
# Populate this dictionary of lists with appropriate values from ansible_distribution and ansible_distribution_version facts
3+
nginx_app_protect_linux_families:
4+
CentOS:
5+
- 7.4
6+
- 7.5
7+
- 7.6
8+
- 7.7
9+
- 7.8
10+
RedHat:
11+
- 7.4
12+
- 7.5
13+
- 7.6
14+
- 7.7
15+
- 7.8
16+
Debian:
17+
- 9.0
18+
- 9.1
19+
- 9.2
20+
- 9.3
21+
- 9.4
22+
- 9.5
23+
- 9.6
24+
- 9.7
25+
- 9.8
26+
- 9.9
27+
- 9.10
28+
- 9.11
29+
- 9.12
30+
- 9.13
31+
Ubuntu:
32+
- 18.04

0 commit comments

Comments
 (0)