6from __future__
import absolute_import, division, print_function
9ANSIBLE_METADATA = {
'metadata_version':
'1.1',
10 'status': [
'preview'],
11 'supported_by':
'certified'}
16short_description: Manage End Point Groups (EPG) objects (fv:AEPg)
18- Manage End Point Groups (EPG) on Cisco ACI fabrics.
23 - Name of an existing tenant.
25 aliases: [ tenant_name ]
28 - Name of an existing application network profile, that will contain the EPGs.
31 aliases: [ app_profile, app_profile_name ]
34 - Name of the end point group.
37 aliases: [ epg_name, name ]
40 - Name of the bridge domain being associated with the EPG.
42 aliases: [ bd_name, bridge_domain ]
46 - The APIC defaults to C(unspecified) when unset during creation.
48 choices: [ level1, level2, level3, unspecified ]
51 - The Intra EPG Isolation.
52 - The APIC defaults to C(unenforced) when unset during creation.
54 choices: [ enforced, unenforced ]
57 - Description
for the EPG.
62 - The forwarding control used by the EPG.
63 - The APIC defaults to C(none) when unset during creation.
65 choices: [ none, proxy-arp ]
68 - Whether ot
not the EPG
is part of the Preferred Group
and can communicate without contracts.
69 - This
is very convenient
for migration scenarios,
or when ACI
is used
for network automation but
not for policy.
70 - The APIC defaults to C(no) when unset during creation.
75 - Use C(present)
or C(absent)
for adding
or removing.
76 - Use C(query)
for listing an object
or multiple objects.
78 choices: [ absent, present, query ]
80extends_documentation_fragment: aci
82- The C(tenant)
and C(app_profile) used must exist before using this module
in your playbook.
83 The M(aci_tenant)
and M(aci_ap) modules can be used
for this.
87- name: APIC Management Information Model reference
88 description: More information about the internal APIC
class B(fv:AEPg).
89 link: https://developer.cisco.com/docs/apic-mim-ref/
91- Swetha Chunduri (
@schunduri)
99 password: SomeSecretPassword
103 description: Web Intranet EPG
107 delegate_to: localhost
112 password: SomeSecretPassword
115 epg: "{{ item.epg }}"
116 description: Ticketing EPG
118 priority: unspecified
119 intra_epg_isolation: unenforced
121 delegate_to: localhost
132 password: SomeSecretPassword
135 app_profile: intranet
138 delegate_to: localhost
144 password: SomeSecretPassword
149 delegate_to: localhost
150 register: query_result
152- name: Query all EPGs
156 password: SomeSecretPassword
158 delegate_to: localhost
159 register: query_result
161- name: Query all EPGs
with a Specific Name
165 password: SomeSecretPassword
169 delegate_to: localhost
170 register: query_result
172- name: Query all EPGs of an App Profile
176 password: SomeSecretPassword
180 delegate_to: localhost
181 register: query_result
186 description: The existing configuration from the APIC after the module has finished
194 "descr":
"Production environment",
195 "dn":
"uni/tn-production",
196 "name":
"production",
205 description: The error information
as returned
from the APIC
211 "text":
"unknown managed object class foo"
214 description: The raw output returned by the APIC REST API (xml
or json)
215 returned: parse error
217 sample:
'<?xml version="1.0" encoding="UTF-8"?><imdata totalCount="1"><error code="122" text="unknown managed object class foo"/></imdata>'
219 description: The actual/minimal configuration pushed to the APIC
226 "descr":
"Production environment"
231 description: The original configuration
from the APIC before the module has started
239 "descr":
"Production",
240 "dn":
"uni/tn-production",
241 "name":
"production",
250 description: The assembled configuration
from the user-provided parameters
257 "descr":
"Production environment",
263 description: The filter string used
for the request
264 returned: failure
or debug
266 sample: ?rsp-prop-include=config-only
268 description: The HTTP method used
for the request to the APIC
269 returned: failure
or debug
273 description: The HTTP response
from the APIC
274 returned: failure
or debug
276 sample: OK (30 bytes)
278 description: The HTTP status
from the APIC
279 returned: failure
or debug
283 description: The HTTP url used
for the request to the APIC
284 returned: failure
or debug
286 sample: https://10.11.12.13/api/mo/uni/tn-production.json
289from ansible.module_utils.basic import AnsibleModule
290from ansible.module_utils.network.aci.aci import ACIModule, aci_argument_spec
295 argument_spec.update(
296 epg=dict(type='str', aliases=[
'epg_name',
'name']),
297 bd=dict(type=
'str', aliases=[
'bd_name',
'bridge_domain']),
298 ap=dict(type=
'str', aliases=[
'app_profile',
'app_profile_name']),
299 tenant=dict(type=
'str', aliases=[
'tenant_name']),
300 description=dict(type=
'str', aliases=[
'descr']),
301 priority=dict(type=
'str', choices=[
'level1',
'level2',
'level3',
'unspecified']),
302 intra_epg_isolation=dict(choices=[
'enforced',
'unenforced']),
303 fwd_control=dict(type=
'str', choices=[
'none',
'proxy-arp']),
304 preferred_group=dict(type=
'bool'),
305 state=dict(type=
'str', default=
'present', choices=[
'absent',
'present',
'query']),
309 argument_spec=argument_spec,
310 supports_check_mode=
True,
312 [
'state',
'absent', [
'ap',
'epg',
'tenant']],
313 [
'state',
'present', [
'ap',
'epg',
'tenant']],
319 epg = module.params[
'epg']
320 bd = module.params[
'bd']
321 description = module.params[
'description']
322 priority = module.params[
'priority']
323 intra_epg_isolation = module.params[
'intra_epg_isolation']
324 fwd_control = module.params[
'fwd_control']
325 preferred_group = aci.boolean(module.params[
'preferred_group'],
'include',
'exclude')
326 state = module.params[
'state']
327 tenant = module.params[
'tenant']
328 ap = module.params[
'ap']
332 aci_class=
'fvTenant',
333 aci_rn=
'tn-{0}'.
format(tenant),
334 module_object=tenant,
335 target_filter={
'name': tenant},
339 aci_rn=
'ap-{0}'.
format(ap),
341 target_filter={
'name': ap},
345 aci_rn=
'epg-{0}'.
format(epg),
347 target_filter={
'name': epg},
349 child_classes=[
'fvRsBd'],
354 if state ==
'present':
361 pcEnfPref=intra_epg_isolation,
363 prefGrMemb=preferred_group,
374 aci.get_diff(aci_class=
'fvAEPg')
378 elif state ==
'absent':
384if __name__ ==
"__main__":