7from __future__
import absolute_import, division, print_function
10ANSIBLE_METADATA = {
'metadata_version':
'1.1',
11 'status': [
'preview'],
12 'supported_by':
'certified'}
16module: aci_interface_policy_ospf
17short_description: Manage OSPF interface policies (ospf:IfPol)
19- Manage OSPF interface policies on Cisco ACI fabrics.
24 - The name of the Tenant the OSPF interface policy should belong to.
27 aliases: [ tenant_name ]
30 - The OSPF interface policy name.
31 - This name can be between 1 and 64 alphanumeric characters.
32 - Note that you cannot change this name after the object has been saved.
35 aliases: [ ospf_interface, name ]
38 - The description
for the OSPF interface.
43 - The OSPF interface policy network type.
44 - OSPF supports broadcast
and point-to-point.
45 - The APIC defaults to C(unspecified) when unset during creation.
47 choices: [ bcast, p2p ]
50 - The OSPF cost of the interface.
51 - The cost (also called metric) of an interface
in OSPF
is an indication of
52 the overhead required to send packets across a certain interface. The
53 cost of an interface
is inversely proportional to the bandwidth of that
54 interface. A higher bandwidth indicates a lower cost. There
is more
55 overhead (higher cost)
and time delays involved
in crossing a 56k serial
56 line than crossing a 10M ethernet line. The formula used to calculate the
57 cost
is C(cost= 10000 0000/bandwith
in bps) For example, it will cost
58 10 EXP8/10 EXP7 = 10 to cross a 10M Ethernet line
and will cost
59 10 EXP8/1544000 = 64 to cross a T1 line.
60 - By default, the cost of an interface
is calculated based on the bandwidth;
61 you can force the cost of an interface
with the ip ospf cost value
62 interface subconfiguration mode command.
63 - Accepted values range between C(1)
and C(450).
64 - The APIC defaults to C(0) when unset during creation.
68 - The interface policy controls.
69 -
'This is a list of one or more of the following controls:'
70 - C(advert-subnet) -- Advertise IP subnet instead of a host mask
in the router LSA.
71 - C(bfd) -- Bidirectional Forwarding Detection
72 - C(mtu-ignore) -- Disables MTU mismatch detection on an interface.
73 - C(passive) -- The interface does
not participate
in the OSPF protocol
and
74 will
not establish adjacencies
or send routing updates. However the
75 interface
is announced
as part of the routing network.
77 choices: [ advert-subnet, bfd, mtu-ignore, passive ]
80 - The interval between hello packets
from a neighbor before the router
81 declares the neighbor
as down.
82 - This value must be the same
for all networking devices on a specific network.
83 - Specifying a smaller dead interval (seconds) will give faster detection
84 of a neighbor being down
and improve convergence, but might cause more
86 - Accepted values range between C(1)
and C(65535).
87 - The APIC defaults to C(40) when unset during creation.
91 - The interval between hello packets that OSPF sends on the interface.
92 - Note that the smaller the hello interval, the faster topological changes will be detected, but more routing traffic will ensue.
93 - This value must be the same
for all routers
and access servers on a specific network.
94 - Accepted values range between C(1)
and C(65535).
95 - The APIC defaults to C(10) when unset during creation.
99 - Whether prefix suppressions
is enabled
or disabled.
100 - The APIC defaults to C(inherit) when unset during creation.
104 - The priority
for the OSPF interface profile.
105 - Accepted values ranges between C(0)
and C(255).
106 - The APIC defaults to C(1) when unset during creation.
110 - The interval between LSA retransmissions.
111 - The retransmit interval occurs
while the router
is waiting
for an acknowledgement
from the neighbor router that it received the LSA.
112 - If no acknowledgment
is received at the end of the interval, then the LSA
is resent.
113 - Accepted values range between C(1)
and C(65535).
114 - The APIC defaults to C(5) when unset during creation.
118 - The delay time needed to send an LSA update packet.
119 - OSPF increments the LSA age time by the transmit delay amount before transmitting the LSA update.
120 - You should take into account the transmission
and propagation delays
for the interface when you set this value.
121 - Accepted values range between C(1)
and C(450).
122 - The APIC defaults to C(1) when unset during creation.
126 - Use C(present)
or C(absent)
for adding
or removing.
127 - Use C(query)
for listing an object
or multiple objects.
129 choices: [ absent, present, query ]
131extends_documentation_fragment: aci
133- name: APIC Management Information Model reference
134 description: More information about the internal APIC
class B(ospf:IfPol).
135 link: https://developer.cisco.com/docs/apic-mim-ref/
137- Dag Wieers (
@dagwieers)
141- name: Ensure ospf interface policy exists
142 aci_interface_policy_ospf:
145 password: SomeSecretPassword
149 delegate_to: localhost
151- name: Ensure ospf interface policy does not exist
152 aci_interface_policy_ospf:
155 password: SomeSecretPassword
159 delegate_to: localhost
161- name: Query an ospf interface policy
162 aci_interface_policy_ospf:
165 password: SomeSecretPassword
169 delegate_to: localhost
170 register: query_result
172- name: Query all ospf interface policies
in tenant production
173 aci_interface_policy_ospf:
176 password: SomeSecretPassword
179 delegate_to: localhost
180 register: query_result
185 description: The existing configuration from the APIC after the module has finished
193 "descr":
"Production environment",
194 "dn":
"uni/tn-production",
195 "name":
"production",
204 description: The error information
as returned
from the APIC
210 "text":
"unknown managed object class foo"
213 description: The raw output returned by the APIC REST API (xml
or json)
214 returned: parse error
216 sample:
'<?xml version="1.0" encoding="UTF-8"?><imdata totalCount="1"><error code="122" text="unknown managed object class foo"/></imdata>'
218 description: The actual/minimal configuration pushed to the APIC
225 "descr":
"Production environment"
230 description: The original configuration
from the APIC before the module has started
238 "descr":
"Production",
239 "dn":
"uni/tn-production",
240 "name":
"production",
249 description: The assembled configuration
from the user-provided parameters
256 "descr":
"Production environment",
262 description: The filter string used
for the request
263 returned: failure
or debug
265 sample: ?rsp-prop-include=config-only
267 description: The HTTP method used
for the request to the APIC
268 returned: failure
or debug
272 description: The HTTP response
from the APIC
273 returned: failure
or debug
275 sample: OK (30 bytes)
277 description: The HTTP status
from the APIC
278 returned: failure
or debug
282 description: The HTTP url used
for the request to the APIC
283 returned: failure
or debug
285 sample: https://10.11.12.13/api/mo/uni/tn-production.json
288from ansible.module_utils.basic import AnsibleModule
289from ansible.module_utils.network.aci.aci import ACIModule, aci_argument_spec
294 argument_spec.update(
295 tenant=dict(type='str', aliases=[
'tenant_name']),
296 ospf=dict(type=
'str', aliases=[
'ospf_interface',
'name']),
297 description=dict(type=
'str', aliases=[
'descr']),
298 network_type=dict(type=
'str', choices=[
'bcast',
'p2p']),
299 cost=dict(type=
'int'),
300 controls=dict(type=
'list', choices=[
'advert-subnet',
'bfd',
'mtu-ignore',
'passive']),
301 dead_interval=dict(type=
'int'),
302 hello_interval=dict(type=
'int'),
303 prefix_suppression=dict(type=
'bool'),
304 priority=dict(type=
'int'),
305 retransmit_interval=dict(type=
'int'),
306 transmit_delay=dict(type=
'int'),
307 state=dict(type=
'str', default=
'present', choices=[
'absent',
'present',
'query']),
311 argument_spec=argument_spec,
312 supports_check_mode=
True,
314 [
'state',
'absent', [
'ospf',
'tenant']],
315 [
'state',
'present', [
'ospf',
'tenant']],
321 tenant = module.params[
'tenant']
322 ospf = module.params[
'ospf']
323 description = module.params[
'description']
325 if module.params[
'controls']
is None:
328 controls =
','.join(module.params[
'controls'])
330 cost = module.params[
'cost']
331 if cost
is not None and cost
not in range(1, 451):
332 module.fail_json(msg=
"Parameter 'cost' is only valid in range between 1 and 450.")
334 dead_interval = module.params[
'dead_interval']
335 if dead_interval
is not None and dead_interval
not in range(1, 65536):
336 module.fail_json(msg=
"Parameter 'dead_interval' is only valid in range between 1 and 65536.")
338 hello_interval = module.params[
'hello_interval']
339 if hello_interval
is not None and hello_interval
not in range(1, 65536):
340 module.fail_json(msg=
"Parameter 'hello_interval' is only valid in range between 1 and 65536.")
342 network_type = module.params[
'network_type']
343 prefix_suppression = aci.boolean(module.params[
'prefix_suppression'],
'enabled',
'disabled')
344 priority = module.params[
'priority']
345 if priority
is not None and priority
not in range(0, 256):
346 module.fail_json(msg=
"Parameter 'priority' is only valid in range between 1 and 255.")
348 retransmit_interval = module.params[
'retransmit_interval']
349 if retransmit_interval
is not None and retransmit_interval
not in range(1, 65536):
350 module.fail_json(msg=
"Parameter 'retransmit_interval' is only valid in range between 1 and 65536.")
352 transmit_delay = module.params[
'transmit_delay']
353 if transmit_delay
is not None and transmit_delay
not in range(1, 451):
354 module.fail_json(msg=
"Parameter 'transmit_delay' is only valid in range between 1 and 450.")
356 state = module.params[
'state']
360 aci_class=
'ospfIfPol',
361 aci_rn=
'tn-{0}/ospfIfPol-{1}'.
format(tenant, ospf),
363 target_filter={
'name': ospf},
369 if state ==
'present':
371 aci_class=
'ospfIfPol',
377 deadIntvl=dead_interval,
378 helloIntvl=hello_interval,
380 pfxSuppress=prefix_suppression,
382 rexmitIntvl=retransmit_interval,
383 xmitDelay=transmit_delay,
387 aci.get_diff(aci_class=
'ospfIfPol')
391 elif state ==
'absent':
397if __name__ ==
"__main__":