Refactor NGINX Amplify agent installation

This commit is contained in:
Alessandro Fael Garcia 2018-09-12 14:03:20 -07:00
parent 65ab26ab2f
commit a55a50d570
7 changed files with 47 additions and 15 deletions

View File

@ -225,7 +225,7 @@ modules:
# Requires access to either the NGINX stub status or the NGINX Plus REST API. # Requires access to either the NGINX stub status or the NGINX Plus REST API.
# Default is null. # Default is null.
amplify_enable: false amplify_enable: false
amplify_key: null amplify_api_key: null
# Install NGINX Controller. # Install NGINX Controller.
# Use your NGINX Controller API key and NGINX Controller API endpoint. # Use your NGINX Controller API key and NGINX Controller API endpoint.

View File

@ -58,7 +58,7 @@ modules:
# Requires access to either the NGINX stub status or the NGINX Plus REST API. # Requires access to either the NGINX stub status or the NGINX Plus REST API.
# Default is null. # Default is null.
amplify_enable: false amplify_enable: false
amplify_key: null amplify_api_key: null
# Install NGINX Controller. # Install NGINX Controller.
# Use your NGINX Controller API key and NGINX Controller API endpoint. # Use your NGINX Controller API key and NGINX Controller API endpoint.

View File

@ -10,6 +10,16 @@
name: nginx name: nginx
state: reloaded state: reloaded
- name: "(Handler: All OSs) Start NGINX Amplify Agent"
service:
name: amplify-agent
state: started
- name: "(Handler: All OSs) Start NGINX Controller Agent"
service:
name: controller-agent
state: started
- name: "(Handler: Debian/Ubuntu/CentOS/RedHat) Start NGINX Unit" - name: "(Handler: Debian/Ubuntu/CentOS/RedHat) Start NGINX Unit"
service: service:
name: unit name: unit
@ -21,8 +31,3 @@
name: unitd name: unitd
state: started state: started
enabled: yes enabled: yes
- name: "(Handler: All OSs) Start NGINX Controller Agent"
service:
name: controller-agent
state: started

View File

@ -1,10 +1,24 @@
--- ---
- import_tasks: ../conf/setup-status.yml - import_tasks: setup-debian.yml
when: ansible_os_family == "Debian"
- name: "(Install: All NGINX) Download NGINX Amplify Script" - import_tasks: setup-redhat.yml
get_url: when: ansible_os_family == "RedHat"
url: https://github.com/nginxinc/nginx-amplify-agent/raw/master/packages/install.sh
dest: /tmp/install.sh
- name: "(Install: All NGINX) Install NGINX Amplify" - name: "(Install: All OSs) Install NGINX Amplify Agent"
shell: API_KEY='{{ amplify_key }}' sh /tmp/install.sh -y package:
name: nginx-amplify-agent
state: present
- name: "(Setup: All OSs) Copy NGINX Configurator Agent Configuration Template"
copy:
remote_src: yes
src: /etc/amplify-agent/agent.configurator.conf.default
dest: /etc/amplify-agent/agent.configurator.conf
- name: "(Setup: All OSs) Configure NGINX Amplify Agent API Key"
lineinfile:
dest: /etc/amplify-agent/agent.conf
regexp: api_key =.*
line: "api_key = {{ amplify_api_key }}"
notify: "(Handler: All OSs) Start NGINX Amplify Agent"

View File

@ -0,0 +1,5 @@
---
- name: "(Install: Debian/Ubuntu) Add NGINX Amplify Agent Repository"
apt_repository:
filename: nginx-amplify
repo: deb http://packages.amplify.nginx.com/{{ ansible_distribution|lower }}/ {{ ansible_distribution_release|lower }} amplify-agent

View File

@ -0,0 +1,8 @@
---
- name: "(Install: CentOS/RedHat/Amazon Linux) Add NGINX Amplify Agent Repository"
yum_repository:
name: nginx-amplify
baseurl: http://packages.amplify.nginx.com/{{ (ansible_distribution == "Amazon") | ternary('amzn/', 'centos/') }}/$releasever/$basearch/
description: NGINX Amplify Agent
enabled: yes
gpgcheck: yes

View File

@ -34,7 +34,7 @@
when: nginx_enable when: nginx_enable
- import_tasks: amplify/install-amplify.yml - import_tasks: amplify/install-amplify.yml
when: amplify_enable and amplify_key is defined and amplify_key when: amplify_enable and amplify_api_key is defined and amplify_api_key
- import_tasks: controller/install-controller.yml - import_tasks: controller/install-controller.yml
when: controller_enable and controller_api_key is defined and controller_api_key and controller_api_endpoint is defined and controller_api_endpoint when: controller_enable and controller_api_key is defined and controller_api_key and controller_api_endpoint is defined and controller_api_endpoint