1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

fix nxos_igmp issues (#38496)

This commit is contained in:
saichint 2018-04-09 21:05:58 -07:00 committed by Trishna Guha
parent dabe5e6d07
commit 361437b042
2 changed files with 37 additions and 9 deletions

View file

@ -132,10 +132,12 @@ def main():
commands.append('no ip igmp enforce-router-alert') commands.append('no ip igmp enforce-router-alert')
elif state == 'present': elif state == 'present':
if desired['flush_routes'] and not current['flush_routes']: ldict = {'flush_routes': 'flush-routes', 'enforce_rtr_alert': 'enforce-router-alert'}
commands.append('ip igmp flush-routes') for arg in ['flush_routes', 'enforce_rtr_alert']:
if desired['enforce_rtr_alert'] and not current['enforce_rtr_alert']: if desired[arg] and not current[arg]:
commands.append('ip igmp enforce-router-alert') commands.append('ip igmp {0}'.format(ldict.get(arg)))
elif current[arg] and not desired[arg]:
commands.append('no ip igmp {0}'.format(ldict.get(arg)))
result = {'changed': False, 'updates': commands, 'warnings': warnings} result = {'changed': False, 'updates': commands, 'warnings': warnings}
@ -145,7 +147,8 @@ def main():
result['changed'] = True result['changed'] = True
if module.params['restart']: if module.params['restart']:
run_commands(module, 'restart igmp') cmd = {'command': 'restart igmp', 'output': 'text'}
run_commands(module, cmd)
module.exit_json(**result) module.exit_json(**result)

View file

@ -3,6 +3,9 @@
- debug: msg="Using provider={{ connection.transport }}" - debug: msg="Using provider={{ connection.transport }}"
when: ansible_connection == "local" when: ansible_connection == "local"
- set_fact: restart="true"
when: platform is not match("N35")
- block: - block:
- name: Configure igmp with non-default values - name: Configure igmp with non-default values
@ -26,23 +29,45 @@
that: that:
- "result.changed == false" - "result.changed == false"
- name: Configure igmp with default values - name: Configure igmp defaults
nxos_igmp: &default nxos_igmp: &default
flush_routes: false
enforce_rtr_alert: false
restart: "{{restart|default(omit)}}"
state: present
provider: "{{ connection }}"
register: result
- assert: *true
- name: "Check Idempotence - Configure igmp with defaults"
nxos_igmp: *default
register: result
- assert: *false
- name: Configure igmp non-defaults again
nxos_igmp: *non-default
register: result
- name: Configure igmp state as values
nxos_igmp: &sdefault
state: default state: default
provider: "{{ connection }}" provider: "{{ connection }}"
register: result register: result
- assert: *true - assert: *true
- name: "Check Idempotence - Configure igmp with default values" - name: "Check Idempotence - Configure igmp with state default"
nxos_igmp: *default nxos_igmp: *sdefault
register: result register: result
- assert: *false - assert: *false
always: always:
- name: Configure igmp with default values - name: Configure igmp with default values
nxos_igmp: *default nxos_igmp: *sdefault
register: result register: result
ignore_errors: yes
- debug: msg="END connection={{ ansible_connection }} nxos_igmp sanity test" - debug: msg="END connection={{ ansible_connection }} nxos_igmp sanity test"