Merge pull request #59 from nginxinc/(feature)/install-controller

Install NGINX Controller agent
This commit is contained in:
Alessandro Fael Garcia 2018-09-12 13:33:43 -07:00 committed by GitHub
commit 65ab26ab2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 195 additions and 47 deletions

121
README.md
View File

@ -17,7 +17,7 @@ Use `ansible-galaxy install nginxinc.nginx` to install the role on your system.
It supports all platforms supported by [NGINX Open Source](https://nginx.org/en/linux_packages.html#mainline) and [NGINX Plus](https://www.nginx.com/products/technical-specs/):
**NGINX Open Source:**
**NGINX Open Source**
```yaml
CentOS:
@ -47,7 +47,7 @@ FreeBSD:
- 11
```
**NGINX Plus:**
**NGINX Plus**
```yaml
CentOS:
@ -84,7 +84,52 @@ FreeBSD:
- 11
```
**NGINX Unit:**
**NGINX Amplify**
```yaml
CentOS:
versions:
- 6
- 7
RedHat:
versions:
- 6
- 7
Debian:
versions:
- jessie
- stretch
Ubuntu:
versions:
- trusty
- xenial
- artful
- bionic
Amazon Linux:
versions:
- 2017.09
```
**NGINX Controller**
```yaml
CentOS:
versions:
- 7
RedHat:
versions:
- 7
Debian:
versions:
- jessie
- stretch
Ubuntu:
versions:
- xenial
- artful
```
**NGINX Unit**
```yaml
CentOS:
@ -154,6 +199,16 @@ nginx_repository:
# Default is mainline.
branch: mainline
# Location of your NGINX Plus license in your local machine.
# Default is the files folder within the NGINX Ansible role.
license:
certificate: license/nginx-repo.crt
key: license/nginx-repo.key
# Delete NGINX Plus license after installation for security purposes.
# Default is true.
delete_license: true
# Install NGINX JavaScript, Perl, ModSecurity WAF (NGINX Plus only), GeoIP, Image-Filter, RTMP Media Streaming, and/or XSLT modules.
# Default is false.
modules:
@ -167,31 +222,37 @@ modules:
# Install NGINX Amplify.
# Use your NGINX Amplify API key.
# Requires access to either the NGINX stub status or the NGINX Plus REST API.
# Default is null.
amplify_enable: false
amplify_key: null
# Install NGINX Controller.
# Use your NGINX Controller API key and NGINX Controller API endpoint.
# Requires NGINX Plus and write access to the NGINX Plus REST API.
# Default is null.
controller_enable: false
controller_api_key: null
controller_api_endpoint: null
# Install NGINX Unit and NGINX Unit modules.
# Use a list of supported NGINX Unit modules.
# Default is false.
unit_enable: false
unit_modules: null
# Enable NGINX status data.
# Will enable 'stub_status' in NGINX Open Source and 'status' in NGINX Plus.
# Default is false.
status_enable: false
# Enable NGINX Plus REST API, write access to the REST API, and NGINX Plus dashboard.
# Requires NGINX Plus.
# Default is false.
rest_api_enable: false
rest_api_write: false
rest_api_dashboard: false
# Location of your NGINX Plus license in your local machine.
# Default is the files folder within the NGINX Ansible role.
license:
certificate: license/nginx-repo.crt
key: license/nginx-repo.key
# Delete NGINX Plus license after installation for security purposes.
# Default is true.
delete_license: true
# Enable uploading NGINX configuration files to your system.
# Default for uploading files is false.
# Default location of files is the files folder within the NGINX Ansible role.
@ -215,12 +276,6 @@ http_template_listen: 80
http_template_server_name: localhost
stream_template_enable: false
stream_template_listen: 12345
# Install NGINX Unit and NGINX Unit modules.
# Use a list of supported NGINX Unit modules.
# Default is false.
unit_enable: false
unit_modules: null
```
Dependencies
@ -241,6 +296,16 @@ This is a sample playbook file for deploying the Ansible Galaxy NGINX role in a
- role: nginxinc.nginx
```
This is a sample playbook file for deploying the Ansible Galaxy NGINX role to a dynamic inventory containing the `nginx` tag.
```yaml
---
- hosts: tag_nginx
remote_user: root
roles:
- role: nginxinc.nginx
```
This is a sample playbook file for deploying the Ansible Galaxy NGINX role in a localhost and installing NGINX Plus.
```yaml
@ -253,19 +318,25 @@ This is a sample playbook file for deploying the Ansible Galaxy NGINX role in a
type: plus
```
This is a sample playbook file for deploying the Ansible Galaxy NGINX role to a dynamic inventory containing the `nginx` tag.
This is a sample playbook file for deploying the Ansible Galaxy NGINX role in a localhost to install NGINX Plus and the NGINX Controller agent.
```yml
---
- hosts: tag_nginx
remote_user: root
```yaml
- hosts: localhost
become: true
roles:
- role: nginxinc.nginx
vars:
type: plus
rest_api_enable: true
rest_api_write: true
controller_enable: true
controller_api_key: <API_KEY_HERE>
controller_api_endpoint: https://<FQDN>/1.4
```
This is a sample playbook file for deploying the Ansible Galaxy NGINX role in a localhost to install NGINX Unit and the PHP/Perl NGINX Unit language modules.
```yml
```yaml
---
- hosts: localhost
become: true

View File

@ -32,6 +32,16 @@ nginx_repository:
# Default is mainline.
branch: mainline
# Location of your NGINX Plus license in your local machine.
# Default is the files folder within the NGINX Ansible role.
license:
certificate: license/nginx-repo.crt
key: license/nginx-repo.key
# Delete NGINX Plus license after installation for security purposes.
# Default is true.
delete_license: true
# Install NGINX JavaScript, Perl, ModSecurity WAF (NGINX Plus only), GeoIP, Image-Filter, RTMP Media Streaming, and/or XSLT modules.
# Default is false.
modules:
@ -45,31 +55,37 @@ modules:
# Install NGINX Amplify.
# Use your NGINX Amplify API key.
# Requires access to either the NGINX stub status or the NGINX Plus REST API.
# Default is null.
amplify_enable: false
amplify_key: null
# Install NGINX Controller.
# Use your NGINX Controller API key and NGINX Controller API endpoint.
# Requires NGINX Plus and write access to the NGINX Plus REST API.
# Default is null.
controller_enable: false
controller_api_key: null
controller_api_endpoint: null
# Install NGINX Unit and NGINX Unit modules.
# Use a list of supported NGINX Unit modules.
# Default is false.
unit_enable: false
unit_modules: null
# Enable NGINX status data.
# Will enable 'stub_status' in NGINX Open Source and 'status' in NGINX Plus.
# Default is false.
status_enable: false
# Enable NGINX Plus REST API, write access to the REST API, and NGINX Plus dashboard.
# Requires NGINX Plus.
# Default is false.
rest_api_enable: false
rest_api_write: false
rest_api_dashboard: false
# Location of your NGINX Plus license in your local machine.
# Default is the files folder within the NGINX Ansible role.
license:
certificate: license/nginx-repo.crt
key: license/nginx-repo.key
# Delete NGINX Plus license after installation for security purposes.
# Default is true.
delete_license: true
# Enable uploading NGINX configuration files to your system.
# Default for uploading files is false.
# Default location of files is the files folder within the NGINX Ansible role.
@ -93,9 +109,3 @@ http_template_listen: 80
http_template_server_name: localhost
stream_template_enable: false
stream_template_listen: 12345
# Install NGINX Unit and NGINX Unit modules.
# Use a list of supported NGINX Unit modules.
# Default is false.
unit_enable: false
unit_modules: null

View File

@ -21,3 +21,8 @@
name: unitd
state: started
enabled: yes
- name: "(Handler: All OSs) Start NGINX Controller Agent"
service:
name: controller-agent
state: started

View File

@ -34,13 +34,18 @@ galaxy_info:
galaxy_tags:
- nginx
- amplify
- nginx-oss
- oss
- nginx-plus
- plus
- nginx-amplify
- amplify
- nginx-controller
- controller
- nginx-unit
- unit
- web
- server
- unit
- development
- web
dependencies: []

View File

@ -0,0 +1,42 @@
---
- import_tasks: setup-debian.yml
when: ansible_os_family == "Debian"
- import_tasks: setup-redhat.yml
when: ansible_os_family == "RedHat"
- name: "(Install: All OSs) Install NGINX Controller Agent"
package:
name: nginx-controller-agent
state: present
- name: "(Setup: All OSs) Copy NGINX Controller Agent Configuration Template"
copy:
remote_src: yes
src: /etc/controller-agent/agent.controller.conf.default
dest: /etc/controller-agent/agent.conf
- name: "(Setup: All OSs) Copy NGINX Configurator Agent Configuration Template"
copy:
remote_src: yes
src: /etc/controller-agent/agent.configurator.conf.default
dest: /etc/controller-agent/agent.configurator.conf
- name: "(Setup: All OSs) Configure NGINX Controller Agent API Key"
lineinfile:
dest: /etc/controller-agent/agent.conf
regexp: api_key =.*
line: "api_key = {{ controller_api_key }}"
- name: "(Setup: All OSs) Configure NGINX Controller Agent API URL"
lineinfile:
dest: /etc/controller-agent/agent.conf
regexp: api_url =.*
line: "api_url = {{ controller_api_endpoint }}"
- name: "(Setup: All OSs) Configure NGINX Controller Agent API Hostname"
lineinfile:
dest: /etc/controller-agent/agent.conf
regexp: hostname =.*
line: "hostname = {{ ansible_hostname }}"
notify: "(Handler: All OSs) Start NGINX Controller Agent"

View File

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

View File

@ -0,0 +1,7 @@
---
- name: "(Install: CentOS/RedHat) Add NGINX Controller Agent Repository"
yum_repository:
name: nginx-controller
baseurl: http://packages.nginx.org/controller/centos/$releasever/$basearch/
description: NGINX Controller Agent
gpgcheck: yes

View File

@ -31,10 +31,13 @@
- import_tasks: conf/setup-rest-api.yml
when: rest_api_enable and type == "plus"
- import_tasks: amplify/install-amplify.yml
when: nginx_enable
- import_tasks: amplify/install-amplify.yml
when: amplify_enable and amplify_key is defined and amplify_key
when: nginx_enable
- 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
- import_tasks: unit/install-unit.yml
when: unit_enable