Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix nxos_igmp issues #38496

Merged
merged 1 commit into from
Apr 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 8 additions & 5 deletions lib/ansible/modules/network/nxos/nxos_igmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,12 @@ def main():
commands.append('no ip igmp enforce-router-alert')

elif state == 'present':
if desired['flush_routes'] and not current['flush_routes']:
commands.append('ip igmp flush-routes')
if desired['enforce_rtr_alert'] and not current['enforce_rtr_alert']:
commands.append('ip igmp enforce-router-alert')
ldict = {'flush_routes': 'flush-routes', 'enforce_rtr_alert': 'enforce-router-alert'}
for arg in ['flush_routes', 'enforce_rtr_alert']:
if desired[arg] and not current[arg]:
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}

Expand All @@ -145,7 +147,8 @@ def main():
result['changed'] = True

if module.params['restart']:
run_commands(module, 'restart igmp')
cmd = {'command': 'restart igmp', 'output': 'text'}
run_commands(module, cmd)

module.exit_json(**result)

Expand Down
33 changes: 29 additions & 4 deletions test/integration/targets/nxos_igmp/tests/common/sanity.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
- debug: msg="Using provider={{ connection.transport }}"
when: ansible_connection == "local"

- set_fact: restart="true"
when: platform is not match("N35")

- block:

- name: Configure igmp with non-default values
Expand All @@ -26,23 +29,45 @@
that:
- "result.changed == false"

- name: Configure igmp with default values
- name: Configure igmp defaults
nxos_igmp: &default
state: 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 default values"
- 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
provider: "{{ connection }}"
register: result

- assert: *true

- name: "Check Idempotence - Configure igmp with state default"
nxos_igmp: *sdefault
register: result

- assert: *false

always:
- name: Configure igmp with default values
nxos_igmp: *default
nxos_igmp: *sdefault
register: result
ignore_errors: yes

- debug: msg="END connection={{ ansible_connection }} nxos_igmp sanity test"