Merge pull request #59 from nginxinc/(feature)/install-controller
Install NGINX Controller agent
This commit is contained in:
commit
65ab26ab2f
121
README.md
121
README.md
@ -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/):
|
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
|
```yaml
|
||||||
CentOS:
|
CentOS:
|
||||||
@ -47,7 +47,7 @@ FreeBSD:
|
|||||||
- 11
|
- 11
|
||||||
```
|
```
|
||||||
|
|
||||||
**NGINX Plus:**
|
**NGINX Plus**
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
CentOS:
|
CentOS:
|
||||||
@ -84,7 +84,52 @@ FreeBSD:
|
|||||||
- 11
|
- 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
|
```yaml
|
||||||
CentOS:
|
CentOS:
|
||||||
@ -154,6 +199,16 @@ nginx_repository:
|
|||||||
# Default is mainline.
|
# Default is mainline.
|
||||||
branch: 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.
|
# Install NGINX JavaScript, Perl, ModSecurity WAF (NGINX Plus only), GeoIP, Image-Filter, RTMP Media Streaming, and/or XSLT modules.
|
||||||
# Default is false.
|
# Default is false.
|
||||||
modules:
|
modules:
|
||||||
@ -167,31 +222,37 @@ modules:
|
|||||||
|
|
||||||
# Install NGINX Amplify.
|
# Install NGINX Amplify.
|
||||||
# Use your NGINX Amplify API key.
|
# Use your NGINX Amplify API key.
|
||||||
|
# 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_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.
|
# Enable NGINX status data.
|
||||||
# Will enable 'stub_status' in NGINX Open Source and 'status' in NGINX Plus.
|
# Will enable 'stub_status' in NGINX Open Source and 'status' in NGINX Plus.
|
||||||
# Default is false.
|
# Default is false.
|
||||||
status_enable: false
|
status_enable: false
|
||||||
|
|
||||||
# Enable NGINX Plus REST API, write access to the REST API, and NGINX Plus dashboard.
|
# Enable NGINX Plus REST API, write access to the REST API, and NGINX Plus dashboard.
|
||||||
|
# Requires NGINX Plus.
|
||||||
# Default is false.
|
# Default is false.
|
||||||
rest_api_enable: false
|
rest_api_enable: false
|
||||||
rest_api_write: false
|
rest_api_write: false
|
||||||
rest_api_dashboard: 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.
|
# Enable uploading NGINX configuration files to your system.
|
||||||
# Default for uploading files is false.
|
# Default for uploading files is false.
|
||||||
# Default location of files is the files folder within the NGINX Ansible role.
|
# 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
|
http_template_server_name: localhost
|
||||||
stream_template_enable: false
|
stream_template_enable: false
|
||||||
stream_template_listen: 12345
|
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
|
Dependencies
|
||||||
@ -241,6 +296,16 @@ This is a sample playbook file for deploying the Ansible Galaxy NGINX role in a
|
|||||||
- role: nginxinc.nginx
|
- 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.
|
This is a sample playbook file for deploying the Ansible Galaxy NGINX role in a localhost and installing NGINX Plus.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
@ -253,19 +318,25 @@ This is a sample playbook file for deploying the Ansible Galaxy NGINX role in a
|
|||||||
type: plus
|
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
|
```yaml
|
||||||
---
|
- hosts: localhost
|
||||||
- hosts: tag_nginx
|
become: true
|
||||||
remote_user: root
|
|
||||||
roles:
|
roles:
|
||||||
- role: nginxinc.nginx
|
- 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.
|
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
|
- hosts: localhost
|
||||||
become: true
|
become: true
|
||||||
|
@ -32,6 +32,16 @@ nginx_repository:
|
|||||||
# Default is mainline.
|
# Default is mainline.
|
||||||
branch: 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.
|
# Install NGINX JavaScript, Perl, ModSecurity WAF (NGINX Plus only), GeoIP, Image-Filter, RTMP Media Streaming, and/or XSLT modules.
|
||||||
# Default is false.
|
# Default is false.
|
||||||
modules:
|
modules:
|
||||||
@ -45,31 +55,37 @@ modules:
|
|||||||
|
|
||||||
# Install NGINX Amplify.
|
# Install NGINX Amplify.
|
||||||
# Use your NGINX Amplify API key.
|
# Use your NGINX Amplify API key.
|
||||||
|
# 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_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.
|
# Enable NGINX status data.
|
||||||
# Will enable 'stub_status' in NGINX Open Source and 'status' in NGINX Plus.
|
# Will enable 'stub_status' in NGINX Open Source and 'status' in NGINX Plus.
|
||||||
# Default is false.
|
# Default is false.
|
||||||
status_enable: false
|
status_enable: false
|
||||||
|
|
||||||
# Enable NGINX Plus REST API, write access to the REST API, and NGINX Plus dashboard.
|
# Enable NGINX Plus REST API, write access to the REST API, and NGINX Plus dashboard.
|
||||||
|
# Requires NGINX Plus.
|
||||||
# Default is false.
|
# Default is false.
|
||||||
rest_api_enable: false
|
rest_api_enable: false
|
||||||
rest_api_write: false
|
rest_api_write: false
|
||||||
rest_api_dashboard: 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.
|
# Enable uploading NGINX configuration files to your system.
|
||||||
# Default for uploading files is false.
|
# Default for uploading files is false.
|
||||||
# Default location of files is the files folder within the NGINX Ansible role.
|
# 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
|
http_template_server_name: localhost
|
||||||
stream_template_enable: false
|
stream_template_enable: false
|
||||||
stream_template_listen: 12345
|
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
|
|
||||||
|
@ -21,3 +21,8 @@
|
|||||||
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
|
||||||
|
@ -34,13 +34,18 @@ galaxy_info:
|
|||||||
|
|
||||||
galaxy_tags:
|
galaxy_tags:
|
||||||
- nginx
|
- nginx
|
||||||
- amplify
|
- nginx-oss
|
||||||
- oss
|
- oss
|
||||||
|
- nginx-plus
|
||||||
- plus
|
- plus
|
||||||
|
- nginx-amplify
|
||||||
|
- amplify
|
||||||
|
- nginx-controller
|
||||||
|
- controller
|
||||||
|
- nginx-unit
|
||||||
|
- unit
|
||||||
- web
|
- web
|
||||||
- server
|
- server
|
||||||
- unit
|
|
||||||
- development
|
- development
|
||||||
- web
|
|
||||||
|
|
||||||
dependencies: []
|
dependencies: []
|
||||||
|
42
tasks/controller/install-controller.yml
Normal file
42
tasks/controller/install-controller.yml
Normal 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"
|
5
tasks/controller/setup-debian.yml
Normal file
5
tasks/controller/setup-debian.yml
Normal 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
|
7
tasks/controller/setup-redhat.yml
Normal file
7
tasks/controller/setup-redhat.yml
Normal 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
|
@ -31,10 +31,13 @@
|
|||||||
- import_tasks: conf/setup-rest-api.yml
|
- import_tasks: conf/setup-rest-api.yml
|
||||||
when: rest_api_enable and type == "plus"
|
when: rest_api_enable and type == "plus"
|
||||||
|
|
||||||
- import_tasks: amplify/install-amplify.yml
|
|
||||||
when: amplify_enable and amplify_key is defined and amplify_key
|
|
||||||
|
|
||||||
when: nginx_enable
|
when: nginx_enable
|
||||||
|
|
||||||
|
- import_tasks: amplify/install-amplify.yml
|
||||||
|
when: amplify_enable and amplify_key is defined and amplify_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
|
||||||
|
|
||||||
- import_tasks: unit/install-unit.yml
|
- import_tasks: unit/install-unit.yml
|
||||||
when: unit_enable
|
when: unit_enable
|
||||||
|
Loading…
Reference in New Issue
Block a user