6from __future__
import absolute_import, division, print_function
9ANSIBLE_METADATA = {
'metadata_version':
'1.1',
10 'status': [
'preview'],
11 'supported_by':
'certified'}
15module: aci_tenant_ep_retention_policy
16short_description: Manage End Point (EP) retention protocol policies (fv:EpRetPol)
18- Manage End Point (EP) retention protocol policies on Cisco ACI fabrics.
23 - The name of an existing tenant.
25 aliases: [ tenant_name ]
28 - The name of the end point retention policy.
30 aliases: [ epr_name, name ]
33 - Bounce entry aging interval in seconds.
34 - Accepted values range between C(150)
and C(65535); 0
is used
for infinite.
35 - The APIC defaults to C(630) when unset during creation.
39 - Determines
if the bounce entries are installed by RARP Flood
or COOP Protocol.
40 - The APIC defaults to C(coop) when unset during creation.
42 choices: [ coop, flood ]
45 - Hold interval
in seconds.
46 - Accepted values range between C(5)
and C(65535).
47 - The APIC defaults to C(300) when unset during creation.
51 - Local end point aging interval
in seconds.
52 - Accepted values range between C(120)
and C(65535); 0
is used
for infinite.
53 - The APIC defaults to C(900) when unset during creation.
57 - Remote end point aging interval
in seconds.
58 - Accepted values range between C(120)
and C(65535); 0
is used
for infinite.
59 - The APIC defaults to C(300) when unset during creation.
63 - Move frequency per second.
64 - Accepted values range between C(0)
and C(65535); 0
is used
for none.
65 - The APIC defaults to C(256) when unset during creation.
69 - Description
for the End point retention policy.
74 - Use C(present)
or C(absent)
for adding
or removing.
75 - Use C(query)
for listing an object
or multiple objects.
77 choices: [ absent, present, query ]
79extends_documentation_fragment: aci
81- The C(tenant) used must exist before using this module
in your playbook.
82 The M(aci_tenant) module can be used
for this.
85- name: APIC Management Information Model reference
86 description: More information about the internal APIC
class B(fv:EpRetPol).
87 link: https://developer.cisco.com/docs/apic-mim-ref/
89- Swetha Chunduri (
@schunduri)
93- name: Add a new EPR policy
94 aci_tenant_ep_retention_policy:
97 password: SomeSecretPassword
102 local_ep_interval: 900
103 remote_ep_interval: 300
107 delegate_to: localhost
109- name: Remove an EPR policy
110 aci_tenant_ep_retention_policy:
113 password: SomeSecretPassword
117 delegate_to: localhost
119- name: Query an EPR policy
120 aci_tenant_ep_retention_policy:
123 password: SomeSecretPassword
127 delegate_to: localhost
128 register: query_result
130- name: Query all EPR policies
131 aci_tenant_ep_retention_policy:
134 password: SomeSecretPassword
136 delegate_to: localhost
137 register: query_result
142 description: The existing configuration from the APIC after the module has finished
150 "descr":
"Production environment",
151 "dn":
"uni/tn-production",
152 "name":
"production",
161 description: The error information
as returned
from the APIC
167 "text":
"unknown managed object class foo"
170 description: The raw output returned by the APIC REST API (xml
or json)
171 returned: parse error
173 sample:
'<?xml version="1.0" encoding="UTF-8"?><imdata totalCount="1"><error code="122" text="unknown managed object class foo"/></imdata>'
175 description: The actual/minimal configuration pushed to the APIC
182 "descr":
"Production environment"
187 description: The original configuration
from the APIC before the module has started
195 "descr":
"Production",
196 "dn":
"uni/tn-production",
197 "name":
"production",
206 description: The assembled configuration
from the user-provided parameters
213 "descr":
"Production environment",
219 description: The filter string used
for the request
220 returned: failure
or debug
222 sample: ?rsp-prop-include=config-only
224 description: The HTTP method used
for the request to the APIC
225 returned: failure
or debug
229 description: The HTTP response
from the APIC
230 returned: failure
or debug
232 sample: OK (30 bytes)
234 description: The HTTP status
from the APIC
235 returned: failure
or debug
239 description: The HTTP url used
for the request to the APIC
240 returned: failure
or debug
242 sample: https://10.11.12.13/api/mo/uni/tn-production.json
245from ansible.module_utils.basic import AnsibleModule
246from ansible.module_utils.network.aci.aci import ACIModule, aci_argument_spec
248BOUNCE_TRIG_MAPPING = dict(
256 argument_spec.update(
257 tenant=dict(type=
'str', aliases=[
'tenant_name']),
258 epr_policy=dict(type=
'str', aliases=[
'epr_name',
'name']),
259 bounce_age=dict(type=
'int'),
260 bounce_trigger=dict(type=
'str', choices=[
'coop',
'flood']),
261 hold_interval=dict(type=
'int'),
262 local_ep_interval=dict(type=
'int'),
263 remote_ep_interval=dict(type=
'int'),
264 description=dict(type=
'str', aliases=[
'descr']),
265 move_frequency=dict(type=
'int'),
266 state=dict(type=
'str', default=
'present', choices=[
'absent',
'present',
'query']),
270 argument_spec=argument_spec,
271 supports_check_mode=
True,
273 [
'state',
'absent', [
'epr_policy',
'tenant']],
274 [
'state',
'present', [
'epr_policy',
'tenant']],
278 epr_policy = module.params[
'epr_policy']
279 bounce_age = module.params[
'bounce_age']
280 if bounce_age
is not None and bounce_age != 0
and bounce_age
not in range(150, 65536):
281 module.fail_json(msg=
"The bounce_age must be a value of 0 or between 150 and 65535")
283 bounce_age =
'infinite'
284 bounce_trigger = module.params[
'bounce_trigger']
285 if bounce_trigger
is not None:
286 bounce_trigger = BOUNCE_TRIG_MAPPING[bounce_trigger]
287 description = module.params[
'description']
288 hold_interval = module.params[
'hold_interval']
289 if hold_interval
is not None and hold_interval
not in range(5, 65536):
290 module.fail_json(msg=
"The hold_interval must be a value between 5 and 65535")
291 local_ep_interval = module.params[
'local_ep_interval']
292 if local_ep_interval
is not None and local_ep_interval != 0
and local_ep_interval
not in range(120, 65536):
293 module.fail_json(msg=
"The local_ep_interval must be a value of 0 or between 120 and 65535")
294 if local_ep_interval == 0:
295 local_ep_interval =
"infinite"
296 move_frequency = module.params[
'move_frequency']
297 if move_frequency
is not None and move_frequency
not in range(65536):
298 module.fail_json(msg=
"The move_frequency must be a value between 0 and 65535")
299 if move_frequency == 0:
300 move_frequency =
"none"
301 remote_ep_interval = module.params[
'remote_ep_interval']
302 if remote_ep_interval
is not None and remote_ep_interval
not in range(120, 65536):
303 module.fail_json(msg=
"The remote_ep_interval must be a value of 0 or between 120 and 65535")
304 if remote_ep_interval == 0:
305 remote_ep_interval =
"infinite"
306 state = module.params[
'state']
307 tenant = module.params[
'tenant']
312 aci_class=
'fvTenant',
313 aci_rn=
'tn-{0}'.
format(tenant),
314 module_object=tenant,
315 target_filter={
'name': tenant},
318 aci_class=
'fvEpRetPol',
319 aci_rn=
'epRPol-{0}'.
format(epr_policy),
320 module_object=epr_policy,
321 target_filter={
'name': epr_policy},
327 if state ==
'present':
329 aci_class=
'fvEpRetPol',
333 bounceAgeIntvl=bounce_age,
334 bounceTrig=bounce_trigger,
335 holdIntvl=hold_interval,
336 localEpAgeIntvl=local_ep_interval,
337 remoteEpAgeIntvl=remote_ep_interval,
338 moveFreq=move_frequency,
342 aci.get_diff(aci_class=
'fvEpRetPol')
346 elif state ==
'absent':
352if __name__ ==
"__main__":