7from __future__
import absolute_import, division, print_function
10ANSIBLE_METADATA = {
'metadata_version':
'1.1',
11 'status': [
'preview'],
12 'supported_by':
'certified'}
16module: aci_switch_policy_vpc_protection_group
17short_description: Manage switch policy explicit vPC protection groups (fabric:ExplicitGEp, fabric:NodePEp).
19- Manage switch policy explicit vPC protection groups on Cisco ACI fabrics.
24 - The name of the Explicit vPC Protection Group.
27 aliases: [ name, protection_group_name ]
30 - The Explicit vPC Protection Group ID.
36 - The vPC domain policy to be associated with the Explicit vPC Protection Group.
38 aliases: [ vpc_domain_policy_name ]
41 - The ID of the first Leaf Switch
for the Explicit vPC Protection Group.
46 - The ID of the Second Leaf Switch
for the Explicit vPC Protection Group.
51 - Use C(present)
or C(absent)
for adding
or removing.
52 - Use C(query)
for listing an object
or multiple objects.
54 choices: [ absent, present, query ]
56extends_documentation_fragment: aci
58- module: aci_switch_policy_leaf_profile
59- name: APIC Management Information Model reference
60 description: More information about the internal APIC classes B(fabric:ExplicitGEp)
and B(fabric:NodePEp).
61 link: https://developer.cisco.com/docs/apic-mim-ref/
63- Bruno Calogero (
@brunocalogero)
67- name: Add vPC Protection Group
68 aci_switch_policy_vpc_protection_group:
71 password: SomeSecretPassword
72 protection_group: leafPair101-vpcGrp
73 protection_group_id: 6
77 delegate_to: localhost
79- name: Remove Explicit vPC Protection Group
80 aci_switch_policy_vpc_protection_group:
83 password: SomeSecretPassword
84 protection_group: leafPair101-vpcGrp
86 delegate_to: localhost
88- name: Query vPC Protection Groups
89 aci_switch_policy_vpc_protection_group:
92 password: SomeSecretPassword
94 delegate_to: localhost
95 register: query_result
97- name: Query our vPC Protection Group
98 aci_switch_policy_vpc_protection_group:
101 password: SomeSecretPassword
102 protection_group: leafPair101-vpcGrp
104 delegate_to: localhost
105 register: query_result
110 description: The existing configuration from the APIC after the module has finished
118 "descr":
"Production environment",
119 "dn":
"uni/tn-production",
120 "name":
"production",
129 description: The error information
as returned
from the APIC
135 "text":
"unknown managed object class foo"
138 description: The raw output returned by the APIC REST API (xml
or json)
139 returned: parse error
141 sample:
'<?xml version="1.0" encoding="UTF-8"?><imdata totalCount="1"><error code="122" text="unknown managed object class foo"/></imdata>'
143 description: The actual/minimal configuration pushed to the APIC
150 "descr":
"Production environment"
155 description: The original configuration
from the APIC before the module has started
163 "descr":
"Production",
164 "dn":
"uni/tn-production",
165 "name":
"production",
174 description: The assembled configuration
from the user-provided parameters
181 "descr":
"Production environment",
187 description: The filter string used
for the request
188 returned: failure
or debug
190 sample: ?rsp-prop-include=config-only
192 description: The HTTP method used
for the request to the APIC
193 returned: failure
or debug
197 description: The HTTP response
from the APIC
198 returned: failure
or debug
200 sample: OK (30 bytes)
202 description: The HTTP status
from the APIC
203 returned: failure
or debug
207 description: The HTTP url used
for the request to the APIC
208 returned: failure
or debug
210 sample: https://10.11.12.13/api/mo/uni/tn-production.json
213from ansible.module_utils.basic import AnsibleModule
214from ansible.module_utils.network.aci.aci import ACIModule, aci_argument_spec
219 argument_spec.update(
220 protection_group=dict(type='str', aliases=[
'name',
'protection_group_name']),
221 protection_group_id=dict(type=
'int', aliases=[
'id']),
222 vpc_domain_policy=dict(type=
'str', aliases=[
'vpc_domain_policy_name']),
223 switch_1_id=dict(type=
'int'),
224 switch_2_id=dict(type=
'int'),
225 state=dict(type=
'str', default=
'present', choices=[
'absent',
'present',
'query']),
229 argument_spec=argument_spec,
230 supports_check_mode=
True,
232 [
'state',
'absent', [
'protection_group']],
233 [
'state',
'present', [
'protection_group',
'protection_group_id',
'switch_1_id',
'switch_2_id']],
237 protection_group = module.params[
'protection_group']
238 protection_group_id = module.params[
'protection_group_id']
239 vpc_domain_policy = module.params[
'vpc_domain_policy']
240 switch_1_id = module.params[
'switch_1_id']
241 switch_2_id = module.params[
'switch_2_id']
242 state = module.params[
'state']
247 aci_class=
'fabricExplicitGEp',
248 aci_rn=
'fabric/protpol/expgep-{0}'.
format(protection_group),
249 module_object=protection_group,
250 target_filter={
'name': protection_group},
252 child_classes=[
'fabricNodePEp',
'fabricNodePEp',
'fabricRsVpcInstPol'],
257 if state ==
'present':
259 aci_class=
'fabricExplicitGEp',
261 name=protection_group,
262 id=protection_group_id,
268 id=
'{0}'.
format(switch_1_id),
275 id=
'{0}'.
format(switch_2_id),
280 fabricRsVpcInstPol=dict(
282 tnVpcInstPolName=vpc_domain_policy,
289 aci.get_diff(aci_class=
'fabricExplicitGEp')
293 elif state ==
'absent':
299if __name__ ==
"__main__":