@@ -35,52 +35,59 @@ Example Playbook
3535To use this role you can create a playbook such as the following:
3636
3737``` yaml
38+ ---
3839- hosts : localhost
39- gather_facts : yes
40+ gather_facts : false
41+ connection : local
42+
4043 vars :
4144 nginx_controller_user_email : " user@example.com"
4245 nginx_controller_user_password : " mySecurePassword"
4346 nginx_controller_fqdn : " controller.mydomain.com"
4447 nginx_controller_validate_certs : false
4548
4649 tasks :
47- - name : Upgrade your packages
48- apt :
49- update_cache : yes
50- upgrade : yes
51-
52- - name : Install minimal support for python2 for the NGINX Controller agent install script
53- apt :
54- name : " {{ item }}"
55- state : present
56- loop :
57- - python-minimal
58- - libxerces-c3.2
59-
60- - name : Retrieve the NGINX Controller auth token
61- include_role :
62- name : nginxinc.nginx_controller_generate_token
63-
64- - name : Get NGINX Controller API key for agent registration
65- uri :
66- url : " https://{{ nginx_controller_fqdn }}/api/v1/platform/global"
67- method : " GET"
68- return_content : yes
69- status_code : 200
70- validate_certs : " {{ nginx_controller_validate_certs | default(false) }}"
71- headers :
72- Cookie : " {{ nginx_controller_auth_token }}"
73- register : nginx_controller_globals
74-
75- - name : Copy api_key to a variable
76- set_fact :
77- nginx_controller_api_key : " {{ nginx_controller_globals.json.currentStatus.agentSettings.apiKey }}"
78-
79- - name : Install the NGINX Controller agent
80- include_role :
81- name : nginxinc.nginx_controller_agent
82- vars :
83- nginx_controller_api_key : " {{ nginx_controller_api_key }}"
50+ - include_role :
51+ name : nginxinc.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 : nginx_controller_globals
63+
64+ - name : Copy api_key to a variable
65+ set_fact :
66+ nginx_controller_api_key : " {{nginx_controller_globals.json.currentStatus.agentSettings.apiKey}}"
67+
68+ - hosts : loadbalancers
69+ remote_user : ubuntu
70+ become : true
71+ become_method : sudo
72+ gather_facts : yes
73+
74+ 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_agent
87+ vars :
88+ nginx_controller_hostname : " {{ ansible_facts['fqdn'] }}"
89+ # instance_name: "{{ ansible_facts['fqdn'] }}"
90+ # location:
8491```
8592
8693You can then run ` ansible-playbook nginx_controller_agent.yaml ` to execute the playbook.
0 commit comments