Merge pull request #60 from nginxinc/(feature)/refactor-amplify

Refactor NGINX Amplify agent installation
This commit is contained in:
Alessandro Fael Garcia 2018-09-14 10:14:19 -07:00 committed by GitHub
commit 7785691616
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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.
# Default is null.
amplify_enable: false
amplify_key: null
amplify_api_key: null
# Install NGINX Controller.
# 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.
# Default is null.
amplify_enable: false
amplify_key: null
amplify_api_key: null
# Install NGINX Controller.
# Use your NGINX Controller API key and NGINX Controller API endpoint.

View File

@ -10,6 +10,16 @@
name: nginx
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"
service:
name: unit
@ -21,8 +31,3 @@
name: unitd
state: started
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"
get_url:
url: https://github.com/nginxinc/nginx-amplify-agent/raw/master/packages/install.sh
dest: /tmp/install.sh
- import_tasks: setup-redhat.yml
when: ansible_os_family == "RedHat"
- name: "(Install: All NGINX) Install NGINX Amplify"
shell: API_KEY='{{ amplify_key }}' sh /tmp/install.sh -y
- name: "(Install: All OSs) Install NGINX Amplify Agent"
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
- 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
when: controller_enable and controller_api_key is defined and controller_api_key and controller_api_endpoint is defined and controller_api_endpoint