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_security
16short_description: Manage port security (l2:PortSecurityPol)
18- Manage port security on Cisco ACI fabrics.
23 - The name of the port security.
29 - The description for the contract.
34 - Maximum number of end points.
35 - Accepted values range between C(0)
and C(12000).
36 - The APIC defaults to C(0) when unset during creation.
38 port_security_timeout:
41 - The delay time
in seconds before MAC learning
is re-enabled
42 - Accepted values range between C(60)
and C(3600)
43 - The APIC defaults to C(60) when unset during creation
47 - Use C(present)
or C(absent)
for adding
or removing.
48 - Use C(query)
for listing an object
or multiple objects.
50 choices: [ absent, present, query ]
52extends_documentation_fragment: aci
54- name: APIC Management Information Model reference
55 description: More information about the internal APIC
class B(l2:PortSecurityPol).
56 link: https://developer.cisco.com/docs/apic-mim-ref/
58- Dag Wieers (
@dagwieers)
61# FIXME: Add more, better examples
63- aci_interface_policy_port_security:
64 host: '{{ inventory_hostname }}'
65 username:
'{{ username }}'
66 password:
'{{ password }}'
67 port_security:
'{{ port_security }}'
68 description:
'{{ descr }}'
69 max_end_points:
'{{ max_end_points }}'
70 port_security_timeout:
'{{ port_security_timeout }}'
71 delegate_to: localhost
76 description: The existing configuration from the APIC after the module has finished
84 "descr":
"Production environment",
85 "dn":
"uni/tn-production",
95 description: The error information
as returned
from the APIC
101 "text":
"unknown managed object class foo"
104 description: The raw output returned by the APIC REST API (xml
or json)
105 returned: parse error
107 sample:
'<?xml version="1.0" encoding="UTF-8"?><imdata totalCount="1"><error code="122" text="unknown managed object class foo"/></imdata>'
109 description: The actual/minimal configuration pushed to the APIC
116 "descr":
"Production environment"
121 description: The original configuration
from the APIC before the module has started
129 "descr":
"Production",
130 "dn":
"uni/tn-production",
131 "name":
"production",
140 description: The assembled configuration
from the user-provided parameters
147 "descr":
"Production environment",
153 description: The filter string used
for the request
154 returned: failure
or debug
156 sample: ?rsp-prop-include=config-only
158 description: The HTTP method used
for the request to the APIC
159 returned: failure
or debug
163 description: The HTTP response
from the APIC
164 returned: failure
or debug
166 sample: OK (30 bytes)
168 description: The HTTP status
from the APIC
169 returned: failure
or debug
173 description: The HTTP url used
for the request to the APIC
174 returned: failure
or debug
176 sample: https://10.11.12.13/api/mo/uni/tn-production.json
179from ansible.module_utils.basic import AnsibleModule
180from ansible.module_utils.network.aci.aci import ACIModule, aci_argument_spec
185 argument_spec.update(
186 port_security=dict(type='str', aliases=[
'name']),
187 description=dict(type=
'str', aliases=[
'descr']),
188 max_end_points=dict(type=
'int'),
189 port_security_timeout=dict(type=
'int'),
190 state=dict(type=
'str', default=
'present', choices=[
'absent',
'present',
'query']),
194 argument_spec=argument_spec,
195 supports_check_mode=
True,
197 [
'state',
'absent', [
'port_security']],
198 [
'state',
'present', [
'port_security']],
202 port_security = module.params[
'port_security']
203 description = module.params[
'description']
204 max_end_points = module.params[
'max_end_points']
205 port_security_timeout = module.params[
'port_security_timeout']
206 if max_end_points
is not None and max_end_points
not in range(12001):
207 module.fail_json(msg=
'The "max_end_points" must be between 0 and 12000')
208 if port_security_timeout
is not None and port_security_timeout
not in range(60, 3601):
209 module.fail_json(msg=
'The "port_security_timeout" must be between 60 and 3600')
210 state = module.params[
'state']
215 aci_class=
'l2PortSecurityPol',
216 aci_rn=
'infra/portsecurityP-{0}'.
format(port_security),
217 module_object=port_security,
218 target_filter={
'name': port_security},
224 if state ==
'present':
226 aci_class=
'l2PortSecurityPol',
230 maximum=max_end_points,
234 aci.get_diff(aci_class=
'l2PortSecurityPol')
238 elif state ==
'absent':
244if __name__ ==
"__main__":