mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-27 10:40:22 -07:00
fix nxos_igmp_interface issues (#38752)
* fix nxos_igmp_interface issues * shippable fix * fix oif_prefix and oif_source * shippable fix * shippable fix * shippable fix * add an example for oif_ps * review comments * review comments * more review comments * fix typo
This commit is contained in:
parent
412373ce8e
commit
6eecbf10e6
4 changed files with 231 additions and 123 deletions
|
@ -10,6 +10,8 @@ Ansible Changes By Release
|
||||||
### Major Changes
|
### Major Changes
|
||||||
|
|
||||||
### Deprecations (to be removed in 2.10)
|
### Deprecations (to be removed in 2.10)
|
||||||
|
* In the `nxos_igmp_interface` module, `oif_prefix` and `oif_source` properties are deprecated.
|
||||||
|
Use the `oif_ps` parameter with a dictionary of prefix and source to values instead.
|
||||||
|
|
||||||
See [Porting Guide](http://docs.ansible.com/ansible/devel/porting_guides/porting_guides.html) for more information
|
See [Porting Guide](http://docs.ansible.com/ansible/devel/porting_guides/porting_guides.html) for more information
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,8 @@ No notable changes.
|
||||||
Deprecated
|
Deprecated
|
||||||
==========
|
==========
|
||||||
|
|
||||||
No notable changes.
|
* In the :ref:`nxos_igmp_interface <nxos_igmp_interface>` module, `oif_prefix` and `oif_source` properties are deprecated. Use
|
||||||
|
`ois_ps` parameter with a dictionary of prefix and source to values instead.
|
||||||
|
|
||||||
Modules
|
Modules
|
||||||
=======
|
=======
|
||||||
|
|
|
@ -39,14 +39,15 @@ notes:
|
||||||
C(startup_query_count), C(robustness), C(querier_timeout), C(query_mrt),
|
C(startup_query_count), C(robustness), C(querier_timeout), C(query_mrt),
|
||||||
C(query_interval), C(last_member_qrt), C(last_member_query_count),
|
C(query_interval), C(last_member_qrt), C(last_member_query_count),
|
||||||
C(group_timeout), C(report_llg), and C(immediate_leave).
|
C(group_timeout), C(report_llg), and C(immediate_leave).
|
||||||
- When C(state=absent), all configs for C(oif_prefix), C(oif_source), and
|
- When C(state=absent), all configs for C(oif_ps), and
|
||||||
C(oif_routemap) will be removed.
|
C(oif_routemap) will be removed.
|
||||||
- PIM must be enabled to use this module.
|
- PIM must be enabled to use this module.
|
||||||
- This module is for Layer 3 interfaces.
|
- This module is for Layer 3 interfaces.
|
||||||
- Route-map check not performed (same as CLI) check when configuring
|
- Route-map check not performed (same as CLI) check when configuring
|
||||||
route-map with 'static-oif'
|
route-map with 'static-oif'
|
||||||
- If restart is set to true with other params set, the restart will happen
|
- If restart is set to true with other params set, the restart will happen
|
||||||
last, i.e. after the configuration takes place.
|
last, i.e. after the configuration takes place. However, 'restart' itself
|
||||||
|
is not idempotent as it is an action and not configuration.
|
||||||
options:
|
options:
|
||||||
interface:
|
interface:
|
||||||
description:
|
description:
|
||||||
|
@ -55,48 +56,51 @@ options:
|
||||||
required: true
|
required: true
|
||||||
version:
|
version:
|
||||||
description:
|
description:
|
||||||
- IGMP version. It can be 2 or 3.
|
- IGMP version. It can be 2 or 3 or keyword 'default'.
|
||||||
choices: ['2', '3']
|
choices: ['2', '3', 'default']
|
||||||
startup_query_interval:
|
startup_query_interval:
|
||||||
description:
|
description:
|
||||||
- Query interval used when the IGMP process starts up.
|
- Query interval used when the IGMP process starts up.
|
||||||
The range is from 1 to 18000. The default is 31.
|
The range is from 1 to 18000 or keyword 'default'.
|
||||||
|
The default is 31.
|
||||||
startup_query_count:
|
startup_query_count:
|
||||||
description:
|
description:
|
||||||
- Query count used when the IGMP process starts up.
|
- Query count used when the IGMP process starts up.
|
||||||
The range is from 1 to 10. The default is 2.
|
The range is from 1 to 10 or keyword 'default'.
|
||||||
|
The default is 2.
|
||||||
robustness:
|
robustness:
|
||||||
description:
|
description:
|
||||||
- Sets the robustness variable. Values can range from 1 to 7.
|
- Sets the robustness variable. Values can range from 1 to 7 or
|
||||||
The default is 2.
|
keyword 'default'. The default is 2.
|
||||||
querier_timeout:
|
querier_timeout:
|
||||||
description:
|
description:
|
||||||
- Sets the querier timeout that the software uses when deciding
|
- Sets the querier timeout that the software uses when deciding
|
||||||
to take over as the querier. Values can range from 1 to 65535
|
to take over as the querier. Values can range from 1 to 65535
|
||||||
seconds. The default is 255 seconds.
|
seconds or keyword 'default'. The default is 255 seconds.
|
||||||
query_mrt:
|
query_mrt:
|
||||||
description:
|
description:
|
||||||
- Sets the response time advertised in IGMP queries.
|
- Sets the response time advertised in IGMP queries.
|
||||||
Values can range from 1 to 25 seconds. The default is 10 seconds.
|
Values can range from 1 to 25 seconds or keyword 'default'.
|
||||||
|
The default is 10 seconds.
|
||||||
query_interval:
|
query_interval:
|
||||||
description:
|
description:
|
||||||
- Sets the frequency at which the software sends IGMP host query
|
- Sets the frequency at which the software sends IGMP host query
|
||||||
messages. Values can range from 1 to 18000 seconds.
|
messages. Values can range from 1 to 18000 seconds or keyword
|
||||||
The default is 125 seconds.
|
'default'. The default is 125 seconds.
|
||||||
last_member_qrt:
|
last_member_qrt:
|
||||||
description:
|
description:
|
||||||
- Sets the query interval waited after sending membership reports
|
- Sets the query interval waited after sending membership reports
|
||||||
before the software deletes the group state. Values can range
|
before the software deletes the group state. Values can range
|
||||||
from 1 to 25 seconds. The default is 1 second.
|
from 1 to 25 seconds or keyword 'default'. The default is 1 second.
|
||||||
last_member_query_count:
|
last_member_query_count:
|
||||||
description:
|
description:
|
||||||
- Sets the number of times that the software sends an IGMP query
|
- Sets the number of times that the software sends an IGMP query
|
||||||
in response to a host leave message.
|
in response to a host leave message.
|
||||||
Values can range from 1 to 5. The default is 2.
|
Values can range from 1 to 5 or keyword 'default'. The default is 2.
|
||||||
group_timeout:
|
group_timeout:
|
||||||
description:
|
description:
|
||||||
- Sets the group membership timeout for IGMPv2.
|
- Sets the group membership timeout for IGMPv2.
|
||||||
Values can range from 3 to 65,535 seconds.
|
Values can range from 3 to 65,535 seconds or keyword 'default'.
|
||||||
The default is 260 seconds.
|
The default is 260 seconds.
|
||||||
report_llg:
|
report_llg:
|
||||||
description:
|
description:
|
||||||
|
@ -105,7 +109,6 @@ options:
|
||||||
Reports are always sent for nonlink local groups.
|
Reports are always sent for nonlink local groups.
|
||||||
By default, reports are not sent for link local groups.
|
By default, reports are not sent for link local groups.
|
||||||
type: bool
|
type: bool
|
||||||
default: 'no'
|
|
||||||
immediate_leave:
|
immediate_leave:
|
||||||
description:
|
description:
|
||||||
- Enables the device to remove the group entry from the multicast
|
- Enables the device to remove the group entry from the multicast
|
||||||
|
@ -115,30 +118,44 @@ options:
|
||||||
device does not send group-specific queries.
|
device does not send group-specific queries.
|
||||||
The default is disabled.
|
The default is disabled.
|
||||||
type: bool
|
type: bool
|
||||||
default: 'no'
|
|
||||||
oif_routemap:
|
oif_routemap:
|
||||||
description:
|
description:
|
||||||
- Configure a routemap for static outgoing interface (OIF).
|
- Configure a routemap for static outgoing interface (OIF) or
|
||||||
|
keyword 'default'.
|
||||||
oif_prefix:
|
oif_prefix:
|
||||||
description:
|
description:
|
||||||
- Configure a prefix for static outgoing interface (OIF).
|
- This argument is deprecated, please use oif_ps instead.
|
||||||
|
Configure a prefix for static outgoing interface (OIF).
|
||||||
oif_source:
|
oif_source:
|
||||||
description:
|
description:
|
||||||
- Configure a source for static outgoing interface (OIF).
|
- This argument is deprecated, please use oif_ps instead.
|
||||||
|
Configure a source for static outgoing interface (OIF).
|
||||||
|
oif_ps:
|
||||||
|
description:
|
||||||
|
- Configure prefixes and sources for static outgoing interface (OIF). This
|
||||||
|
is a list of dict where each dict has source and prefix defined or just
|
||||||
|
prefix if source is not needed. The specified values will be configured
|
||||||
|
on the device and if any previous prefix/sources exist, they will be removed.
|
||||||
|
Keyword 'default' is also accpted which removes all existing prefix/sources.
|
||||||
|
version_added: 2.6
|
||||||
restart:
|
restart:
|
||||||
description:
|
description:
|
||||||
- Restart IGMP.
|
- Restart IGMP. This is NOT idempotent as this is action only.
|
||||||
type: bool
|
type: bool
|
||||||
|
default: False
|
||||||
state:
|
state:
|
||||||
description:
|
description:
|
||||||
- Manages desired state of the resource.
|
- Manages desired state of the resource.
|
||||||
default: present
|
default: present
|
||||||
choices: ['present', 'default']
|
choices: ['present', 'absent', 'default']
|
||||||
'''
|
'''
|
||||||
EXAMPLES = '''
|
EXAMPLES = '''
|
||||||
- nxos_igmp_interface:
|
- nxos_igmp_interface:
|
||||||
interface: ethernet1/32
|
interface: ethernet1/32
|
||||||
startup_query_interval: 30
|
startup_query_interval: 30
|
||||||
|
oif_ps:
|
||||||
|
- { 'prefix': '238.2.2.6' }
|
||||||
|
- { 'source': '192.168.0.1', 'prefix': '238.2.2.5'}
|
||||||
state: present
|
state: present
|
||||||
'''
|
'''
|
||||||
RETURN = '''
|
RETURN = '''
|
||||||
|
@ -146,54 +163,25 @@ proposed:
|
||||||
description: k/v pairs of parameters passed into module
|
description: k/v pairs of parameters passed into module
|
||||||
returned: always
|
returned: always
|
||||||
type: dict
|
type: dict
|
||||||
sample: {"asn": "65535", "router_id": "1.1.1.1", "vrf": "test"}
|
sample: {"startup_query_count": "30",
|
||||||
|
"oif_ps": [{'prefix': '238.2.2.6'}, {'source': '192.168.0.1', 'prefix': '238.2.2.5'}]}
|
||||||
existing:
|
existing:
|
||||||
description: k/v pairs of existing BGP configuration
|
description: k/v pairs of existing igmp_interface configuration
|
||||||
returned: always
|
returned: always
|
||||||
type: dict
|
type: dict
|
||||||
sample: {"asn": "65535", "bestpath_always_compare_med": false,
|
sample: {"startup_query_count": "2", "oif_ps": []}
|
||||||
"bestpath_aspath_multipath_relax": false,
|
|
||||||
"bestpath_compare_neighborid": false,
|
|
||||||
"bestpath_compare_routerid": false,
|
|
||||||
"bestpath_cost_community_ignore": false,
|
|
||||||
"bestpath_med_confed": false,
|
|
||||||
"bestpath_med_missing_as_worst": false,
|
|
||||||
"bestpath_med_non_deterministic": false, "cluster_id": "",
|
|
||||||
"confederation_id": "", "confederation_peers": "",
|
|
||||||
"graceful_restart": true, "graceful_restart_helper": false,
|
|
||||||
"graceful_restart_timers_restart": "120",
|
|
||||||
"graceful_restart_timers_stalepath_time": "300", "local_as": "",
|
|
||||||
"log_neighbor_changes": false, "maxas_limit": "",
|
|
||||||
"neighbor_down_fib_accelerate": false, "reconnect_interval": "60",
|
|
||||||
"router_id": "11.11.11.11", "suppress_fib_pending": false,
|
|
||||||
"timer_bestpath_limit": "", "timer_bgp_hold": "180",
|
|
||||||
"timer_bgp_keepalive": "60", "vrf": "test"}
|
|
||||||
end_state:
|
end_state:
|
||||||
description: k/v pairs of BGP configuration after module execution
|
description: k/v pairs of igmp interface configuration after module execution
|
||||||
returned: always
|
returned: always
|
||||||
type: dict
|
type: dict
|
||||||
sample: {"asn": "65535", "bestpath_always_compare_med": false,
|
sample: {"startup_query_count": "30",
|
||||||
"bestpath_aspath_multipath_relax": false,
|
"oif_ps": [{'prefix': '238.2.2.6'}, {'source': '192.168.0.1', 'prefix': '238.2.2.5'}]}
|
||||||
"bestpath_compare_neighborid": false,
|
|
||||||
"bestpath_compare_routerid": false,
|
|
||||||
"bestpath_cost_community_ignore": false,
|
|
||||||
"bestpath_med_confed": false,
|
|
||||||
"bestpath_med_missing_as_worst": false,
|
|
||||||
"bestpath_med_non_deterministic": false, "cluster_id": "",
|
|
||||||
"confederation_id": "", "confederation_peers": "",
|
|
||||||
"graceful_restart": true, "graceful_restart_helper": false,
|
|
||||||
"graceful_restart_timers_restart": "120",
|
|
||||||
"graceful_restart_timers_stalepath_time": "300", "local_as": "",
|
|
||||||
"log_neighbor_changes": false, "maxas_limit": "",
|
|
||||||
"neighbor_down_fib_accelerate": false, "reconnect_interval": "60",
|
|
||||||
"router_id": "1.1.1.1", "suppress_fib_pending": false,
|
|
||||||
"timer_bestpath_limit": "", "timer_bgp_hold": "180",
|
|
||||||
"timer_bgp_keepalive": "60", "vrf": "test"}
|
|
||||||
updates:
|
updates:
|
||||||
description: commands sent to the device
|
description: commands sent to the device
|
||||||
returned: always
|
returned: always
|
||||||
type: list
|
type: list
|
||||||
sample: ["router bgp 65535", "vrf test", "router-id 1.1.1.1"]
|
sample: ["interface Ethernet1/32", "ip igmp startup-query-count 30",
|
||||||
|
"ip igmp static-oif 238.2.2.6", "ip igmp static-oif 238.2.2.5 source 192.168.0.1"]
|
||||||
changed:
|
changed:
|
||||||
description: check to see if a change was made on the device
|
description: check to see if a change was made on the device
|
||||||
returned: always
|
returned: always
|
||||||
|
@ -299,6 +287,8 @@ def get_igmp_interface(module, interface):
|
||||||
body = execute_show_command(command, module)[0]
|
body = execute_show_command(command, module)[0]
|
||||||
|
|
||||||
if body:
|
if body:
|
||||||
|
if 'not running' in body:
|
||||||
|
return igmp
|
||||||
resource = body['TABLE_vrf']['ROW_vrf']['TABLE_if']['ROW_if']
|
resource = body['TABLE_vrf']['ROW_vrf']['TABLE_if']['ROW_if']
|
||||||
igmp = apply_key_map(key_map, resource)
|
igmp = apply_key_map(key_map, resource)
|
||||||
report_llg = str(resource['ReportingForLinkLocal']).lower()
|
report_llg = str(resource['ReportingForLinkLocal']).lower()
|
||||||
|
@ -369,7 +359,7 @@ def get_igmp_interface(module, interface):
|
||||||
return igmp
|
return igmp
|
||||||
|
|
||||||
|
|
||||||
def config_igmp_interface(delta, found_both, found_prefix):
|
def config_igmp_interface(delta, existing, existing_oif_prefix_source):
|
||||||
CMDS = {
|
CMDS = {
|
||||||
'version': 'ip igmp version {0}',
|
'version': 'ip igmp version {0}',
|
||||||
'startup_query_interval': 'ip igmp startup-query-interval {0}',
|
'startup_query_interval': 'ip igmp startup-query-interval {0}',
|
||||||
|
@ -390,19 +380,46 @@ def config_igmp_interface(delta, found_both, found_prefix):
|
||||||
|
|
||||||
commands = []
|
commands = []
|
||||||
command = None
|
command = None
|
||||||
|
def_vals = get_igmp_interface_defaults()
|
||||||
|
|
||||||
for key, value in delta.items():
|
for key, value in delta.items():
|
||||||
if key == 'oif_source' or found_both or found_prefix:
|
if key == 'oif_ps':
|
||||||
pass
|
for each in value:
|
||||||
elif key == 'oif_prefix':
|
if each in existing_oif_prefix_source:
|
||||||
if delta.get('oif_source'):
|
existing_oif_prefix_source.remove(each)
|
||||||
command = CMDS.get('oif_prefix_source').format(
|
else:
|
||||||
delta.get('oif_prefix'), delta.get('oif_source'))
|
# add new prefix/sources
|
||||||
|
pf = each['prefix']
|
||||||
|
src = ''
|
||||||
|
if 'source' in each.keys():
|
||||||
|
src = each['source']
|
||||||
|
if src:
|
||||||
|
commands.append(CMDS.get('oif_prefix_source').format(pf, src))
|
||||||
|
else:
|
||||||
|
commands.append(CMDS.get('oif_prefix').format(pf))
|
||||||
|
if existing_oif_prefix_source:
|
||||||
|
for each in existing_oif_prefix_source:
|
||||||
|
# remove stale prefix/sources
|
||||||
|
pf = each['prefix']
|
||||||
|
src = ''
|
||||||
|
if 'source' in each.keys():
|
||||||
|
src = each['source']
|
||||||
|
if src:
|
||||||
|
commands.append('no ' + CMDS.get('oif_prefix_source').format(pf, src))
|
||||||
|
else:
|
||||||
|
commands.append('no ' + CMDS.get('oif_prefix').format(pf))
|
||||||
|
elif key == 'oif_routemap':
|
||||||
|
if value == 'default':
|
||||||
|
if existing.get(key):
|
||||||
|
command = 'no ' + CMDS.get(key).format(existing.get(key))
|
||||||
else:
|
else:
|
||||||
command = CMDS.get('oif_prefix').format(
|
command = CMDS.get(key).format(value)
|
||||||
delta.get('oif_prefix'))
|
|
||||||
elif value:
|
elif value:
|
||||||
command = CMDS.get(key).format(value)
|
if value == 'default':
|
||||||
|
if def_vals.get(key) != existing.get(key):
|
||||||
|
command = CMDS.get(key).format(def_vals.get(key))
|
||||||
|
else:
|
||||||
|
command = CMDS.get(key).format(value)
|
||||||
elif not value:
|
elif not value:
|
||||||
command = 'no {0}'.format(CMDS.get(key).format(value))
|
command = 'no {0}'.format(CMDS.get(key).format(value))
|
||||||
|
|
||||||
|
@ -442,12 +459,12 @@ def get_igmp_interface_defaults():
|
||||||
return default
|
return default
|
||||||
|
|
||||||
|
|
||||||
def config_default_igmp_interface(existing, delta, found_both, found_prefix):
|
def config_default_igmp_interface(existing, delta):
|
||||||
commands = []
|
commands = []
|
||||||
proposed = get_igmp_interface_defaults()
|
proposed = get_igmp_interface_defaults()
|
||||||
delta = dict(set(proposed.items()).difference(existing.items()))
|
delta = dict(set(proposed.items()).difference(existing.items()))
|
||||||
if delta:
|
if delta:
|
||||||
command = config_igmp_interface(delta, found_both, found_prefix)
|
command = config_igmp_interface(delta, existing, existing_oif_prefix_source=None)
|
||||||
|
|
||||||
if command:
|
if command:
|
||||||
for each in command:
|
for each in command:
|
||||||
|
@ -459,10 +476,9 @@ def config_default_igmp_interface(existing, delta, found_both, found_prefix):
|
||||||
def config_remove_oif(existing, existing_oif_prefix_source):
|
def config_remove_oif(existing, existing_oif_prefix_source):
|
||||||
commands = []
|
commands = []
|
||||||
command = None
|
command = None
|
||||||
if existing.get('routemap'):
|
if existing.get('oif_routemap'):
|
||||||
command = 'no ip igmp static-oif route-map {0}'.format(
|
commands.append('no ip igmp static-oif route-map {0}'.format(existing.get('oif_routemap')))
|
||||||
existing.get('routemap'))
|
elif existing_oif_prefix_source:
|
||||||
if existing_oif_prefix_source:
|
|
||||||
for each in existing_oif_prefix_source:
|
for each in existing_oif_prefix_source:
|
||||||
if each.get('prefix') and each.get('source'):
|
if each.get('prefix') and each.get('source'):
|
||||||
command = 'no ip igmp static-oif {0} source {1} '.format(
|
command = 'no ip igmp static-oif {0} source {1} '.format(
|
||||||
|
@ -495,16 +511,22 @@ def main():
|
||||||
report_llg=dict(type='bool'),
|
report_llg=dict(type='bool'),
|
||||||
immediate_leave=dict(type='bool'),
|
immediate_leave=dict(type='bool'),
|
||||||
oif_routemap=dict(required=False, type='str'),
|
oif_routemap=dict(required=False, type='str'),
|
||||||
oif_prefix=dict(required=False, type='str'),
|
oif_prefix=dict(required=False, type='str', removed_in_version='2.10'),
|
||||||
oif_source=dict(required=False, type='str'),
|
oif_source=dict(required=False, type='str', removed_in_version='2.10'),
|
||||||
|
oif_ps=dict(required=False, type='list', elements='dict'),
|
||||||
restart=dict(type='bool', default=False),
|
restart=dict(type='bool', default=False),
|
||||||
state=dict(choices=['present', 'absent', 'default'],
|
state=dict(choices=['present', 'absent', 'default'],
|
||||||
default='present')
|
default='present')
|
||||||
)
|
)
|
||||||
|
|
||||||
argument_spec.update(nxos_argument_spec)
|
argument_spec.update(nxos_argument_spec)
|
||||||
|
mutually_exclusive = [('oif_ps', 'oif_prefix'),
|
||||||
|
('oif_ps', 'oif_source'),
|
||||||
|
('oif_ps', 'oif_routemap'),
|
||||||
|
('oif_prefix', 'oif_routemap')]
|
||||||
|
|
||||||
module = AnsibleModule(argument_spec=argument_spec,
|
module = AnsibleModule(argument_spec=argument_spec,
|
||||||
|
mutually_exclusive=mutually_exclusive,
|
||||||
supports_check_mode=True)
|
supports_check_mode=True)
|
||||||
|
|
||||||
warnings = list()
|
warnings = list()
|
||||||
|
@ -515,19 +537,19 @@ def main():
|
||||||
oif_prefix = module.params['oif_prefix']
|
oif_prefix = module.params['oif_prefix']
|
||||||
oif_source = module.params['oif_source']
|
oif_source = module.params['oif_source']
|
||||||
oif_routemap = module.params['oif_routemap']
|
oif_routemap = module.params['oif_routemap']
|
||||||
|
oif_ps = module.params['oif_ps']
|
||||||
|
|
||||||
if oif_source:
|
if oif_source and not oif_prefix:
|
||||||
if not oif_prefix:
|
module.fail_json(msg='oif_prefix required when setting oif_source')
|
||||||
module.fail_json(msg='oif_prefix required when setting oif_source')
|
elif oif_source and oif_prefix:
|
||||||
|
oif_ps = [{'source': oif_source, 'prefix': oif_prefix}]
|
||||||
|
elif not oif_source and oif_prefix:
|
||||||
|
oif_ps = [{'prefix': oif_prefix}]
|
||||||
|
|
||||||
intf_type = get_interface_type(interface)
|
intf_type = get_interface_type(interface)
|
||||||
if get_interface_mode(interface, intf_type, module) == 'layer2':
|
if get_interface_mode(interface, intf_type, module) == 'layer2':
|
||||||
module.fail_json(msg='this module only works on Layer 3 interfaces')
|
module.fail_json(msg='this module only works on Layer 3 interfaces')
|
||||||
|
|
||||||
if oif_prefix and oif_routemap:
|
|
||||||
module.fail_json(msg='cannot use oif_prefix AND oif_routemap.'
|
|
||||||
' select one.')
|
|
||||||
|
|
||||||
existing = get_igmp_interface(module, interface)
|
existing = get_igmp_interface(module, interface)
|
||||||
existing_copy = existing.copy()
|
existing_copy = existing.copy()
|
||||||
end_state = existing_copy
|
end_state = existing_copy
|
||||||
|
@ -543,7 +565,7 @@ def main():
|
||||||
module.fail_json(msg='Delete static-oif configurations on this '
|
module.fail_json(msg='Delete static-oif configurations on this '
|
||||||
'interface if you want to use a routemap')
|
'interface if you want to use a routemap')
|
||||||
|
|
||||||
if oif_prefix and existing.get('oif_routemap'):
|
if oif_ps and existing.get('oif_routemap'):
|
||||||
module.fail_json(msg='Delete static-oif route-map configuration '
|
module.fail_json(msg='Delete static-oif route-map configuration '
|
||||||
'on this interface if you want to config '
|
'on this interface if you want to config '
|
||||||
'static entries')
|
'static entries')
|
||||||
|
@ -562,8 +584,6 @@ def main():
|
||||||
'report_llg',
|
'report_llg',
|
||||||
'immediate_leave',
|
'immediate_leave',
|
||||||
'oif_routemap',
|
'oif_routemap',
|
||||||
'oif_prefix',
|
|
||||||
'oif_source'
|
|
||||||
]
|
]
|
||||||
|
|
||||||
changed = False
|
changed = False
|
||||||
|
@ -581,41 +601,26 @@ def main():
|
||||||
for each in CANNOT_ABSENT:
|
for each in CANNOT_ABSENT:
|
||||||
if each in proposed:
|
if each in proposed:
|
||||||
module.fail_json(msg='only params: oif_prefix, oif_source, '
|
module.fail_json(msg='only params: oif_prefix, oif_source, '
|
||||||
'oif_routemap can be used when '
|
'oif_ps, oif_routemap can be used when '
|
||||||
'state=absent')
|
'state=absent')
|
||||||
|
|
||||||
# delta check for all params except oif_prefix and oif_source
|
# delta check for all params except oif_ps
|
||||||
delta = dict(set(proposed.items()).difference(existing.items()))
|
delta = dict(set(proposed.items()).difference(existing.items()))
|
||||||
|
|
||||||
# now check to see there is a delta for prefix and source command option
|
if oif_ps:
|
||||||
found_both = False
|
if oif_ps == ['default']:
|
||||||
found_prefix = False
|
delta['oif_ps'] = []
|
||||||
|
else:
|
||||||
if existing_oif_prefix_source:
|
delta['oif_ps'] = oif_ps
|
||||||
if oif_prefix and oif_source:
|
|
||||||
for each in existing_oif_prefix_source:
|
|
||||||
if (oif_prefix == each.get('prefix') and
|
|
||||||
oif_source == each.get('source')):
|
|
||||||
found_both = True
|
|
||||||
if not found_both:
|
|
||||||
delta['prefix'] = oif_prefix
|
|
||||||
delta['source'] = oif_source
|
|
||||||
elif oif_prefix:
|
|
||||||
for each in existing_oif_prefix_source:
|
|
||||||
if oif_prefix == each.get('prefix') and not each.get('source'):
|
|
||||||
found_prefix = True
|
|
||||||
if not found_prefix:
|
|
||||||
delta['prefix'] = oif_prefix
|
|
||||||
|
|
||||||
if state == 'present':
|
if state == 'present':
|
||||||
if delta:
|
if delta:
|
||||||
command = config_igmp_interface(delta, found_both, found_prefix)
|
command = config_igmp_interface(delta, existing, existing_oif_prefix_source)
|
||||||
if command:
|
if command:
|
||||||
commands.append(command)
|
commands.append(command)
|
||||||
|
|
||||||
elif state == 'default':
|
elif state == 'default':
|
||||||
command = config_default_igmp_interface(existing, delta,
|
command = config_default_igmp_interface(existing, delta)
|
||||||
found_both, found_prefix)
|
|
||||||
if command:
|
if command:
|
||||||
commands.append(command)
|
commands.append(command)
|
||||||
elif state == 'absent':
|
elif state == 'absent':
|
||||||
|
@ -626,14 +631,10 @@ def main():
|
||||||
if command:
|
if command:
|
||||||
commands.append(command)
|
commands.append(command)
|
||||||
|
|
||||||
command = config_default_igmp_interface(existing, delta,
|
command = config_default_igmp_interface(existing, delta)
|
||||||
found_both, found_prefix)
|
|
||||||
if command:
|
if command:
|
||||||
commands.append(command)
|
commands.append(command)
|
||||||
|
|
||||||
if module.params['restart']:
|
|
||||||
commands.append('restart igmp')
|
|
||||||
|
|
||||||
cmds = []
|
cmds = []
|
||||||
results = {}
|
results = {}
|
||||||
if commands:
|
if commands:
|
||||||
|
@ -649,6 +650,10 @@ def main():
|
||||||
if 'configure' in cmds:
|
if 'configure' in cmds:
|
||||||
cmds.pop(0)
|
cmds.pop(0)
|
||||||
|
|
||||||
|
if module.params['restart']:
|
||||||
|
cmd = {'command': 'restart igmp', 'output': 'text'}
|
||||||
|
run_commands(module, cmd)
|
||||||
|
|
||||||
results['proposed'] = proposed
|
results['proposed'] = proposed
|
||||||
results['existing'] = existing_copy
|
results['existing'] = existing_copy
|
||||||
results['updates'] = cmds
|
results['updates'] = cmds
|
||||||
|
|
|
@ -6,6 +6,9 @@
|
||||||
# Select interface for test
|
# Select interface for test
|
||||||
- set_fact: intname="{{ nxos_int1 }}"
|
- set_fact: intname="{{ nxos_int1 }}"
|
||||||
|
|
||||||
|
- set_fact: restart="true"
|
||||||
|
when: platform is not match("N35")
|
||||||
|
|
||||||
- name: "Enable feature PIM"
|
- name: "Enable feature PIM"
|
||||||
nxos_feature:
|
nxos_feature:
|
||||||
feature: pim
|
feature: pim
|
||||||
|
@ -13,6 +16,14 @@
|
||||||
provider: "{{ connection }}"
|
provider: "{{ connection }}"
|
||||||
ignore_errors: yes
|
ignore_errors: yes
|
||||||
|
|
||||||
|
- name: Put interface in default mode
|
||||||
|
nxos_config:
|
||||||
|
commands:
|
||||||
|
- "default interface {{ intname }}"
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
match: none
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
- block:
|
- block:
|
||||||
|
|
||||||
- name: put interface in L3 and enable PIM
|
- name: put interface in L3 and enable PIM
|
||||||
|
@ -39,7 +50,10 @@
|
||||||
last_member_query_count: 4
|
last_member_query_count: 4
|
||||||
report_llg: true
|
report_llg: true
|
||||||
immediate_leave: true
|
immediate_leave: true
|
||||||
restart: false
|
group_timeout: 300
|
||||||
|
# deprecated
|
||||||
|
oif_prefix: 239.255.255.2
|
||||||
|
oif_source: 1.1.1.1
|
||||||
state: present
|
state: present
|
||||||
provider: "{{ connection }}"
|
provider: "{{ connection }}"
|
||||||
register: result
|
register: result
|
||||||
|
@ -56,7 +70,78 @@
|
||||||
that:
|
that:
|
||||||
- "result.changed == false"
|
- "result.changed == false"
|
||||||
|
|
||||||
- name: Configure igmp interface with default value
|
- name: Configure igmp interface with some default values
|
||||||
|
nxos_igmp_interface: &sdef
|
||||||
|
interface: "{{ intname }}"
|
||||||
|
version: default
|
||||||
|
startup_query_interval: default
|
||||||
|
startup_query_count: default
|
||||||
|
robustness: default
|
||||||
|
querier_timeout: default
|
||||||
|
query_mrt: default
|
||||||
|
query_interval: default
|
||||||
|
last_member_qrt: default
|
||||||
|
last_member_query_count: default
|
||||||
|
group_timeout: default
|
||||||
|
oif_ps:
|
||||||
|
- {'prefix': '238.2.2.6'}
|
||||||
|
- {'prefix': '238.2.2.5'}
|
||||||
|
- {'source': '1.1.1.1', 'prefix': '238.2.2.5'}
|
||||||
|
state: present
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: *true
|
||||||
|
|
||||||
|
- name: "Check Idempotence - Configure igmp interface with some default values"
|
||||||
|
nxos_igmp_interface: *sdef
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: *false
|
||||||
|
|
||||||
|
- name: restart igmp
|
||||||
|
nxos_igmp_interface: &restart
|
||||||
|
interface: "{{ intname }}"
|
||||||
|
restart: "{{restart|default(omit)}}"
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
|
||||||
|
- name: Configure igmp interface with default oif_ps
|
||||||
|
nxos_igmp_interface: &defoif
|
||||||
|
interface: "{{ intname }}"
|
||||||
|
oif_ps: default
|
||||||
|
state: present
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: *true
|
||||||
|
|
||||||
|
- name: "Check Idempotence - Configure igmp interface with default oif_ps"
|
||||||
|
nxos_igmp_interface: *defoif
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: *false
|
||||||
|
|
||||||
|
- name: Configure igmp interface with oif_routemap
|
||||||
|
nxos_igmp_interface: &orm
|
||||||
|
interface: "{{ intname }}"
|
||||||
|
version: 3
|
||||||
|
startup_query_interval: 60
|
||||||
|
startup_query_count: 5
|
||||||
|
robustness: 6
|
||||||
|
oif_routemap: abcd
|
||||||
|
state: present
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: *true
|
||||||
|
|
||||||
|
- name: "Check Idempotence - Configure igmp interface with oif_routemap"
|
||||||
|
nxos_igmp_interface: *orm
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: *false
|
||||||
|
|
||||||
|
- name: Configure igmp interface with default state
|
||||||
nxos_igmp_interface: &default
|
nxos_igmp_interface: &default
|
||||||
interface: "{{ intname }}"
|
interface: "{{ intname }}"
|
||||||
state: default
|
state: default
|
||||||
|
@ -65,15 +150,30 @@
|
||||||
|
|
||||||
- assert: *true
|
- assert: *true
|
||||||
|
|
||||||
- name: "Check Idempotence - Configure igmp interface with default value"
|
- name: "Check Idempotence - Configure igmp interface with default state"
|
||||||
nxos_igmp_interface: *default
|
nxos_igmp_interface: *default
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert: *false
|
- assert: *false
|
||||||
|
|
||||||
|
- name: Configure igmp interface with absent state
|
||||||
|
nxos_igmp_interface: &absent
|
||||||
|
interface: "{{ intname }}"
|
||||||
|
state: absent
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: *true
|
||||||
|
|
||||||
|
- name: "Check Idempotence - Configure igmp interface with absent state"
|
||||||
|
nxos_igmp_interface: *absent
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: *false
|
||||||
|
|
||||||
always:
|
always:
|
||||||
- name: Configure igmp interface with default value
|
- name: Configure igmp interface with absent state
|
||||||
nxos_igmp_interface: *default
|
nxos_igmp_interface: *absent
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: Put interface in default mode
|
- name: Put interface in default mode
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue