Skip to content

Commit 7785691

Browse files
authored
Merge pull request #60 from nginxinc/(feature)/refactor-amplify
Refactor NGINX Amplify agent installation
2 parents 65ab26a + a55a50d commit 7785691

File tree

7 files changed

+47
-15
lines changed

7 files changed

+47
-15
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ modules:
225225
# Requires access to either the NGINX stub status or the NGINX Plus REST API.
226226
# Default is null.
227227
amplify_enable: false
228-
amplify_key: null
228+
amplify_api_key: null
229229

230230
# Install NGINX Controller.
231231
# Use your NGINX Controller API key and NGINX Controller API endpoint.

defaults/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ modules:
5858
# Requires access to either the NGINX stub status or the NGINX Plus REST API.
5959
# Default is null.
6060
amplify_enable: false
61-
amplify_key: null
61+
amplify_api_key: null
6262

6363
# Install NGINX Controller.
6464
# Use your NGINX Controller API key and NGINX Controller API endpoint.

handlers/main.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@
1010
name: nginx
1111
state: reloaded
1212

13+
- name: "(Handler: All OSs) Start NGINX Amplify Agent"
14+
service:
15+
name: amplify-agent
16+
state: started
17+
18+
- name: "(Handler: All OSs) Start NGINX Controller Agent"
19+
service:
20+
name: controller-agent
21+
state: started
22+
1323
- name: "(Handler: Debian/Ubuntu/CentOS/RedHat) Start NGINX Unit"
1424
service:
1525
name: unit
@@ -21,8 +31,3 @@
2131
name: unitd
2232
state: started
2333
enabled: yes
24-
25-
- name: "(Handler: All OSs) Start NGINX Controller Agent"
26-
service:
27-
name: controller-agent
28-
state: started

tasks/amplify/install-amplify.yml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
11
---
2-
- import_tasks: ../conf/setup-status.yml
2+
- import_tasks: setup-debian.yml
3+
when: ansible_os_family == "Debian"
34

4-
- name: "(Install: All NGINX) Download NGINX Amplify Script"
5-
get_url:
6-
url: https://github.com/nginxinc/nginx-amplify-agent/raw/master/packages/install.sh
7-
dest: /tmp/install.sh
5+
- import_tasks: setup-redhat.yml
6+
when: ansible_os_family == "RedHat"
87

9-
- name: "(Install: All NGINX) Install NGINX Amplify"
10-
shell: API_KEY='{{ amplify_key }}' sh /tmp/install.sh -y
8+
- name: "(Install: All OSs) Install NGINX Amplify Agent"
9+
package:
10+
name: nginx-amplify-agent
11+
state: present
12+
13+
- name: "(Setup: All OSs) Copy NGINX Configurator Agent Configuration Template"
14+
copy:
15+
remote_src: yes
16+
src: /etc/amplify-agent/agent.configurator.conf.default
17+
dest: /etc/amplify-agent/agent.configurator.conf
18+
19+
- name: "(Setup: All OSs) Configure NGINX Amplify Agent API Key"
20+
lineinfile:
21+
dest: /etc/amplify-agent/agent.conf
22+
regexp: api_key =.*
23+
line: "api_key = {{ amplify_api_key }}"
24+
notify: "(Handler: All OSs) Start NGINX Amplify Agent"

tasks/amplify/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 Amplify Agent Repository"
3+
apt_repository:
4+
filename: nginx-amplify
5+
repo: deb http://packages.amplify.nginx.com/{{ ansible_distribution|lower }}/ {{ ansible_distribution_release|lower }} amplify-agent

tasks/amplify/setup-redhat.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
- name: "(Install: CentOS/RedHat/Amazon Linux) Add NGINX Amplify Agent Repository"
3+
yum_repository:
4+
name: nginx-amplify
5+
baseurl: http://packages.amplify.nginx.com/{{ (ansible_distribution == "Amazon") | ternary('amzn/', 'centos/') }}/$releasever/$basearch/
6+
description: NGINX Amplify Agent
7+
enabled: yes
8+
gpgcheck: yes

tasks/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
when: nginx_enable
3535

3636
- import_tasks: amplify/install-amplify.yml
37-
when: amplify_enable and amplify_key is defined and amplify_key
37+
when: amplify_enable and amplify_api_key is defined and amplify_api_key
3838

3939
- import_tasks: controller/install-controller.yml
4040
when: controller_enable and controller_api_key is defined and controller_api_key and controller_api_endpoint is defined and controller_api_endpoint

0 commit comments

Comments
 (0)