forked from CiscoDevNet/sdwan-devops
-
Notifications
You must be signed in to change notification settings - Fork 1
/
detach-template.yml
48 lines (43 loc) · 1.52 KB
/
detach-template.yml
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
- name: Detach Template
hosts: viptela:&virl_hosts
connection: local
gather_facts: no
vars:
vmanage_host: "{{ groups.vmanage_hosts | first }}"
vmanage_mgmt_interface: "{{ hostvars[vmanage_host].mgmt_interface | default('ansible_host') }}"
vmanage_ip: "{{ hostvars[vmanage_host][vmanage_mgmt_interface] | ipaddr('address') }}"
tasks:
- name: Detach template from device
vmanage_device_attachment:
user: "{{ ansible_user }}"
host: "{{ vmanage_ip }}"
password: "{{ ansible_password }}"
device: "{{ inventory_hostname }}"
wait: yes
state: absent
delegate_to: localhost
when: viptela.template is defined
register: attachment_results
#
## - debug:
## var: attachment_results
# - block:
# - name: Attach template to device
# vmanage_device_action_status:
# user: "{{ ansible_user }}"
# host: "{{ vmanage_ip }}"
# password: "{{ ansible_password }}"
# id: "{{ attachment_results.action_id }}"
# when: attachment_results.action_id is defined
# register: action_status
# until: action_status.json.data[0].statusId != 'in_progress'
# retries: 48
# delay: 5
#
#
# - debug:
# msg: "{{ action_status.json.data[0].statusId }}: {{ action_status.json.data[0].currentActivity}}"
# when: attachment_results.changed
# failed_when: action_status.json.data[0].statusId == 'failure'
#
# when: viptela is defined