forked from CiscoSE/DEVWKS-3155-CL22
-
Notifications
You must be signed in to change notification settings - Fork 0
/
02-add-switches.yaml
92 lines (82 loc) · 2.96 KB
/
02-add-switches.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#
# Add switch and set role with REST API
#
- hosts: dcnm
gather_facts: false
connection: ansible.netcommon.httpapi
collections:
- cisco.dcnm
vars:
# Need to extend timeouts because discovery process is slow
ansible_command_timeout: 1800
ansible_connect_timeout: 1800
switch_username: "{{ lookup('env', 'SWITCH_USER') }}"
switch_password: "{{ lookup('env', 'SWITCH_PASS') }}"
switch_data: {
"seedIP": "{{ site1.leaf1_ip }},{{ site1.spine1_ip }},{{ site1.bgw1_ip }}",
"preserveConfig": "true",
"username": "{{ switch_username }}",
"password": "{{ switch_password }}",
"switches": [
{
"deviceIndex": "{{ site1.leaf1_name }}-n9k({{ site1.leaf1_serial }})",
"sysName": "{{ site1.leaf1_name }}",
"ipaddr": "{{ site1.leaf1_ip }}",
"platform": "N9K-9000v",
"serial_number": "{{ site1.leaf1_serial }}",
"version": "9.2(3)"
},
{
"deviceIndex": "{{ site1.spine1_name }}-n9k({{ site1.spine1_serial }})",
"sysName": "{{ site1.spine1_name }}",
"ipaddr": "{{ site1.spine1_ip }}",
"platform": "N9K-9000v",
"serial_number": "{{ site1.spine1_serial }}",
"version": "9.2(3)"
},
{
"deviceIndex": "{{ site1.bgw1_name }}-n9k({{ site1.bgw1_serial }})",
"sysName": "{{ site1.bgw1_name }}",
"ipaddr": "{{ site1.bgw1_ip }}",
"platform": "N9K-9000v",
"serial_number": "{{ site1.bgw1_serial }}",
"version": "9.2(3)"
}
]
}
role_data:
- {
"serialNumber": "{{ site1.bgw1_serial }}",
"role": "{{ site1.bgw1_role }}"
}
- {
"serialNumber": "{{ site1.spine1_serial }}",
"role": "{{ site1.spine1_role }}"
}
- {
"serialNumber": "{{ site1.leaf1_serial }}",
"role": "{{ site1.leaf1_role }}"
}
tasks:
# Add switches to the fabric
- name: "Add switches to the Classic fabric: '{{ site1.fabric_name }}'"
dcnm_rest:
method: POST
path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ site1.fabric_name }}/inventory/discover"
data: "{{ switch_data | to_json }}"
ignore_errors: true
# Set the switch roles
- name: "Set switch roles on Classic fabric: '{{ site1.fabric_name }}'"
dcnm_rest:
method: POST
path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/switches/roles"
data: "{{ role_data | to_json }}"
# Save and Deploy
- name: Save changes to "{{ site1.fabric_name }}"
dcnm_rest:
method: POST
path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ site1.fabric_name }}/config-save"
- name: Deploy changes to "{{ site1.fabric_name }}"
dcnm_rest:
method: POST
path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ site1.fabric_name }}/config-deploy"