Skip to content
This repository was archived by the owner on Aug 9, 2022. It is now read-only.

Commit 065a521

Browse files
committed
Refactor role to bring it up to par with other NGINX Ansible roles (#19)
1 parent 11b2f56 commit 065a521

23 files changed

+180
-119
lines changed

.ansible-lint

Lines changed: 0 additions & 2 deletions
This file was deleted.

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,27 @@ labels: ''
66
assignees: ''
77
---
88
### Describe the bug
9+
910
A clear and concise description of what the bug is.
1011

1112
### To reproduce
13+
1214
Steps to reproduce the behavior:
15+
1316
1. Deploy NGINX Controller Generate Token role using playbook.yml
1417
2. View output/logs/configuration on '...'
1518
3. See error
1619

1720
### Expected behavior
21+
1822
A clear and concise description of what you expected to happen.
1923

20-
### Your environment:
21-
- Version of the NGINX Controller Generate Token role or specific commit
22-
- Version of Ansible
23-
- Version of Jinja2 (if you are using any templating capability)
24-
- Target deployment platform
24+
### Your environment
25+
26+
- Version of the NGINX Controller Generate Token role or specific commit
27+
- Version of Ansible
28+
- Target deployment platform
2529

2630
### Additional context
31+
2732
Add any other context about the problem here.

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@ labels: ''
66
assignees: ''
77
---
88
### Is your feature request related to a problem? Please describe
9+
910
A clear and concise description of what the problem is. Ex. I'm always frustrated when ...
1011

1112
### Describe the solution you'd like
13+
1214
A clear and concise description of what you want to happen.
1315

1416
### Describe alternatives you've considered
17+
1518
A clear and concise description of any alternative solutions or features you've considered.
1619

1720
### Additional context
21+
1822
Add any other context or screenshots about the feature request here.

.github/pull_request_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Describe the use case and detail of the change. If this PR addresses an issue on
44
### Checklist
55
Before creating a PR, run through this checklist and mark each as complete.
66

7-
- [ ] I have read the [CONTRIBUTING](https://github.com/nginxinc/ansible-role-nginx-controller-generate-token/blob/main/CONTRIBUTING.md) document
7+
- [ ] I have read the [CONTRIBUTING](https://github.com/nginxinc/ansible_role_nginx_controller_generate_token/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 any relevant Molecule tests pass after adding my changes
1010
- [ ] I have updated any relevant documentation (`defaults/main/*.yml`, `README.md` and `CHANGELOG.md`)

.github/release-drafter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,6 @@ template: |
9494
9595
## Resources
9696
97-
* Functional configuration examples (check `converge.yml` under each `molecule` scenario) -- [github.com/nginxinc/ansible-role-nginx-controller-generate-token/tree/$RESOLVED_VERSION/molecule](https://github.com/nginxinc/ansible-role-nginx-controller-generate-token/tree/$RESOLVED_VERSION/molecule).
97+
* Functional configuration examples (check `converge.yml` under each `molecule` scenario) -- [github.com/nginxinc/ansible_role_nginx_controller_generate_token/tree/$RESOLVED_VERSION/molecule](https://github.com/nginxinc/ansible_role_nginx_controller_generate_token/tree/$RESOLVED_VERSION/molecule).
9898
* Ansible Galaxy repository -- [galaxy.ansible.com/nginxinc/nginx_controller_generate_token](https://galaxy.ansible.com/nginxinc/nginx_controller_generate_token).
9999
* NGINX: Better with Ansible demo -- [github.com/alessfg/nginx-ansible-demo](https://github.com/alessfg/nginx-ansible-demo).

.github/workflows/molecule.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@ jobs:
3838
- name: Run Molecule tests
3939
run: molecule test -s ${{ matrix.scenario }}
4040
env:
41-
PY_COLORS: "1"
42-
ANSIBLE_FORCE_COLOR: "1"
41+
PY_COLORS: 1
42+
ANSIBLE_FORCE_COLOR: 1
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
---
22
collections:
33
- name: community.docker
4-
version: 1.7.0
4+
version: 2.0.0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
ansible-core==2.11.6
22
Jinja2==3.0.2
3-
ansible-lint==5.2.0
3+
ansible-lint==5.2.1
44
yamllint==1.26.3
55
molecule[docker]==3.5.2
66
docker==5.0.3

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@ Thumbs.db
2121
# Python specific #
2222
###################
2323
__pycache__
24+
25+
# Logs #
26+
########
27+
*.log

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44

55
ENHANCEMENTS:
66

7-
* Implement GitHub Actions CI/CD workflow for repo.
8-
* Add Molecule tests for role.
7+
* Refactor role to bring it up to par with other NGINX Ansible roles.
8+
* Implement GitHub Actions CI/CD workflow for repo.
9+
* Add Molecule tests for role.

CODE_OF_CONDUCT.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ members of the project's leadership.
6868
## Attribution
6969

7070
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71-
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
71+
available at <https://www.contributor-covenant.org/version/1/4/code-of-conduct.html>
7272

7373
[homepage]: https://www.contributor-covenant.org
7474

7575
For answers to common questions about this code of conduct, see
76-
https://www.contributor-covenant.org/faq
76+
<https://www.contributor-covenant.org/faq>

CONTRIBUTING.md

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,30 @@ The following is a set of guidelines for contributing to the NGINX Controller Ge
1111
[Contributing](#contributing)
1212

1313
[Code Guidelines](#code-guidelines)
14-
* [Git Guidelines](#git-guidelines)
15-
* [Ansible Guidelines](#ansible-guidelines)
1614

17-
[Code of Conduct](https://github.com/nginxinc/ansible-role-nginx-controller-generate-token/blob/main/CODE_OF_CONDUCT.md)
15+
* [Git Guidelines](#git-guidelines)
16+
* [Ansible Guidelines](#ansible-guidelines)
17+
18+
[Code of Conduct](https://github.com/nginxinc/ansible_role_nginx_controller_generate_token/blob/main/CODE_OF_CONDUCT.md)
1819

1920
## Ask a Question
2021

2122
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`.
2223

2324
## Getting Started
2425

25-
Follow our [Installation Guide](https://github.com/nginxinc/ansible-role-nginx-controller-generate-token/blob/main/README.md#Installation) to install Ansible and Molecule and get ready to use the NGINX Controller Generate Token Ansible role.
26+
Follow our [Installation Guide](https://github.com/nginxinc/ansible_role_nginx_controller_generate_token/blob/main/README.md#Installation) to install Ansible and Molecule and get ready to use the NGINX Controller Generate Token Ansible role.
2627

2728
### Project Structure
2829

29-
* The NGINX Controller Generate Token Ansible role is written in `yaml` and supports NGINX Controller.
30-
* 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 in [`tasks/`](https://github.com/nginxinc/ansible-role-nginx-controller-generate-token/blob/main/tasks/).
32-
* Variables can be found in [`defaults/main/`](https://github.com/nginxinc/ansible-role-nginx-controller-generate-token/blob/main/defaults/main/).
33-
* "Constant" variables can be found in [`vars/main.yml`](https://github.com/nginxinc/ansible-role-nginx-controller-generate-token/blob/main/vars/main.yml).
34-
* Configuration templates for NGINX can be found in [`templates/`](https://github.com/nginxinc/ansible-role-nginx-controller-generate-token/blob/main/templates/).
35-
* [Molecule](https://molecule.readthedocs.io/) tests can be found in [`molecule/`](https://github.com/nginxinc/ansible-role-nginx-controller-generate-token/blob/main/molecule/).
36-
* CI/CD is done via GitHub actions using the workflow files found in [`.github/workflows/`](https://github.com/nginxinc/ansible-role-nginx-controller-generate-token/blob/main/.github/workflows/).
30+
* The NGINX Controller Generate Token Ansible role is written in `yaml` and supports NGINX Controller.
31+
* The project follows the standard [Ansible role directory structure](https://docs.ansible.com/ansible/latest/user_guide/playbooks_reuse_roles.html)
32+
* The main code is found in [`tasks/`](https://github.com/nginxinc/ansible_role_nginx_controller_generate_token/blob/main/tasks/).
33+
* Variables can be found in [`defaults/main/`](https://github.com/nginxinc/ansible_role_nginx_controller_generate_token/blob/main/defaults/main/).
34+
* "Constant" variables can be found in [`vars/main.yml`](https://github.com/nginxinc/ansible_role_nginx_controller_generate_token/blob/main/vars/main.yml).
35+
* Configuration templates for NGINX can be found in [`templates/`](https://github.com/nginxinc/ansible_role_nginx_controller_generate_token/blob/main/templates/).
36+
* [Molecule](https://molecule.readthedocs.io/) tests can be found in [`molecule/`](https://github.com/nginxinc/ansible_role_nginx_controller_generate_token/blob/main/molecule/).
37+
* CI/CD is done via GitHub actions using the workflow files found in [`.github/workflows/`](https://github.com/nginxinc/ansible_role_nginx_controller_generate_token/blob/main/.github/workflows/).
3738

3839
## Contributing
3940

@@ -47,27 +48,27 @@ To suggest an enhancement, please create an issue on GitHub with the label `enha
4748

4849
### Open a Pull Request
4950

50-
* Fork the repo, create a branch, implement your changes, add any relevant Molecule tests, submit a PR when your changes are **tested** (using Molecule) and ready for review.
51-
* Fill in [our pull request template](https://github.com/nginxinc/ansible-role-nginx-controller-generate-token/blob/main/.github/pull_request_template.md).
51+
* Fork the repo, create a branch, implement your changes, add any relevant Molecule tests, submit a PR when your changes are **tested** (using Molecule) and ready for review.
52+
* Fill in [our pull request template](https://github.com/nginxinc/ansible_role_nginx_controller_generate_token/blob/main/.github/pull_request_template.md).
5253

5354
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.
5455

5556
## Code Guidelines
5657

5758
### Ansible Guidelines
5859

59-
* Run `molecule lint` over your code to automatically resolve a lot of `yaml` and Ansible style issues.
60-
* Run `molecule test` on your code before you submit a PR to catch any potential issues. If you are testing a specific molecule scenario, run `molecule test -s <scenario>`.
61-
* Follow these guides on some good practices for Ansible:
62-
* <https://www.ansible.com/blog/ansible-best-practices-essentials>
63-
* <https://docs.ansible.com/ansible/latest/user_guide/playbooks_best_practices.html>
60+
* Run `molecule lint` over your code to automatically resolve a lot of `yaml` and Ansible style issues.
61+
* Run `molecule test` on your code before you submit a PR to catch any potential issues. If you are testing a specific molecule scenario, run `molecule test -s <scenario>`.
62+
* Follow these guides on some good practices for Ansible:
63+
* <https://www.ansible.com/blog/ansible-best-practices-essentials>
64+
* <https://docs.ansible.com/ansible/latest/user_guide/playbooks_best_practices.html>
6465

6566
### Git Guidelines
6667

67-
* Keep a clean, concise and meaningful git commit history on your branch (within reason), rebasing locally and squashing before submitting a PR
68-
* 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
69-
* In the subject line, use the present tense ("Add feature" not "Added feature")
70-
* In the subject line, use the imperative mood ("Move cursor to..." not "Moves cursor to...")
71-
* Limit the subject line to 72 characters or less
72-
* Reference issues and pull requests liberally after the subject line
73-
* 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`)
68+
* Keep a clean, concise and meaningful git commit history on your branch (within reason), rebasing locally and squashing before submitting a PR
69+
* 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
70+
* In the subject line, use the present tense ("Add feature" not "Added feature")
71+
* In the subject line, use the imperative mood ("Move cursor to..." not "Moves cursor to...")
72+
* Limit the subject line to 72 characters or less
73+
* Reference issues and pull requests liberally after the subject line
74+
* 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`)

README.md

Lines changed: 71 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,77 @@
1-
NGINX Controller Generate Token
2-
===============================
1+
# Ansible NGINX Controller Generate Token Role
32

43
A role to generate and return an authentication token for NGINX Controller for use in other Roles or within a playbook.
54

6-
Requirements
7-
------------
5+
## Requirements
86

9-
[NGINX Controller](https://www.nginx.com/products/nginx-controller/)
7+
### NGINX Controller
108

11-
Role Variables
12-
--------------
9+
A running [NGINX Controller](https://www.nginx.com/products/nginx-controller/) instance.
1310

14-
-- All the below variables are required --
11+
### Ansible
1512

16-
`nginx_controller_user_email` - The email address of the NGINX Controller user.
13+
* This role is developed and tested with [maintained](https://docs.ansible.com/ansible/devel/reference_appendices/release_and_maintenance.html) versions of Ansible core (above `2.11`).
14+
* You will need to run this role as a root user using Ansible's `become` parameter. Make sure you have set up the appropriate permissions on your target hosts.
15+
* Instructions on how to install Ansible can be found in the [Ansible website](https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#upgrading-ansible-from-version-2-9-and-older-to-version-2-10-or-later).
1716

18-
`nginx_controller_user_password` - The password that corresponds to the controller.user_email.
17+
### Molecule (Optional)
1918

20-
`nginx_controller_fqdn` - The DNS name of your NGINX Controller installation.
19+
* Molecule is used to test the various functionalities of the role. The recommended version of Molecule to test this role is `3.3`.
20+
* Instructions on how to install Molecule can be found in the [Molecule website](https://molecule.readthedocs.io/en/latest/installation.html). _You will also need to install the Molecule Docker driver._
2121

22-
`nginx_controller_auth_token` - Variable returned by this Role and consumed by others to authenticate to the NGINX Controller API.
22+
## Installation
2323

24-
Dependencies
25-
------------
24+
### Ansible Galaxy
2625

27-
none
26+
Use `ansible-galaxy install nginxinc.nginx_controller_generate_token` to install the latest stable release of the role on your system. Alternatively, if you have already installed the role, use `ansible-galaxy install -f nginxinc.nginx_controller_generate_token` to update the role to the latest release.
2827

29-
Example Playbook
30-
----------------
28+
### Git
29+
30+
Use `git clone https://github.com/nginxinc/ansible_role_nginx_controller_generate_token.git` to pull the latest edge commit of the role from GitHub.
31+
32+
## Platforms
33+
34+
The NGINX Controller generate token Ansible role supports all platforms that support Ansible `2.11`, some of them being:
35+
36+
```yaml
37+
Alpine:
38+
- all
39+
Amazon Linux:
40+
- all
41+
Amazon Linux 2:
42+
- all
43+
CentOS:
44+
- all
45+
Debian:
46+
- all
47+
FreeBSD:
48+
- all
49+
RHEL:
50+
- all
51+
Ubuntu:
52+
- all
53+
```
54+
55+
## Role Variables
56+
57+
| Variable | Default | Description | Required |
58+
| -------- | ------- | ----------- | -------- |
59+
| `nginx_controller_user_email` | `""` | The email address of the NGINX Controller user | Yes |
60+
| `nginx_controller_user_password` | `""` | The password of the NGINX Controller user | Yes |
61+
| `nginx_controller_fqdn` | `""` | The FQDN of NGINX Controller | Yes |
62+
| `nginx_controller_validate_certs` | `false` | Whether NGINX Controller SSL cert should be validated or not | No |
63+
64+
In addition, this role returns the following variable:
65+
`nginx_controller_auth_token` - Authentication token used to authenticate to the NGINX Controller API.
66+
67+
## Example Playbook
3168

3269
To use this role you can create a playbook such as the following:
3370

3471
```yaml
72+
---
3573
- hosts: localhost
3674
gather_facts: no
37-
3875
tasks:
3976
- name: Retrieve the NGINX Controller auth token
4077
include_role:
@@ -46,24 +83,30 @@ To use this role you can create a playbook such as the following:
4683
nginx_controller_validate_certs: false
4784
```
4885

49-
You can then run `ansible-playbook nginx_controller_generate_token.yaml` to execute the playbook.
86+
## Other NGINX Ansible Collections and Roles
5087

51-
Alternatively, you can also pass/override any variables at run time using the `--extra-vars` or `-e` flag like so `ansible-playbook nginx_controller_generate_token.yaml -e "[email protected] nginx_controller_user_password=notsecure nginx_controller_fqdn=controller.example.local nginx_controller_validate_certs=false"`
88+
You can find the Ansible NGINX Core collection of roles to install and configure NGINX Open Source, NGINX Plus, and NGINX App Protect [here](https://github.com/nginxinc/ansible-collection-nginx).
5289

53-
You can also pass/override any variables by passing a `yaml` file containing any number of variables like so `ansible-playbook nginx_controller_generate_token.yaml -e "@nginx_controller_token_vars.yaml"`
90+
You can find the Ansible NGINX role to install NGINX OSS and NGINX Plus [here](https://github.com/nginxinc/ansible-role-nginx).
5491

55-
License
56-
-------
92+
You can find the Ansible NGINX configuration role to configure NGINX [here](https://github.com/nginxinc/ansible-role-nginx-config).
5793

58-
[Apache License, Version 2.0](./LICENSE)
94+
You can find the Ansible NGINX App Protect role to install and configure NGINX App Protect WAF and NGINX App Protect DoS [here](https://github.com/nginxinc/ansible-role-nginx-app-protect).
5995

60-
Author Information
61-
------------------
96+
You can find the Ansible NGINX Controller collection of roles to install and configure NGINX Controller [here](https://github.com/nginxinc/ansible-collection-nginx_controller).
6297

63-
[Brian Ehlert](https://github.com/brianehlert)
98+
You can find the Ansible NGINX Unit role to install NGINX Unit [here](https://github.com/nginxinc/ansible-role-nginx-unit).
99+
100+
## License
101+
102+
[Apache License, Version 2.0](https://github.com/nginxinc/ansible-role-nginx-config/blob/main/LICENSE)
103+
104+
## Author Information
64105

65106
[Alessandro Fael Garcia](https://github.com/alessfg)
66107

108+
[Brian Ehlert](https://github.com/brianehlert)
109+
67110
[Daniel Edgar](https://github.com/aknot242)
68111

69-
&copy; [NGINX, Inc.](https://www.nginx.com/) 2020
112+
&copy; [F5 Networks, Inc.](https://www.f5.com/) 2020 - 2021

defaults/main.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
11
---
2-
nginx_controller_api_version: "api/v1"
2+
# Required -- The email address of the NGINX Controller user.
3+
# nginx_controller_user_email: ""
4+
# Required -- The password of the NGINX Controller user.
5+
# nginx_controller_user_password: ""
6+
# Required -- The FQDN of NGINX Controller
7+
# nginx_controller_fqdn: ""
8+
9+
# Whether NGINX Controller SSL cert should be validated or not.
10+
# nginx_controller_validate_certs: false

meta/main.yml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
---
22
galaxy_info:
3-
author: Brian Ehlert
4-
description: A role to generate and return an authentication token for NGINX Controller for use in other Roles or within a playbook.
5-
company: F5 Networks, Inc.
3+
author: Alessandro Fael Garcia
4+
description: A role to generate an NGINX Controller authentication token.
65
role_name: nginx_controller_generate_token
7-
namespace: nginxinc
6+
namespace: nginxinc # Ansible Lint requirement
7+
company: F5 Networks, Inc.
88

99
license: Apache License, Version 2.0
1010

11-
min_ansible_version: 2.7
11+
min_ansible_version: 2.11
1212

1313
platforms:
1414
- name: Alpine
@@ -17,6 +17,9 @@ galaxy_info:
1717
- name: Amazon
1818
versions:
1919
- all
20+
- name: Amazon Linux 2
21+
versions:
22+
- all
2023
- name: Debian
2124
versions:
2225
- all
@@ -34,6 +37,9 @@ galaxy_info:
3437
- nginx
3538
- controller
3639
- api
40+
- auth
3741
- token
38-
39-
dependencies: []
42+
- cloud
43+
- infrastructure
44+
- linux
45+
- tools

0 commit comments

Comments
 (0)