forked from brianehlert/ansible-nginx-controller-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
5_nginx_controller_agent_3x.yaml
48 lines (41 loc) · 1.33 KB
/
5_nginx_controller_agent_3x.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
---
# ansible-playbook nginx_controller_agent.yaml -i loadbalancers -e "[email protected] admin_password=userPassword"
# ansible-playbook nginx_controller_agent_3x.yaml -e "@nginx_install_controller_vars.yaml"
- hosts: loadbalancers
remote_user: ubuntu
become: true
become_method: sudo
gather_facts: yes
tasks:
# - name: upgrade packages here.
# apt:
# update_cache: yes
# upgrade: yes
# - name: install minimal support for python2 for Agent install script
# apt:
# name: "{{ packages }}"
# state: present
# vars:
# packages:
# - python-minimal
# - libxerces-c3.2
- include_role:
name: ansible_role_nginx_controller_generate_token
- name: Get controller api key for agent registration
uri:
url: "https://{{nginx_controller_fqdn}}/api/v1/platform/global"
method: "GET"
return_content: yes
status_code: 200
validate_certs: false
headers:
Cookie: "{{nginx_controller_auth_token}}"
register: ctrl_globals
- name: Copy api_key to a variable
set_fact:
nginx_controller_api_key: "{{ctrl_globals.json.currentStatus.agentSettings.apiKey}}"
- name: install the agent
include_role:
name: ansible-role-nginx-controller-agent
vars:
nginx_controller_location: "{{ hostvars[inventory_hostname].location }}"