diff --git a/lib/ansible/modules/network/nxos/nxos_banner.py b/lib/ansible/modules/network/nxos/nxos_banner.py index b3adb4c7010..3690a31f1bc 100644 --- a/lib/ansible/modules/network/nxos/nxos_banner.py +++ b/lib/ansible/modules/network/nxos/nxos_banner.py @@ -96,7 +96,7 @@ def map_obj_to_commands(want, have, module): commands = list() state = module.params['state'] - if state == 'absent' and have.get('text'): + if (state == 'absent' and (have.get('text') and have.get('text') != 'User Access Verification')): commands.append('no banner %s' % module.params['banner']) elif state == 'present' and want.get('text') != have.get('text'): diff --git a/test/integration/targets/nxos_banner/tests/common/basic-no-exec.yaml b/test/integration/targets/nxos_banner/tests/common/basic-no-exec.yaml index da7ee1999a5..b7c9fbfc99d 100644 --- a/test/integration/targets/nxos_banner/tests/common/basic-no-exec.yaml +++ b/test/integration/targets/nxos_banner/tests/common/basic-no-exec.yaml @@ -1,16 +1,16 @@ --- - name: Setup nxos_banner: - banner: exec + banner: motd text: | - Junk exec banner + Junk motd banner over multiple lines state: present provider: "{{ connection }}" -- name: remove exec - nxos_banner: &rm-exec - banner: exec +- name: remove motd + nxos_banner: &rm-motd + banner: motd state: absent provider: "{{ connection }}" register: result @@ -18,10 +18,10 @@ - assert: that: - "result.changed == true" - - "'no banner exec' in result.commands" + - "'no banner motd' in result.commands" -- name: remove exec (idempotent) - nxos_banner: *rm-exec +- name: remove motd (idempotent) + nxos_banner: *rm-motd register: result - assert: