Skip to content

Commit dc4c714

Browse files
alessfgoliveromahonyoCHRISo
authored
feat: Install NGINX Agent (#698)
Co-authored-by: Oliver O'Mahony <[email protected]> Co-authored-by: Chris Adams <[email protected]>
1 parent 83e9fdb commit dc4c714

File tree

32 files changed

+439
-28
lines changed

32 files changed

+439
-28
lines changed

.github/workflows/molecule.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,19 @@ jobs:
3939
runs-on: ubuntu-22.04
4040
needs: ansible-lint
4141
env:
42+
AGENT_DATA_PLANE_KEY: ${{ secrets.AGENT_DATA_PLANE_KEY }}
4243
AMPLIFY_API_KEY: ${{ secrets.AMPLIFY_API_KEY }}
4344
AMPLIFY_EMAIL: ${{ secrets.AMPLIFY_EMAIL }}
4445
AMPLIFY_PASSWORD: ${{ secrets.AMPLIFY_PASSWORD }}
4546
NGINX_CRT: ${{ secrets.NGINX_CRT }}
4647
NGINX_KEY: ${{ secrets.NGINX_KEY }}
48+
ONE_API_TOKEN: ${{ secrets.ONE_API_TOKEN }}
49+
ONE_TENANT: ${{ secrets.ONE_TENANT }}
4750
strategy:
4851
fail-fast: false
4952
matrix:
5053
scenario:
54+
- agent
5155
- amplify
5256
- default
5357
- distribution

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
FEATURES:
66

7+
- Implement the ability to install the NGINX Agent.
78
- Add Alpine Linux 3.19 to the list of NGINX Open Source and NGINX Plus tested and supported distributions.
89
- Remove Alpine Linux 3.15 from the list of NGINX Open Source and NGINX Plus tested and supported distributions.
910

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Follow our [Installation Guide](https://github.com/nginxinc/ansible-role-nginx/b
2727

2828
### Project Structure
2929

30-
- The NGINX Ansible role is written in `yaml` and supports NGINX Open Source, NGINX Plus, and NGINX Amplify.
30+
- The NGINX Ansible role is written in `yaml` and supports NGINX Open Source, NGINX Plus, NGINX Agent and NGINX Amplify.
3131
- The project follows the standard [Ansible role directory structure](https://docs.ansible.com/ansible/latest/user_guide/playbooks_reuse_roles.html):
3232
- The main code is found in [`tasks/`](https://github.com/nginxinc/ansible-role-nginx/blob/main/tasks/).
3333
- Variables can be found in [`defaults/main/`](https://github.com/nginxinc/ansible-role-nginx/blob/main/defaults/main/).

README.md

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
# Ansible NGINX Role
1010

11-
This role installs NGINX Open Source, NGINX Plus, or the NGINX Amplify agent on your target host.
11+
This role installs NGINX Open Source, NGINX Plus, NGINX Agent or the NGINX Amplify agent on your target host.
1212

1313
**Note:** This role is still in active development. There may be unidentified issues and the role variables may change as development continues.
1414

@@ -85,7 +85,7 @@ git clone https://github.com/nginxinc/ansible-role-nginx.git
8585

8686
## Platforms
8787

88-
The NGINX Ansible role supports all platforms supported by [NGINX Open Source](https://nginx.org/en/linux_packages.html), [NGINX Plus](https://docs.nginx.com/nginx/technical-specs/), and the [NGINX Amplify agent](https://github.com/nginxinc/nginx-amplify-doc/blob/master/amplify-faq.md#21-what-operating-systems-are-supported):
88+
The NGINX Ansible role supports almost all platforms supported by [NGINX Open Source](https://nginx.org/en/linux_packages.html), [NGINX Plus](https://docs.nginx.com/nginx/technical-specs/), the [NGINX Agent](https://docs.nginx.com/nginx-agent/technical-specifications/), and the [NGINX Amplify agent](https://github.com/nginxinc/nginx-amplify-doc/blob/master/amplify-faq.md#21-what-operating-systems-are-supported):
8989

9090
### NGINX Open Source
9191

@@ -166,6 +166,46 @@ Ubuntu:
166166
- jammy (22.04)
167167
```
168168

169+
### NGINX Agent
170+
171+
```yaml
172+
AlmaLinux:
173+
- 8
174+
- 9
175+
Alpine:
176+
- 3.16
177+
- 3.17
178+
- 3.18
179+
- 3.19
180+
Amazon Linux:
181+
- 2
182+
Debian:
183+
- bullseye (11)
184+
- bookwork (12)
185+
CentOS:
186+
- 7.4+
187+
FreeBSD:
188+
- 13
189+
- 14
190+
Oracle Linux:
191+
- 7.4+
192+
- 8
193+
- 9
194+
Red Hat:
195+
- 7
196+
- 8
197+
- 9
198+
Rocky Linux:
199+
- 8
200+
- 9
201+
SUSE/SLES:
202+
- 12
203+
- 15
204+
Ubuntu:
205+
- focal (20.04)
206+
- jammy (22.04)
207+
```
208+
169209
### NGINX Amplify Agent
170210

171211
```yaml
@@ -183,7 +223,7 @@ Ubuntu:
183223
- jammy (22.04)
184224
```
185225

186-
**Note:** You can also use this role to compile NGINX Open Source from source, install NGINX Open Source on compatible yet unsupported platforms, or install NGINX Open Source on BSD systems at your own risk.
226+
**Note:** At your own risk, you can also use this role to compile NGINX Open Source from source, install NGINX Open Source on "compatible" yet unsupported platforms, install NGINX from your respective distribution package manager, or install NGINX Open Source on BSD systems.
187227

188228
## Role Variables
189229

@@ -192,6 +232,7 @@ This role has multiple variables. The descriptions and defaults for all these va
192232
| Name | Description |
193233
| ---- | ----------- |
194234
| **[`main.yml`](https://github.com/nginxinc/ansible-role-nginx/blob/main/defaults/main/main.yml)** | NGINX installation variables |
235+
| **[`agent.yml`](https://github.com/nginxinc/ansible-role-nginx/blob/main/defaults/main/agent.yml)** | NGINX Agent installation variables |
195236
| **[`amplify.yml`](https://github.com/nginxinc/ansible-role-nginx/blob/main/defaults/main/amplify.yml)** | NGINX Amplify agent installation variables |
196237
| **[`bsd.yml`](https://github.com/nginxinc/ansible-role-nginx/blob/main/defaults/main/bsd.yml)** | BSD installation variables |
197238
| **[`logrotate.yml`](https://github.com/nginxinc/ansible-role-nginx/blob/main/defaults/main/logrotate.yml)** | Logrotate configuration variables |
@@ -210,6 +251,7 @@ Working functional playbook examples can be found in the **[`molecule/`](https:/
210251

211252
| Name | Description |
212253
| ---- | ----------- |
254+
| **[`agent/converge.yml`](https://github.com/nginxinc/ansible-role-nginx/blob/main/molecule/agent/converge.yml)** | Install and configure the NGINX Agent to connect to the NGINX One SaaS control plane on F5 Distributed Cloud |
213255
| **[`amplify/converge.yml`](https://github.com/nginxinc/ansible-role-nginx/blob/main/molecule/amplify/converge.yml)** | Install and configure the NGINX Amplify agent |
214256
| **[`default/converge.yml`](https://github.com/nginxinc/ansible-role-nginx/blob/main/molecule/default/converge.yml)** | Install a specific version of NGINX, install various NGINX supported modules, tweak systemd and set up logrotate |
215257
| **[`distribution/converge.yml`](https://github.com/nginxinc/ansible-role-nginx/blob/main/molecule/distribution/converge.yml)** | Install NGINX from the distribution's package repository instead of NGINX's package repository |

defaults/main/agent.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
# Install NGINX Agent.
3+
# Requires access to either the NGINX stub_status or the NGINX Plus REST API.
4+
nginx_agent_enable: false
5+
6+
# Specify the NGINX Agent data plane key/token.
7+
# This is required to authenticate the NGINX Agent with the NGINX One SaaS control plane available in F5 Distributed Cloud.
8+
# Default is null.
9+
nginx_agent_data_plane_key: null
10+
11+
# Specify the control plane server host and port.
12+
# Default is the NGINX One SaaS control plane available in F5 Distributed Cloud.
13+
nginx_agent_server_host: agent.connect.nginx.com
14+
nginx_agent_server_port: 443
15+
16+
# Enable TLS communication between data plane and control plane
17+
# Default is true.
18+
nginx_agent_tls_enable: true
19+
nginx_agent_tls_skip_verify: false

defaults/main/amplify.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
# Install NGINX Amplify.
3-
# Use your NGINX Amplify API key.
43
# Requires access to either the NGINX stub_status or the NGINX Plus REST API.
4+
# Use your NGINX Amplify API key.
55
# Default is null.
66
nginx_amplify_enable: false
77
nginx_amplify_api_key: null

handlers/main.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@
4141
ansible.builtin.service:
4242
name: amplify-agent
4343
state: started
44+
enabled: true
45+
46+
- name: (Handler) Start NGINX Agent
47+
ansible.builtin.service:
48+
name: nginx-agent
49+
state: started
50+
enabled: true
4451

4552
- name: (Handler) Start logrotate
4653
ansible.builtin.command:

molecule/agent/cleanup.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
- name: Cleanup
3+
hosts: localhost
4+
gather_facts: false
5+
tasks:
6+
- name: Cleanup NGINX Agent instances
7+
block:
8+
- name: Wait for containers to be up
9+
ansible.builtin.wait_for_connection:
10+
delay: 1
11+
timeout: 2
12+
ignore_errors: true
13+
register: container
14+
15+
- name: Containers are not up, quit from here
16+
ansible.builtin.fail:
17+
when: container['failed'] | bool
18+
19+
- name: Gather facts
20+
ansible.builtin.setup:
21+
gather_subset:
22+
- "!all"
23+
- "!any"
24+
- distribution
25+
26+
- name: Get list of NGINX One dangling instance IDs
27+
ansible.builtin.uri:
28+
url: https://{{ lookup('env', 'ONE_TENANT') }}.console.ves.volterra.io/api/nginx/one/namespaces/default/instances?paginated=false&filter_fields=hostname&filter_ops=IN&filter_values=almalinux-8|almalinux-9|alpine-3.16|alpine-3.17|alpine-3.18|alpine-3.19|amazonlinux-2|centos-7|debian-bullseye|debian-bookworm|oraclelinux-7|oraclelinux-8|oraclelinux-9|rhel-7|rhel-8|rhel-9|rockylinux-8|rockylinux-9|sles-15|ubuntu-focal|ubuntu-jammy
29+
method: GET
30+
headers:
31+
Authorization: APIToken {{ lookup('env', 'ONE_API_TOKEN') }}
32+
register: get_ids
33+
34+
- name: Remove dangling instances from NGINX One
35+
ansible.builtin.uri:
36+
url: https://{{ lookup('env', 'ONE_TENANT') }}.console.ves.volterra.io/api/nginx/one/namespaces/default/instances/{{ item }}
37+
method: DELETE
38+
status_code: 204
39+
headers:
40+
Authorization: APIToken {{ lookup('env', 'ONE_API_TOKEN') }}
41+
loop: "{{ get_ids['json']['items'] | map(attribute='object_id') | list }}"
42+
rescue:
43+
- name: It's ok we're at startup
44+
ansible.builtin.meta: noop

molecule/agent/converge.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
- name: Converge
3+
hosts: all
4+
tasks:
5+
- name: Install NGINX Agent
6+
ansible.builtin.include_role:
7+
name: ansible-role-nginx
8+
vars:
9+
nginx_agent_enable: true
10+
nginx_agent_data_plane_key: "{{ lookup('env', 'AGENT_DATA_PLANE_KEY') }}"

0 commit comments

Comments
 (0)