forked from JNPRAutomate/ansible-junos-evpn-vxlan
-
Notifications
You must be signed in to change notification settings - Fork 2
/
pb.rav.token.fqdn_get.yaml
56 lines (48 loc) · 1.58 KB
/
pb.rav.token.fqdn_get.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
49
50
51
52
53
54
55
56
---
- name: Get FQDN for all VM on Ravello
connection: local
hosts: leaf,spine,fabric,server
gather_facts: no
roles:
- ravello.lib
pre_tasks:
- include_vars: "{{ topology_file }}"
tasks:
###############################
## Get VM ID ###
###############################
- name: Get App ID from Ravello
ravello_get_id:
resource_name: "{{ ravello_ci_app_name }}"
resource_type: applications
token: "{{ ravello_ci_token }}"
register: app
run_once: true
# - debug: var=app
- name: Get VM ID from Ravello
ravello_get_id:
application_id: "{{ app.json.id }}"
resource_type: vms
resource_name: "{{ inventory_hostname }}"
token: "{{ ravello_ci_token }}"
failed_if_not_found: true
register: vm
# - debug: var=vm
- name: Get VM public FQDN
uri:
url: "https://cloud.ravellosystems.com/api/v1/applications/{{ app.json.id }}/vms/{{ vm.json.id }}/fqdn;deployment"
method: GET
status_code: 200
HEADER_Content-Type: 'application/json'
HEADER_Accept: 'application/json'
HEADER_X-Ephemeral-Token-Authorization: "{{ ravello_ci_token }}"
register: ravello_public_ip
- name: Delete previous file
file:
path: "host_vars/{{ inventory_hostname}}/fqdn.yaml"
state: absent
- name: Populate ansible_ssh_host Variable based on FQDN
lineinfile:
create: yes
dest: "host_vars/{{ inventory_hostname}}/fqdn.yaml"
line: "ansible_ssh_host: {{ ravello_public_ip.json.value }}"