From 025386c56b1d8f272a23cd61193f834e666e9e3e Mon Sep 17 00:00:00 2001 From: rahushen Date: Wed, 11 Oct 2017 06:56:17 -0400 Subject: [PATCH] Fix nxos_banner removal idempotence issue in N1 images (#31259) * Fix nxos_banner removal idempotence issue in N1 images * handle pep8 error --- lib/ansible/modules/network/nxos/nxos_banner.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/network/nxos/nxos_banner.py b/lib/ansible/modules/network/nxos/nxos_banner.py index 6d9295b90d0..69f90056627 100644 --- a/lib/ansible/modules/network/nxos/nxos_banner.py +++ b/lib/ansible/modules/network/nxos/nxos_banner.py @@ -90,14 +90,17 @@ commands: from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.nxos import load_config, run_commands from ansible.module_utils.nxos import nxos_argument_spec, check_args +import re def map_obj_to_commands(want, have, module): commands = list() state = module.params['state'] + platform_regex = 'Nexus.*Switch' - if (state == 'absent' and (have.get('text') and have.get('text') != 'User Access Verification')): - commands.append('no banner %s' % module.params['banner']) + if state == 'absent': + if (have.get('text') and not ((have.get('text') == 'User Access Verification') or re.match(platform_regex, have.get('text')))): + commands.append('no banner %s' % module.params['banner']) elif state == 'present' and want.get('text') != have.get('text'): banner_cmd = 'banner %s @\n%s\n@' % (module.params['banner'], want['text'].strip())