|  | 
| 1 |  | -NGINX Controller Agent | 
| 2 |  | -====================== | 
|  | 1 | +# Ansible NGINX Controller Agent Role | 
| 3 | 2 | 
 | 
| 4 |  | -This Role installs, configures, and upgrades the NGINX Controller agent alongside an NGINX Plus instance in a machine. | 
|  | 3 | +This role installs, configures, and upgrades the NGINX Controller agent alongside an NGINX Plus instance in a machine. | 
| 5 | 4 | 
 | 
| 6 |  | -Requirements | 
| 7 |  | ------------- | 
|  | 5 | +## Requirements | 
| 8 | 6 | 
 | 
| 9 |  | -*   [NGINX Plus](https://www.nginx.com/products/nginx/) | 
| 10 |  | -*   [NGINX Controller](https://www.nginx.com/products/nginx-controller/) | 
|  | 7 | +### NGINX Controller and NGINX Plus | 
| 11 | 8 | 
 | 
| 12 |  | -Role Variables | 
| 13 |  | --------------- | 
|  | 9 | +* [NGINX Plus](https://www.nginx.com/products/nginx/) | 
|  | 10 | +* [NGINX Controller](https://www.nginx.com/products/nginx-controller/) | 
| 14 | 11 | 
 | 
| 15 |  | -### Required Variables | 
|  | 12 | +### Ansible | 
| 16 | 13 | 
 | 
| 17 |  | -`nginx_controller_fqdn` - FQDN of the NGINX Controller instance | 
|  | 14 | +* This role is developed and tested with [maintained](https://docs.ansible.com/ansible/devel/reference_appendices/release_and_maintenance.html) versions of Ansible core (above `2.11`). | 
|  | 15 | +* You will need to run this role as a root user using Ansible's `become` parameter. Make sure you have set up the appropriate permissions on your target hosts. | 
|  | 16 | +* Instructions on how to install Ansible can be found in the [Ansible website](https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#upgrading-ansible-from-version-2-9-and-older-to-version-2-10-or-later). | 
| 18 | 17 | 
 | 
| 19 |  | -`nginx_controller_api_key` - The API key used to authenticate to NGINX Controller. | 
|  | 18 | +### Molecule (Optional) | 
| 20 | 19 | 
 | 
| 21 |  | -### Optional Variables | 
|  | 20 | +* Molecule is used to test the various functionalities of the role. The recommended version of Molecule to test this role is `3.3`. | 
|  | 21 | +* Instructions on how to install Molecule can be found in the [Molecule website](https://molecule.readthedocs.io/en/latest/installation.html). _You will also need to install the Molecule Docker driver._ | 
| 22 | 22 | 
 | 
| 23 |  | -`nginx_controller_hostname` - The name of the NGINX instance as reflected in NGINX Controller. Must be unique per instance.  (currently redundant with nginx_controller_instance_name) | 
|  | 23 | +## Installation | 
| 24 | 24 | 
 | 
| 25 |  | -`nginx_controller_location` - The location in NGINX Controller this instance will be automatically added to. Otherwise the location will be 'unspecified' in NGINX Controller. | 
|  | 25 | +### Ansible Galaxy | 
| 26 | 26 | 
 | 
| 27 |  | -`nginx_controller_instance_name` - The name of the instance as reflected in Controller. Must be unique per instance. | 
|  | 27 | +Use `ansible-galaxy install nginxinc.nginx_controller_agent` to install the latest stable release of the role on your system. Alternatively, if you have already installed the role, use `ansible-galaxy install -f nginxinc.nginx_controller_agent` to update the role to the latest release. | 
| 28 | 28 | 
 | 
| 29 |  | -Dependencies | 
| 30 |  | ------------- | 
|  | 29 | +### Git | 
| 31 | 30 | 
 | 
| 32 |  | -Example Playbook | 
| 33 |  | ----------------- | 
|  | 31 | +Use `git clone https://github.com/nginxinc/ansible_role_nginx_controller_agent.git` to pull the latest edge commit of the role from GitHub. | 
|  | 32 | + | 
|  | 33 | +## Platforms | 
|  | 34 | + | 
|  | 35 | +The NGINX Controller agent Ansible role supports all platforms supported by the [NGINX Controller agent](https://docs.nginx.com/nginx-controller/admin-guides/install/nginx-controller-tech-specs/): | 
|  | 36 | + | 
|  | 37 | +```yaml | 
|  | 38 | +Amazon: | 
|  | 39 | +  - 2017.09 | 
|  | 40 | +Amazon Linux 2: | 
|  | 41 | +  - any | 
|  | 42 | +CentOS: | 
|  | 43 | +  - 7.4+ | 
|  | 44 | +Debian: | 
|  | 45 | +  - stretch (9) | 
|  | 46 | +  - buster (10) | 
|  | 47 | +RHEL: | 
|  | 48 | +  - 7.4+ | 
|  | 49 | +Ubuntu: | 
|  | 50 | +  - bionic (18.04) | 
|  | 51 | +  - focal (20.04) | 
|  | 52 | +``` | 
|  | 53 | +
 | 
|  | 54 | +## Role Variables | 
|  | 55 | +
 | 
|  | 56 | +| Variable | Default | Description | Required | | 
|  | 57 | +| -------- | ------- | ----------- | -------- | | 
|  | 58 | +| `nginx_controller_fqdn` | `""` | FQDN of the NGINX Controller instance | Yes | | 
|  | 59 | +| `nginx_controller_api_key` | `""` | The API key used to authenticate to NGINX Controller | Yes | | 
|  | 60 | +| `nginx_controller_location` | `"unspecified"` | The location in NGINX Controller this instance will be automatically added to | No | | 
|  | 61 | +| `nginx_controller_hostname` | `""` | The unique name of the NGINX instance as reflected in NGINX Controller -- currently redundant with `nginx_controller_instance_name` | No | | 
|  | 62 | +| `nginx_controller_instance_name` | `""` | The unique name of the NGINX instance as reflected in NGINX Controller -- currently redundant with `nginx_controller_hostname` | No | | 
|  | 63 | + | 
|  | 64 | +## Example Playbook | 
| 34 | 65 | 
 | 
| 35 | 66 | To use this role you can create a playbook such as the following: | 
| 36 | 67 | 
 | 
| 37 | 68 | ```yaml | 
| 38 | 69 | --- | 
| 39 |  | -- hosts: localhost | 
| 40 |  | -  gather_facts: false | 
|  | 70 | +- name: Fetch NGINX Controller API Key | 
|  | 71 | +  hosts: localhost | 
| 41 | 72 |   connection: local | 
| 42 |  | - | 
|  | 73 | +  gather_facts: false | 
| 43 | 74 |   vars: | 
| 44 | 75 |     nginx_controller_user_email: "[email protected]" | 
| 45 | 76 |     nginx_controller_user_password: "mySecurePassword" | 
| 46 | 77 |     nginx_controller_fqdn: "controller.mydomain.com" | 
| 47 | 78 |     nginx_controller_validate_certs: false | 
| 48 |  | - | 
| 49 | 79 |   tasks: | 
| 50 |  | -  - include_role: | 
| 51 |  | -      name: nginxinc.nginx_controller.nginx_controller_generate_token | 
| 52 |  | - | 
| 53 |  | -  - name: Get controller api key for agent registration | 
| 54 |  | -    uri: | 
| 55 |  | -      url: "https://{{ nginx_controller_fqdn }}/api/v1/platform/global" | 
| 56 |  | -      method: "GET" | 
| 57 |  | -      return_content: yes | 
| 58 |  | -      status_code: 200 | 
| 59 |  | -      validate_certs: false | 
| 60 |  | -      headers: | 
| 61 |  | -        Cookie: "{{nginx_controller_auth_token}}" | 
| 62 |  | -    register: ctrl_globals | 
| 63 |  | - | 
| 64 |  | -  - name: Copy api_key to a variable | 
| 65 |  | -    set_fact: | 
| 66 |  | -      api_key: "{{ctrl_globals.json.currentStatus.agentSettings.apiKey}}" | 
| 67 |  | - | 
| 68 |  | -- hosts: tag_new_gateway | 
|  | 80 | +    - name: Fetch NGINX Controller auth token | 
|  | 81 | +      include_role: | 
|  | 82 | +        name: nginxinc.nginx_controller_generate_token | 
|  | 83 | +
 | 
|  | 84 | +    - name: Fetch NGINX Controller API Key for the NGINX Controller agent registration | 
|  | 85 | +      uri: | 
|  | 86 | +        url: "https://{{ nginx_controller_fqdn }}/api/v1/platform/global" | 
|  | 87 | +        method: GET | 
|  | 88 | +        return_content: yes | 
|  | 89 | +        status_code: 200 | 
|  | 90 | +        validate_certs: false | 
|  | 91 | +        headers: | 
|  | 92 | +          Cookie: "{{ nginx_controller_auth_token }}" | 
|  | 93 | +      register: ctrl_globals | 
|  | 94 | +
 | 
|  | 95 | +    - name: Filter API Key to a variable | 
|  | 96 | +      set_fact: | 
|  | 97 | +        api_key: "{{ ctrl_globals.json.currentStatus.agentSettings.apiKey }}" | 
|  | 98 | +
 | 
|  | 99 | +- name: Install NGINX Controller agent | 
|  | 100 | +  hosts: tag_new_gateway | 
| 69 | 101 |   remote_user: ubuntu | 
| 70 | 102 |   become: true | 
| 71 | 103 |   become_method: sudo | 
| 72 |  | -  gather_facts: yes | 
| 73 |  | - | 
| 74 | 104 |   tasks: | 
| 75 |  | -  - name: install minimal support for python2 for Agent install script | 
| 76 |  | -    apt: | 
| 77 |  | -      name: "{{ packages }}" | 
| 78 |  | -      state: present | 
| 79 |  | -    vars: | 
| 80 |  | -      packages: | 
| 81 |  | -      - python-minimal | 
| 82 |  | -      - libxerces-c3.2 | 
| 83 |  | - | 
| 84 |  | -  - name: install the agent | 
| 85 |  | -    include_role: | 
| 86 |  | -      name: nginxinc.nginx_controller.nginx_controller_agent | 
| 87 |  | -    vars: | 
| 88 |  | -      nginx_controller_api_key: "{{ hostvars['localhost']['api_key'] }}" | 
|  | 105 | +    # - name: Install minimal support for python2 for Agent install script | 
|  | 106 | +    #   apt: | 
|  | 107 | +    #     name: | 
|  | 108 | +    #       - python-minimal | 
|  | 109 | +    #       - libxerces-c3.2 | 
|  | 110 | +
 | 
|  | 111 | +    - name: Install the NGINX Controller agent | 
|  | 112 | +      include_role: | 
|  | 113 | +        name: nginxinc.nginx_controller_agent | 
|  | 114 | +      vars: | 
|  | 115 | +        nginx_controller_api_key: "{{ hostvars['localhost']['api_key'] }}" | 
| 89 | 116 | ``` | 
| 90 | 117 | 
 | 
| 91 |  | -You can then run `ansible-playbook nginx_controller_agent.yaml` to execute the playbook. | 
|  | 118 | +## Other NGINX Ansible Collections and Roles | 
| 92 | 119 | 
 | 
| 93 |  | -Alternatively, you can also pass/override any variables at run time using the `--extra-vars` or `-e` flag like so `ansible-playbook nginx_controller_agent.yaml -e "[email protected] nginx_controller_user_password=notsecure nginx_controller_fqdn=controller.example.local nginx_controller_validate_certs=false"` | 
|  | 120 | +You can find the Ansible NGINX Core collection of roles to install and configure NGINX Open Source, NGINX Plus, and NGINX App Protect [here](https://github.com/nginxinc/ansible-collection-nginx). | 
| 94 | 121 | 
 | 
| 95 |  | -You can also pass/override any variables by passing a `yaml` file containing any number of variables like so `ansible-playbook nginx_controller_agent.yaml -e "@nginx_controller_agent_vars.yaml"` | 
|  | 122 | +You can find the Ansible NGINX role to install NGINX OSS and NGINX Plus [here](https://github.com/nginxinc/ansible-role-nginx). | 
| 96 | 123 | 
 | 
| 97 |  | -License | 
| 98 |  | -------- | 
|  | 124 | +You can find the Ansible NGINX configuration role to configure NGINX [here](https://github.com/nginxinc/ansible-role-nginx-config). | 
| 99 | 125 | 
 | 
| 100 |  | -[Apache License, Version 2.0](./LICENSE) | 
|  | 126 | +You can find the Ansible NGINX App Protect role to install and configure NGINX App Protect WAF and NGINX App Protect DoS [here](https://github.com/nginxinc/ansible-role-nginx-app-protect). | 
| 101 | 127 | 
 | 
| 102 |  | -Author Information | 
| 103 |  | ------------------- | 
|  | 128 | +You can find the Ansible NGINX Controller collection of roles to install and configure NGINX Controller [here](https://github.com/nginxinc/ansible-collection-nginx_controller). | 
| 104 | 129 | 
 | 
| 105 |  | -[Brian Ehlert](https://github.com/brianehlert) | 
|  | 130 | +You can find the Ansible NGINX Unit role to install NGINX Unit [here](https://github.com/nginxinc/ansible-role-nginx-unit). | 
|  | 131 | + | 
|  | 132 | +## License | 
|  | 133 | + | 
|  | 134 | +[Apache License, Version 2.0](https://github.com/nginxinc/ansible-role-nginx-config/blob/main/LICENSE) | 
|  | 135 | + | 
|  | 136 | +## Author Information | 
| 106 | 137 | 
 | 
| 107 | 138 | [Alessandro Fael Garcia](https://github.com/alessfg) | 
| 108 | 139 | 
 | 
|  | 140 | +[Brian Ehlert](https://github.com/brianehlert) | 
|  | 141 | + | 
| 109 | 142 | [Daniel Edgar](https://github.com/aknot242) | 
| 110 | 143 | 
 | 
| 111 |  | -© [NGINX, Inc.](https://www.nginx.com/) 2021 | 
|  | 144 | +© [F5 Networks, Inc.](https://www.f5.com/) 2020 - 2021 | 
0 commit comments