-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclone_interface_epg.yaml
More file actions
153 lines (134 loc) · 5.22 KB
/
clone_interface_epg.yaml
File metadata and controls
153 lines (134 loc) · 5.22 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
---
- name: 'clone epg configuration to a new created EPG'
hosts: all
gather_facts: no
connection: local
tasks:
- name: LOGIN TO FABRIC
uri:
url: "https://{{ inventory_hostname }}/api/aaaLogin.json"
method: POST
body_format: json
body:
{
"aaaUser":{
"attributes":{
"name":"{{ user }}",
"pwd":"{{ pass }}"
}
}
}
force_basic_auth: yes
validate_certs: no
register: data_login
- name: "debug get all configs of the EPG"
uri:
url: 'https://{{ inventory_hostname }}/api/mo/uni/tn-{{ tenant }}/ap-{{ ap }}/epg-{{ cloned_epg }}.json?query-target=subtree'
# url: 'https://{{ inventory_hostname }}/api/mo/uni/tn-{{ tenant }}/ap-{{ ap }}/epg-{{ epg }}.json?query-target=subtree&target-subtree-class=fvRsPathAtt'
method: GET
headers:
Cookie: "{{ data_login.set_cookie }}"
return_content: yes
register: epg_config
- name : "test savegarde de la config des fvAEPG"
copy: content="{{ epg_config }}" dest=/var/lib/awx/projects/aci/fvAEPg_v2.json
- name: "get the bridge domain of the PEG you want to clone"
uri:
# url: 'https://{{ inventory_hostname }}/api/mo/uni/tn-{{ tenant }}/ap-{{ ap }}/epg-{{ epg }}.json?query-target=subtree'
url: 'https://{{ inventory_hostname }}/api/mo/uni/tn-{{ tenant }}/ap-{{ ap }}/epg-{{ cloned_epg }}.json?query-target=subtree&target-subtree-class=fvRsBd'
method: GET
headers:
Cookie: "{{ data_login.set_cookie }}"
return_content: yes
register: epg_config_Bd
- name: "create the the epg"
uri:
url: 'https://{{ inventory_hostname }}/api/mo/uni/tn-{{ tenant }}/ap-{{ ap }}/epg-{{ new_epg }}.json'
method: POST
headers:
Cookie: "{{ data_login.set_cookie }}"
body_format: json
body:
{
"fvAEPg": {
"attributes":{
"dn": "uni/tn-{{ tenant }}/ap-{{ ap }}/epg-{{ new_epg }}",
"name": "{{ new_epg }}",
"rn": "epg-{{ new_epg }}",
"status": "created,modified"
},
"children": [{
"fvRsBd": {
"attributes": {
"tnFvBDName": "{{ item.fvRsBd.attributes.tnFvBDName }}",
"status": "created,modified"
},
"children":[]
}
}]
}
}
return_content: yes
with_items: "{{ epg_config_Bd.json.imdata }}"
- name: "get configs of the EPG domain with class query"
uri:
# url: 'https://{{ inventory_hostname }}/api/mo/uni/tn-{{ tenant }}/ap-{{ ap }}/epg-{{ epg }}.json?query-target=subtree'
url: 'https://{{ inventory_hostname }}/api/mo/uni/tn-{{ tenant }}/ap-{{ ap }}/epg-{{ cloned_epg }}.json?query-target=subtree&target-subtree-class=fvRsDomAtt'
method: GET
headers:
Cookie: "{{ data_login.set_cookie }}"
return_content: yes
register: epg_config_dom
- name: "bind the new EPG to the domain of the cloned EPG"
uri:
url: 'https://{{ inventory_hostname }}/api/mo/uni/tn-{{ tenant }}/ap-{{ ap }}/epg-{{ new_epg }}.json'
method: POST
headers:
Cookie: "{{ data_login.set_cookie }}"
body_format: json
body:
{
"fvRsDomAtt": {
"attributes":{
"resImedcy": "immediate",
"tDn": "{{ item.fvRsDomAtt.attributes.tDn }}",
"status": "created,modified"
},
"children": []
}
}
return_content: yes
with_items: "{{ epg_config_dom.json.imdata }}"
- name: "get configs of the EPG interface with class query"
uri:
# url: 'https://{{ inventory_hostname }}/api/mo/uni/tn-{{ tenant }}/ap-{{ ap }}/epg-{{ epg }}.json?query-target=subtree'
url: 'https://{{ inventory_hostname }}/api/mo/uni/tn-{{ tenant }}/ap-{{ ap }}/epg-{{ cloned_epg }}.json?query-target=subtree&target-subtree-class=fvRsPathAtt'
method: GET
headers:
Cookie: "{{ data_login.set_cookie }}"
return_content: yes
register: epg_config_int
- name: "get configs of the EPG"
uri:
url: 'https://{{ inventory_hostname }}/api/mo/uni/tn-{{ tenant }}/ap-{{ ap }}/epg-{{ new_epg }}.json'
method: POST
headers:
Cookie: "{{ data_login.set_cookie }}"
body_format: json
body:
{
"fvRsPathAtt": {
"attributes":{
"encap": "vlan-{{ vlan }}",
"tDn": "{{ item.fvRsPathAtt.attributes.tDn }}",
"mode": "{{ item.fvRsPathAtt.attributes.mode }}",
"instrImedcy": "{{ item.fvRsPathAtt.attributes.instrImedcy }}",
"status": "created,modified"
},
"children": []
}
}
return_content: yes
with_items: "{{ epg_config_int.json.imdata }}"
- name : "test savegarde de la config des fvAEPG"
copy: content="{{ epg_config }}" dest=/var/lib/awx/projects/aci/fvAEPg_v2.json