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_port_channel
16short_description: Manage port channel interface policies (lacp:LagPol)
18- Manage port channel interface policies on Cisco ACI fabrics.
23 - Name of the port channel.
29 - The description for the port channel.
35 - Accepted values range between 1
and 16.
36 - The APIC defaults to C(16) when unset during creation.
41 - Accepted values range between 1
and 16.
42 - The APIC defaults to C(1) when unset during creation.
46 - Port channel interface policy mode.
47 - Determines the LACP method to use
for forming port-channels.
48 - The APIC defaults to C(off) when unset during creation.
50 choices: [ active, mac-pin, mac-pin-nicload,
'off', passive ]
53 - Determines
if Fast Select
is enabled
for Hot Standby Ports.
54 - This makes up the LACP Policy Control Policy;
if one setting
is defined, then all other Control Properties
55 left undefined
or set to false will
not exist after the task
is ran.
56 - The APIC defaults to C(yes) when unset during creation.
60 - Determines
if Graceful Convergence
is enabled.
61 - This makes up the LACP Policy Control Policy;
if one setting
is defined, then all other Control Properties
62 left undefined
or set to false will
not exist after the task
is ran.
63 - The APIC defaults to C(yes) when unset during creation.
67 - Determines
if Load Defer
is enabled.
68 - This makes up the LACP Policy Control Policy;
if one setting
is defined, then all other Control Properties
69 left undefined
or set to false will
not exist after the task
is ran.
70 - The APIC defaults to C(no) when unset during creation.
74 - Determines
if Suspend Individual
is enabled.
75 - This makes up the LACP Policy Control Policy;
if one setting
is defined, then all other Control Properties
76 left undefined
or set to false will
not exist after the task
is ran.
77 - The APIC defaults to C(yes) when unset during creation.
81 - Determines
if Symmetric Hashing
is enabled.
82 - This makes up the LACP Policy Control Policy;
if one setting
is defined, then all other Control Properties
83 left undefined
or set to false will
not exist after the task
is ran.
84 - The APIC defaults to C(no) when unset during creation.
88 - Use C(present)
or C(absent)
for adding
or removing.
89 - Use C(query)
for listing an object
or multiple objects.
91 choices: [ absent, present, query ]
93extends_documentation_fragment: aci
95- name: APIC Management Information Model reference
96 description: More information about the internal APIC
class B(lacp:LagPol).
97 link: https://developer.cisco.com/docs/apic-mim-ref/
99- Dag Wieers (
@dagwieers)
103- aci_interface_policy_port_channel:
104 host: '{{ inventory_hostname }}'
105 username:
'{{ username }}'
106 password:
'{{ password }}'
107 port_channel:
'{{ port_channel }}'
108 description:
'{{ description }}'
109 min_links:
'{{ min_links }}'
110 max_links:
'{{ max_links }}'
112 delegate_to: localhost
117 description: The existing configuration from the APIC after the module has finished
125 "descr":
"Production environment",
126 "dn":
"uni/tn-production",
127 "name":
"production",
136 description: The error information
as returned
from the APIC
142 "text":
"unknown managed object class foo"
145 description: The raw output returned by the APIC REST API (xml
or json)
146 returned: parse error
148 sample:
'<?xml version="1.0" encoding="UTF-8"?><imdata totalCount="1"><error code="122" text="unknown managed object class foo"/></imdata>'
150 description: The actual/minimal configuration pushed to the APIC
157 "descr":
"Production environment"
162 description: The original configuration
from the APIC before the module has started
170 "descr":
"Production",
171 "dn":
"uni/tn-production",
172 "name":
"production",
181 description: The assembled configuration
from the user-provided parameters
188 "descr":
"Production environment",
194 description: The filter string used
for the request
195 returned: failure
or debug
197 sample: ?rsp-prop-include=config-only
199 description: The HTTP method used
for the request to the APIC
200 returned: failure
or debug
204 description: The HTTP response
from the APIC
205 returned: failure
or debug
207 sample: OK (30 bytes)
209 description: The HTTP status
from the APIC
210 returned: failure
or debug
214 description: The HTTP url used
for the request to the APIC
215 returned: failure
or debug
217 sample: https://10.11.12.13/api/mo/uni/tn-production.json
220from ansible.module_utils.basic import AnsibleModule
221from ansible.module_utils.network.aci.aci import ACIModule, aci_argument_spec
226 argument_spec.update(
227 port_channel=dict(type='str', aliases=[
'name']),
228 description=dict(type=
'str', aliases=[
'descr']),
229 min_links=dict(type=
'int'),
230 max_links=dict(type=
'int'),
231 mode=dict(type=
'str', choices=[
'active',
'mac-pin',
'mac-pin-nicload',
'off',
'passive']),
232 fast_select=dict(type=
'bool'),
233 graceful_convergence=dict(type=
'bool'),
234 load_defer=dict(type=
'bool'),
235 suspend_individual=dict(type=
'bool'),
236 symmetric_hash=dict(type=
'bool'),
237 state=dict(type=
'str', default=
'present', choices=[
'absent',
'present',
'query']),
241 argument_spec=argument_spec,
242 supports_check_mode=
True,
244 [
'state',
'absent', [
'port_channel']],
245 [
'state',
'present', [
'port_channel']],
249 port_channel = module.params[
'port_channel']
250 description = module.params[
'description']
251 min_links = module.params[
'min_links']
252 if min_links
is not None and min_links
not in range(1, 17):
253 module.fail_json(msg=
'The "min_links" must be a value between 1 and 16')
254 max_links = module.params[
'max_links']
255 if max_links
is not None and max_links
not in range(1, 17):
256 module.fail_json(msg=
'The "max_links" must be a value between 1 and 16')
257 mode = module.params[
'mode']
258 state = module.params[
'state']
262 if module.params[
'fast_select']
is True:
263 ctrl.append(
'fast-sel-hot-stdby')
264 if module.params[
'graceful_convergence']
is True:
265 ctrl.append(
'graceful-conv')
266 if module.params[
'load_defer']
is True:
267 ctrl.append(
'load-defer')
268 if module.params[
'suspend_individual']
is True:
269 ctrl.append(
'susp-individual')
270 if module.params[
'symmetric_hash']
is True:
271 ctrl.append(
'symmetric-hash')
275 ctrl =
",".join(ctrl)
280 aci_class=
'lacpLagPol',
281 aci_rn=
'infra/lacplagp-{0}'.
format(port_channel),
282 module_object=port_channel,
283 target_filter={
'name': port_channel},
289 if state ==
'present':
291 aci_class=
'lacpLagPol',
302 aci.get_diff(aci_class=
'lacpLagPol')
306 elif state ==
'absent':
312if __name__ ==
"__main__":