Skip to content

Commit ef1294b

Browse files
committed
Install NGINX Controller agent
1 parent a8db981 commit ef1294b

File tree

7 files changed

+73
-3
lines changed

7 files changed

+73
-3
lines changed

defaults/main.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ modules:
4949
amplify_enable: false
5050
amplify_key: null
5151

52+
# Install NGINX Controller.
53+
# Use your NGINX Controller API key.
54+
# Default is null.
55+
controller_enable: false
56+
controller_license: null
57+
controller_api_url: null
58+
5259
# Enable NGINX status data.
5360
# Will enable 'stub_status' in NGINX Open Source and 'status' in NGINX Plus.
5461
# Default is false.

handlers/main.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,8 @@
2121
name: unitd
2222
state: started
2323
enabled: yes
24+
25+
- name: "(Handler: All OSs) Start NGINX Controller Agent"
26+
service:
27+
name: controller-agent
28+
state: started

meta/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ galaxy_info:
3535
galaxy_tags:
3636
- nginx
3737
- amplify
38+
- controller
3839
- oss
3940
- plus
4041
- web
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
- import_tasks: setup-debian.yml
3+
when: ansible_os_family == "Debian"
4+
5+
- import_tasks: setup-redhat.yml
6+
when: ansible_os_family == "RedHat"
7+
8+
- name: "(Install: All OSs) Install NGINX Controller Agent"
9+
package:
10+
name: nginx-controller-agent
11+
state: present
12+
13+
- name: "(Setup: All OSs) Copy NGINX Controller Agent Configuration Template"
14+
copy:
15+
remote_src: yes
16+
src: /etc/controller-agent/agent.controller.conf.default
17+
dest: /etc/controller-agent/agent.conf
18+
19+
- name: "(Setup: All OSs) Copy NGINX Configurator Agent Configuration Template"
20+
copy:
21+
remote_src: yes
22+
src: /etc/controller-agent/agent.configurator.conf.default
23+
dest: /etc/controller-agent/agent.configurator.conf
24+
25+
- name: "(Setup: All OSs) Configure NGINX Controller Agent API Key"
26+
lineinfile:
27+
dest: /etc/controller-agent/agent.conf
28+
regexp: api_key =.*
29+
line: "api_key = {{ controller_license }}"
30+
31+
- name: "(Setup: All OSs) Configure NGINX Controller Agent API URL"
32+
lineinfile:
33+
dest: /etc/controller-agent/agent.conf
34+
regexp: api_url =.*
35+
line: "api_url = {{ controller_api_url }}"
36+
37+
- name: "(Setup: All OSs) Configure NGINX Controller Agent API Hostname"
38+
lineinfile:
39+
dest: /etc/controller-agent/agent.conf
40+
regexp: hostname =.*
41+
line: "hostname = {{ ansible_hostname }}"
42+
notify: "(Handler: All OSs) Start NGINX Controller Agent"

tasks/controller/setup-debian.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
- name: "(Install: Debian/Ubuntu) Add NGINX Controller Repository"
3+
apt_repository:
4+
filename: nginx-controller
5+
repo: deb http://packages.nginx.org/controller/{{ ansible_distribution|lower }}/ {{ ansible_distribution_release|lower }} controller

tasks/controller/setup-redhat.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
- name: "(Install: CentOS/RedHat) Add NGINX Controller Agent Repository"
3+
yum_repository:
4+
name: nginx-controller
5+
baseurl: http://packages.nginx.org/controller/centos/$releasever/$basearch/
6+
description: NGINX Controller Agent
7+
gpgcheck: yes

tasks/main.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,13 @@
3131
- import_tasks: conf/setup-rest-api.yml
3232
when: rest_api_enable and type == "plus"
3333

34-
- import_tasks: amplify/install-amplify.yml
35-
when: amplify_enable and amplify_key is defined and amplify_key
36-
3734
when: nginx_enable
3835

36+
- import_tasks: amplify/install-amplify.yml
37+
when: amplify_enable and amplify_key is defined and amplify_key
38+
39+
- import_tasks: controller/install-controller.yml
40+
when: controller_enable and controller_license is defined and controller_license and controller_api_url is defined and controller_api_url
41+
3942
- import_tasks: unit/install-unit.yml
4043
when: unit_enable

0 commit comments

Comments
 (0)