-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask05-aci_create_environment.yaml
More file actions
197 lines (177 loc) · 5.29 KB
/
task05-aci_create_environment.yaml
File metadata and controls
197 lines (177 loc) · 5.29 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# Copyright (c) 2025 Cisco and/or its affiliates.
#
# This software is licensed to you under the terms of the Cisco Sample
# Code License, Version 1.1 (the "License"). You may obtain a copy of the
# License at
#
# https://developer.cisco.com/docs/licenses
#
# All use of the material herein must be in accordance with the terms of
# the License. All rights not expressly granted by the License are
# reserved. Unless required by applicable law or agreed to separately in
# writing, software distributed under the License is distributed on an "AS
# IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
# or implied.
---
- name: Task05 - Create Student Environment
hosts: dcuapic
gather_facts: no
vars:
student_id: '00'
tenant_name: "student{{ student_id }}"
vrf_name: "{{ tenant_name }}_VRF"
ap_name: "{{ tenant_name }}_AP"
bd_name: "{{ tenant_name }}_BD"
subnet_address: "10.2.255.1/24"
tasks:
- set_fact:
aci_login: &aci_login
host: "{{ inventory_hostname }}"
username: "{{ ansible_user }}"
password: "{{ ansible_password }}"
use_ssl: yes
validate_certs: no
######### Tenant Config ##########
- name: Set {{ tenant_name }} Tenant
cisco.aci.aci_tenant:
<<: *aci_login
tenant: "{{ tenant_name }}"
state: present
register: qResult
delegate_to: localhost
- name: Add a new VRF to {{ tenant_name }}
cisco.aci.aci_vrf:
<<: *aci_login
vrf: "{{ vrf_name }}"
tenant: "{{ tenant_name }}"
policy_control_preference: enforced
policy_control_direction: ingress
state: present
delegate_to: localhost
- name: Add AP
cisco.aci.aci_ap:
<<: *aci_login
tenant: "{{ tenant_name }}"
ap: "{{ ap_name }}"
state: present
delegate_to: localhost
- name: Add Bridge Domain
cisco.aci.aci_bd:
<<: *aci_login
tenant: "{{ tenant_name }}"
bd: "{{ bd_name }}"
vrf: "{{ vrf_name }}"
state: present
delegate_to: localhost
- debug:
var: subnet_address
- name: Create a subnet
cisco.aci.aci_bd_subnet:
<<: *aci_login
tenant: "{{ tenant_name }}"
bd: "{{ bd_name }}"
scope: [public,shared]
gateway: "{{ subnet_address }}"
mask: 24
state: present
delegate_to: localhost
##########Check for missing loops variables etc - BEGIN
- name: Add EPGs
cisco.aci.aci_epg:
<<: *aci_login
tenant: "{{ tenant_name }}"
ap: "{{ ap_name }}"
epg: proxy_EPG
bd: "{{ bd_name }}"
preferred_group: yes
state: present
delegate_to: localhost
- name: Add a new physical domain to EPG binding
cisco.aci.aci_epg_to_domain:
<<: *aci_login
tenant: "{{ tenant_name }}"
ap: "{{ ap_name }}"
epg: proxy_EPG
domain: bm_DOM
domain_type: phys
state: present
delegate_to: localhost
- name: Deploy Static Path binding for given EPG
cisco.aci.aci_static_binding_to_epg:
<<: *aci_login
tenant: "{{ tenant_name }}"
ap: "{{ ap_name }}"
epg: proxy_EPG
encap_id: 3399
deploy_immediacy: immediate
interface_mode: trunk
interface_type: switch_port
pod_id: 1
leafs: '311'
interface: '1/1'
state: present
delegate_to: localhost
- name: Deploy Static Path binding for given EPG
cisco.aci.aci_static_binding_to_epg:
<<: *aci_login
tenant: "{{ tenant_name }}"
ap: "{{ ap_name }}"
epg: webserver_EPG
encap_id: 3499
deploy_immediacy: immediate
interface_mode: trunk
interface_type: switch_port
pod_id: 1
leafs: '311'
interface: '1/1'
state: present
delegate_to: localhost
ignore_errors: true
##########Check for missing loops variables etc - End
- name: Add common contract to EPG
cisco.aci.aci_rest:
<<: *aci_login
path: /api/mo/uni/tn-{{ tenant_name }}/ap-{{ ap_name }}/epg-proxy_EPG.json
method: post
content:
{
"fvRsCons": {
"attributes":{
"tnVzBrCPName":"internet_CTR",
"status":"created,modified"
}
}
}
delegate_to: localhost
- name: Add common contract to EPG
cisco.aci.aci_rest:
<<: *aci_login
path: /api/mo/uni/tn-{{ tenant_name }}/ap-{{ ap_name }}/epg-proxy_EPG.json
method: post
content:
{
"fvRsCons": {
"attributes":{
"tnVzBrCPName":"dcu_CTR",
"status":"created,modified"
}
}
}
delegate_to: localhost
- name: Add common contract to EPG
cisco.aci.aci_rest:
<<: *aci_login
path: /api/mo/uni/tn-{{ tenant_name }}/ap-{{ ap_name }}/epg-webserver_EPG.json
method: post
content:
{
"fvRsProv": {
"attributes":{
"tnVzBrCPName":"dcu_CTR",
"status":"created,modified"
}
}
}
delegate_to: localhost
ignore_errors: true
...