7from __future__
import absolute_import, division, print_function
10ANSIBLE_METADATA = {
'metadata_version':
'1.1',
11 'status': [
'preview'],
12 'supported_by':
'certified'}
16module: aci_interface_policy_leaf_policy_group
17short_description: Manage fabric interface policy leaf policy groups (infra:AccBndlGrp, infra:AccPortGrp)
19- Manage fabric interface policy leaf policy groups on Cisco ACI fabrics.
24 - Name of the leaf policy group to be added/deleted.
26 aliases: [ name, policy_group_name ]
29 - Description for the leaf policy group to be created.
34 - Selector
for the type of leaf policy group we want to create.
35 - C(leaf)
for Leaf Access Port Policy Group
36 - C(link)
for Port Channel (PC)
37 - C(node)
for Virtual Port Channel (VPC)
40 choices: [ leaf, link, node ]
41 aliases: [ lag_type_name ]
44 - Choice of link_level_policy to be used
as part of the leaf policy group to be created.
46 aliases: [ link_level_policy_name ]
49 - Choice of cdp_policy to be used
as part of the leaf policy group to be created.
51 aliases: [ cdp_policy_name ]
54 - Choice of mcp_policy to be used
as part of the leaf policy group to be created.
56 aliases: [ mcp_policy_name ]
59 - Choice of lldp_policy to be used
as part of the leaf policy group to be created.
61 aliases: [ lldp_policy_name ]
64 - Choice of stp_interface_policy to be used
as part of the leaf policy group to be created.
66 aliases: [ stp_interface_policy_name ]
67 egress_data_plane_policing_policy:
69 - Choice of egress_data_plane_policing_policy to be used
as part of the leaf policy group to be created.
71 aliases: [ egress_data_plane_policing_policy_name ]
72 ingress_data_plane_policing_policy:
74 - Choice of ingress_data_plane_policing_policy to be used
as part of the leaf policy group to be created.
76 aliases: [ ingress_data_plane_policing_policy_name ]
77 priority_flow_control_policy:
79 - Choice of priority_flow_control_policy to be used
as part of the leaf policy group to be created.
81 aliases: [ priority_flow_control_policy_name ]
82 fibre_channel_interface_policy:
84 - Choice of fibre_channel_interface_policy to be used
as part of the leaf policy group to be created.
86 aliases: [ fibre_channel_interface_policy_name ]
89 - Choice of slow_drain_policy to be used
as part of the leaf policy group to be created.
91 aliases: [ slow_drain_policy_name ]
94 - Choice of port_channel_policy to be used
as part of the leaf policy group to be created.
96 aliases: [ port_channel_policy_name ]
99 - Choice of monitoring_policy to be used
as part of the leaf policy group to be created.
101 aliases: [ monitoring_policy_name ]
102 storm_control_interface_policy:
104 - Choice of storm_control_interface_policy to be used
as part of the leaf policy group to be created.
106 aliases: [ storm_control_interface_policy_name ]
109 - Choice of l2_interface_policy to be used
as part of the leaf policy group to be created.
111 aliases: [ l2_interface_policy_name ]
112 port_security_policy:
114 - Choice of port_security_policy to be used
as part of the leaf policy group to be created.
116 aliases: [ port_security_policy_name ]
119 - Choice of attached_entity_profile (AEP) to be used
as part of the leaf policy group to be created.
121 aliases: [ aep_name ]
124 - Use C(present)
or C(absent)
for adding
or removing.
125 - Use C(query)
for listing an object
or multiple objects.
127 choices: [ absent, present, query ]
129extends_documentation_fragment: aci
131- When using the module please select the appropriate link_aggregation_type (lag_type).
132 C(link)
for Port Channel(PC), C(node)
for Virtual Port Channel(VPC)
and C(leaf)
for Leaf Access Port Policy Group.
134- name: APIC Management Information Model reference
135 description: More information about the internal APIC classes B(infra:AccBndlGrp)
and B(infra:AccPortGrp).
136 link: https://developer.cisco.com/docs/apic-mim-ref/
138- Bruno Calogero (
@brunocalogero)
142- name: Create a Port Channel (PC) Interface Policy Group
143 aci_interface_policy_leaf_policy_group:
146 password: SomeSecretPassword
148 policy_group: policygroupname
149 description: policygroupname description
150 link_level_policy: whateverlinklevelpolicy
151 fibre_channel_interface_policy: whateverfcpolicy
153 delegate_to: localhost
155- name: Create a Virtual Port Channel (VPC) Interface Policy Group (no description)
156 aci_interface_policy_leaf_policy_group:
159 password: SomeSecretPassword
161 policy_group: policygroupname
162 link_level_policy: whateverlinklevelpolicy
163 fibre_channel_interface_policy: whateverfcpolicy
165 delegate_to: localhost
167- name: Create a Leaf Access Port Policy Group (no description)
168 aci_interface_policy_leaf_policy_group:
171 password: SomeSecretPassword
173 policy_group: policygroupname
174 link_level_policy: whateverlinklevelpolicy
175 fibre_channel_interface_policy: whateverfcpolicy
177 delegate_to: localhost
179- name: Query all Leaf Access Port Policy Groups of type link
180 aci_interface_policy_leaf_policy_group:
183 password: SomeSecretPassword
186 delegate_to: localhost
187 register: query_result
189- name: Query a specific Lead Access Port Policy Group
190 aci_interface_policy_leaf_policy_group:
193 password: SomeSecretPassword
195 policy_group: policygroupname
197 delegate_to: localhost
198 register: query_result
200- name: Delete an Interface policy Leaf Policy Group
201 aci_interface_policy_leaf_policy_group:
204 password: SomeSecretPassword
206 policy_group: policygroupname
208 delegate_to: localhost
213 description: The existing configuration from the APIC after the module has finished
221 "descr":
"Production environment",
222 "dn":
"uni/tn-production",
223 "name":
"production",
232 description: The error information
as returned
from the APIC
238 "text":
"unknown managed object class foo"
241 description: The raw output returned by the APIC REST API (xml
or json)
242 returned: parse error
244 sample:
'<?xml version="1.0" encoding="UTF-8"?><imdata totalCount="1"><error code="122" text="unknown managed object class foo"/></imdata>'
246 description: The actual/minimal configuration pushed to the APIC
253 "descr":
"Production environment"
258 description: The original configuration
from the APIC before the module has started
266 "descr":
"Production",
267 "dn":
"uni/tn-production",
268 "name":
"production",
277 description: The assembled configuration
from the user-provided parameters
284 "descr":
"Production environment",
290 description: The filter string used
for the request
291 returned: failure
or debug
293 sample: ?rsp-prop-include=config-only
295 description: The HTTP method used
for the request to the APIC
296 returned: failure
or debug
300 description: The HTTP response
from the APIC
301 returned: failure
or debug
303 sample: OK (30 bytes)
305 description: The HTTP status
from the APIC
306 returned: failure
or debug
310 description: The HTTP url used
for the request to the APIC
311 returned: failure
or debug
313 sample: https://10.11.12.13/api/mo/uni/tn-production.json
316from ansible.module_utils.basic import AnsibleModule
317from ansible.module_utils.network.aci.aci import ACIModule, aci_argument_spec
322 argument_spec.update(
325 lag_type=dict(type=
'str', required=
True, aliases=[
'lag_type_name'], choices=[
'leaf',
'link',
'node']),
326 policy_group=dict(type=
'str', aliases=[
'name',
'policy_group_name']),
327 description=dict(type=
'str', aliases=[
'descr']),
328 link_level_policy=dict(type=
'str', aliases=[
'link_level_policy_name']),
329 cdp_policy=dict(type=
'str', aliases=[
'cdp_policy_name']),
330 mcp_policy=dict(type=
'str', aliases=[
'mcp_policy_name']),
331 lldp_policy=dict(type=
'str', aliases=[
'lldp_policy_name']),
332 stp_interface_policy=dict(type=
'str', aliases=[
'stp_interface_policy_name']),
333 egress_data_plane_policing_policy=dict(type=
'str', aliases=[
'egress_data_plane_policing_policy_name']),
334 ingress_data_plane_policing_policy=dict(type=
'str', aliases=[
'ingress_data_plane_policing_policy_name']),
335 priority_flow_control_policy=dict(type=
'str', aliases=[
'priority_flow_control_policy_name']),
336 fibre_channel_interface_policy=dict(type=
'str', aliases=[
'fibre_channel_interface_policy_name']),
337 slow_drain_policy=dict(type=
'str', aliases=[
'slow_drain_policy_name']),
338 port_channel_policy=dict(type=
'str', aliases=[
'port_channel_policy_name']),
339 monitoring_policy=dict(type=
'str', aliases=[
'monitoring_policy_name']),
340 storm_control_interface_policy=dict(type=
'str', aliases=[
'storm_control_interface_policy_name']),
341 l2_interface_policy=dict(type=
'str', aliases=[
'l2_interface_policy_name']),
342 port_security_policy=dict(type=
'str', aliases=[
'port_security_policy_name']),
343 aep=dict(type=
'str', aliases=[
'aep_name']),
344 state=dict(type=
'str', default=
'present', choices=[
'absent',
'present',
'query']),
348 argument_spec=argument_spec,
349 supports_check_mode=
True,
351 [
'state',
'absent', [
'policy_group']],
352 [
'state',
'present', [
'policy_group']],
356 policy_group = module.params[
'policy_group']
357 description = module.params[
'description']
358 lag_type = module.params[
'lag_type']
359 link_level_policy = module.params[
'link_level_policy']
360 cdp_policy = module.params[
'cdp_policy']
361 mcp_policy = module.params[
'mcp_policy']
362 lldp_policy = module.params[
'lldp_policy']
363 stp_interface_policy = module.params[
'stp_interface_policy']
364 egress_data_plane_policing_policy = module.params[
'egress_data_plane_policing_policy']
365 ingress_data_plane_policing_policy = module.params[
'ingress_data_plane_policing_policy']
366 priority_flow_control_policy = module.params[
'priority_flow_control_policy']
367 fibre_channel_interface_policy = module.params[
'fibre_channel_interface_policy']
368 slow_drain_policy = module.params[
'slow_drain_policy']
369 port_channel_policy = module.params[
'port_channel_policy']
370 monitoring_policy = module.params[
'monitoring_policy']
371 storm_control_interface_policy = module.params[
'storm_control_interface_policy']
372 l2_interface_policy = module.params[
'l2_interface_policy']
373 port_security_policy = module.params[
'port_security_policy']
374 aep = module.params[
'aep']
375 state = module.params[
'state']
377 if lag_type ==
'leaf':
378 aci_class_name =
'infraAccPortGrp'
379 dn_name =
'accportgrp'
380 class_config_dict = dict(
386 elif lag_type
in (
'link',
'node'):
387 aci_class_name =
'infraAccBndlGrp'
388 dn_name =
'accbundle'
389 class_config_dict = dict(
397 infraRsCdpIfPol=dict(
399 tnCdpIfPolName=cdp_policy,
406 tnFcIfPolName=fibre_channel_interface_policy,
413 tnFabricHIfPolName=link_level_policy,
420 tnL2IfPolName=l2_interface_policy,
425 infraRsL2PortSecurityPol=dict(
427 tnL2PortSecurityPolName=port_security_policy,
434 tnLacpLagPolName=port_channel_policy,
439 infraRsLldpIfPol=dict(
441 tnLldpIfPolName=lldp_policy,
446 infraRsMcpIfPol=dict(
448 tnMcpIfPolName=mcp_policy,
453 infraRsMonIfInfraPol=dict(
455 tnMonInfraPolName=monitoring_policy,
460 infraRsQosEgressDppIfPol=dict(
462 tnQosDppPolName=egress_data_plane_policing_policy,
467 infraRsQosIngressDppIfPol=dict(
469 tnQosDppPolName=ingress_data_plane_policing_policy,
474 infraRsQosPfcIfPol=dict(
476 tnQosPfcIfPolName=priority_flow_control_policy,
481 infraRsQosSdIfPol=dict(
483 tnQosSdIfPolName=slow_drain_policy,
488 infraRsStormctrlIfPol=dict(
490 tnStormctrlIfPolName=storm_control_interface_policy,
495 infraRsStpIfPol=dict(
497 tnStpIfPolName=stp_interface_policy,
505 child_configs.append(dict(
508 tDn=
'uni/infra/attentp-{0}'.
format(aep),
516 aci_class=aci_class_name,
517 aci_rn=
'infra/funcprof/{0}-{1}'.
format(dn_name, policy_group),
518 module_object=policy_group,
519 target_filter={
'name': policy_group,
'lagT': lag_type},
527 'infraRsL2PortSecurityPol',
531 'infraRsMonIfInfraPol',
532 'infraRsQosEgressDppIfPol',
533 'infraRsQosIngressDppIfPol',
534 'infraRsQosPfcIfPol',
536 'infraRsStormctrlIfPol',
543 if state ==
'present':
545 aci_class=aci_class_name,
546 class_config=class_config_dict,
547 child_configs=child_configs,
550 aci.get_diff(aci_class=aci_class_name)
554 elif state ==
'absent':
560if __name__ ==
"__main__":