6from __future__
import absolute_import, division, print_function
9ANSIBLE_METADATA = {
'metadata_version':
'1.1',
10 'status': [
'preview'],
11 'supported_by':
'certified'}
15module: aci_interface_policy_l2
16short_description: Manage Layer 2 interface policies (l2:IfPol)
18- Manage Layer 2 interface policies on Cisco ACI fabrics.
23 - The name of the Layer 2 interface policy.
29 - The description of the Layer 2 interface policy.
34 - Determines if QinQ
is disabled
or if the port should be considered a core
or edge port.
35 - The APIC defaults to C(disabled) when unset during creation.
37 choices: [ core, disabled, edge ]
40 - Determines
if Virtual Ethernet Port Aggregator
is disabled
or enabled.
41 - The APIC defaults to C(no) when unset during creation.
45 - The scope of the VLAN.
46 - The APIC defaults to C(
global) when unset during creation.
48 choices: [
global, portlocal ]
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- name: APIC Management Information Model reference
59 description: More information about the internal APIC
class B(l2:IfPol).
60 link: https://developer.cisco.com/docs/apic-mim-ref/
62- Dag Wieers (
@dagwieers)
66- aci_interface_policy_l2:
67 host: '{{ hostname }}'
68 username:
'{{ username }}'
69 password:
'{{ password }}'
70 l2_policy:
'{{ l2_policy }}'
71 vlan_scope:
'{{ vlan_policy }}'
72 description:
'{{ description }}'
73 delegate_to: localhost
78 description: The existing configuration from the APIC after the module has finished
86 "descr":
"Production environment",
87 "dn":
"uni/tn-production",
97 description: The error information
as returned
from the APIC
103 "text":
"unknown managed object class foo"
106 description: The raw output returned by the APIC REST API (xml
or json)
107 returned: parse error
109 sample:
'<?xml version="1.0" encoding="UTF-8"?><imdata totalCount="1"><error code="122" text="unknown managed object class foo"/></imdata>'
111 description: The actual/minimal configuration pushed to the APIC
118 "descr":
"Production environment"
123 description: The original configuration
from the APIC before the module has started
131 "descr":
"Production",
132 "dn":
"uni/tn-production",
133 "name":
"production",
142 description: The assembled configuration
from the user-provided parameters
149 "descr":
"Production environment",
155 description: The filter string used
for the request
156 returned: failure
or debug
158 sample: ?rsp-prop-include=config-only
160 description: The HTTP method used
for the request to the APIC
161 returned: failure
or debug
165 description: The HTTP response
from the APIC
166 returned: failure
or debug
168 sample: OK (30 bytes)
170 description: The HTTP status
from the APIC
171 returned: failure
or debug
175 description: The HTTP url used
for the request to the APIC
176 returned: failure
or debug
178 sample: https://10.11.12.13/api/mo/uni/tn-production.json
181from ansible.module_utils.basic import AnsibleModule
182from ansible.module_utils.network.aci.aci import ACIModule, aci_argument_spec
184# Mapping dicts are used to normalize the proposed data to what the APIC expects, which will keep diffs accurate
194 argument_spec.update(
195 l2_policy=dict(type=
'str', aliases=[
'name']),
196 description=dict(type=
'str', aliases=[
'descr']),
197 vlan_scope=dict(type=
'str', choices=[
'global',
'portlocal']),
198 qinq=dict(type=
'str', choices=[
'core',
'disabled',
'edge']),
199 vepa=dict(type=
'bool'),
200 state=dict(type=
'str', default=
'present', choices=[
'absent',
'present',
'query']),
204 argument_spec=argument_spec,
205 supports_check_mode=
True,
207 [
'state',
'absent', [
'l2_policy']],
208 [
'state',
'present', [
'l2_policy']],
214 l2_policy = module.params[
'l2_policy']
215 vlan_scope = module.params[
'vlan_scope']
216 qinq = module.params[
'qinq']
218 qinq = QINQ_MAPPING[qinq]
219 vepa = aci.boolean(module.params[
'vepa'],
'enabled',
'disabled')
220 description = module.params[
'description']
221 state = module.params[
'state']
226 aci_rn=
'infra/l2IfP-{0}'.
format(l2_policy),
227 module_object=l2_policy,
228 target_filter={
'name': l2_policy},
234 if state ==
'present':
240 vlanScope=vlan_scope,
241 qinq=qinq, vepa=vepa,
245 aci.get_diff(aci_class=
'l2IfPol')
249 elif state ==
'absent':
255if __name__ ==
"__main__":