Skip to content
This repository was archived by the owner on Aug 9, 2022. It is now read-only.

Commit bc1ab01

Browse files
committed
nginx_controller_ var pattern
1 parent e851790 commit bc1ab01

File tree

4 files changed

+34
-39
lines changed

4 files changed

+34
-39
lines changed

README.md

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ Role Variables
1414

1515
### Required Variables
1616

17-
`controller.fqdn` - FQDN of the NGINX Controller instance
17+
`nginx_controller_fqdn` - FQDN of the NGINX Controller instance
1818

19-
`api_key` - The API key used to authenticate to NGINX Controller.
19+
`nginx_controller_api_key` - The API key used to authenticate to NGINX Controller.
2020

2121
### Optional Variables
2222

23-
`controller_hostname` - The name of the NGINX instance as reflected in NGINX Controller. Must be unique per instance.
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)
2424

25-
`location` - The location in NGINX Controller this instance will be automatically added to. Otherwise the location will be 'unspecified' in NGINX Controller.
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.
2626

27-
`instance_name` - The name of the instance as reflected in Controller. Must be unique per instance (currently redundant with controller_hostname).
27+
`nginx_controller_instance_name` - The name of the instance as reflected in Controller. Must be unique per instance.
2828

2929
Dependencies
3030
------------
@@ -38,11 +38,10 @@ To use this role you can create a playbook such as the following:
3838
- hosts: localhost
3939
gather_facts: yes
4040
vars:
41-
controller:
42-
user_email: "user@example.com"
43-
user_password: "mySecurePassword"
44-
fqdn: "controller.mydomain.com"
45-
validate_certs: false
41+
nginx_controller_user_email: "user@example.com"
42+
nginx_controller_user_password: "mySecurePassword"
43+
nginx_controller_fqdn: "controller.mydomain.com"
44+
nginx_controller_validate_certs: false
4645

4746
tasks:
4847
- name: Upgrade your packages
@@ -64,31 +63,31 @@ To use this role you can create a playbook such as the following:
6463

6564
- name: Get NGINX Controller API key for agent registration
6665
uri:
67-
url: "https://{{ controller.fqdn }}/api/v1/platform/global"
66+
url: "https://{{ nginx_controller_fqdn }}/api/v1/platform/global"
6867
method: "GET"
6968
return_content: yes
7069
status_code: 200
71-
validate_certs: "{{ controller.validate_certs | default(false) }}"
70+
validate_certs: "{{ nginx_controller_validate_certs | default(false) }}"
7271
headers:
73-
Cookie: "{{ controller.auth_token }}"
74-
register: ctrl_globals
72+
Cookie: "{{ nginx_controller_auth_token }}"
73+
register: nginx_controller_globals
7574

7675
- name: Copy api_key to a variable
7776
set_fact:
78-
api_key: "{{ ctrl_globals.json.currentStatus.agentSettings.apiKey }}"
77+
nginx_controller_api_key: "{{ nginx_controller_globals.json.currentStatus.agentSettings.apiKey }}"
7978

8079
- name: Install the NGINX Controller agent
8180
include_role:
8281
name: nginxinc.nginx_controller_agent
8382
vars:
84-
api_key: "{{ api_key }}"
83+
nginx_controller_api_key: "{{ nginx_controller_api_key }}"
8584
```
8685
8786
Use
8887
---
8988
9089
```cli
91-
ansible-playbook nginx_controller_agent.yaml -b -i hosts -e "user_email=controller-admin@nginx.com user_password=password controller_fqdn=controller.acme.com"
90+
ansible-playbook nginx_controller_agent.yaml -b -i hosts -e "nginx_controller_user_email=controller-admin@nginx.com nginx_controller_user_password=password nginx_controller_fqdn=controller.acme.com"
9291
```
9392

9493
License

defaults/main.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
---
2-
# These need to be defined to allow the ternary test to execute.
3-
controller_hostname: ""
4-
location: ""
5-
instance_name: ""
62

7-
## The following defaults exist to ensure no breakage of existing implementations that utilize this role. Do not remove.
8-
controller:
9-
user_email: "user@example.com"
10-
user_password: "mySecurePassword"
11-
fqdn: "{{ controller_fqdn }}"
3+
4+
# These need to be defined to allow the ternary test to evaluate.
5+
nginx_controller_hostname: ""
6+
nginx_controller_location: ""
7+
nginx_controller_instance_name: ""

tasks/main.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
assert:
44
that: ("{{ item }} is defined") and ("{{ item }} | length > 0")
55
loop:
6-
- controller.fqdn
7-
- api_key
6+
- nginx_controller_fqdn
7+
- nginx_controller_api_key
88

99
- name: COPY files/nginx-plus-api.conf /etc/nginx/conf.d/ necessary for process monitoring.
1010
copy:
@@ -14,15 +14,15 @@
1414

1515
- name: Download the installer script from NGINX Controller
1616
get_url:
17-
url: "https://{{ controller.fqdn }}:8443/1.4/install/controller/"
17+
url: "https://{{ nginx_controller_fqdn }}:8443/1.4/install/controller/"
1818
dest: "{{ ansible_env.HOME }}/install.sh"
19-
validate_certs: "{{ controller.validate_certs | default(false) }}"
19+
validate_certs: "{{ nginx_controller_validate_certs | default(false) }}"
2020
force: yes
21-
register: controller_return
21+
register: nginx_controller_return
2222

2323
- name: Run the NGINX Controller agent installer
2424
shell: |
25-
API_KEY='{{ api_key }}' \
25+
API_KEY='{{ nginx_controller_api_key }}' \
2626
{{ (controller_hostname | length > 0) | ternary('CONTROLLER_HOSTNAME=' + controller_hostname,'') }} \
2727
{{ (controller_hostname | length > 0) | ternary('STORE_UUID=True','') }} \
2828
sh ./install.sh -y \
@@ -31,11 +31,11 @@
3131
args:
3232
chdir: "{{ ansible_env.HOME }}"
3333
creates: /var/log/nginx-controller/agent.log
34-
register: agent_install
34+
register: nginx_controller_agent_install
3535

3636
- name: Output agent install results
3737
debug:
38-
var: agent_install.stdout_lines
38+
var: nginx_controller_agent_install.stdout_lines
3939

4040
- name: Restart NGINX
4141
service:

vars/main.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
22
## All the below variables are REQUIRED
33

4-
# controller.fqdn: # FQDN of the NGINX Controller instance
5-
# api_key: "" # The API key used to authenticate to NGINX Controller
4+
# nginx_controller_fqdn: # FQDN of the NGINX Controller instance
5+
# nginx_controller_api_key: "" # The API key used to authenticate to NGINX Controller
66

77
## All the below variables are OPTIONAL
88

9-
# controller_hostname: "" # The name of the instance as reflected in NGINX Controller. Must be unique.
10-
# location: # The location in NGINX Controller this instance will be automatically added to. Otherwise the location will be 'unspecified'.
11-
# instance_name: # The name of the instance as reflected in Controller. Must be unique (redundant with controller_hostname).
9+
# nginx_controller_hostname: "" # The name of the instance as reflected in NGINX Controller. Must be unique.
10+
# nginx_controller_location: # The location in NGINX Controller this instance will be automatically added to. Otherwise the location will be 'unspecified'.
11+
# nginx_controller_instance_name: # The name of the instance as reflected in Controller. Must be unique (redundant with controller_hostname).

0 commit comments

Comments
 (0)