From 7113e50a427aa8d4ba95607f697dcbd7e3206bb9 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Wed, 5 Sep 2018 23:38:43 +0530 Subject: [PATCH] Fix ios_user issue CP in 2.5 (#45180) * Fix ios_user issues (#44904) * Fix ios_user issues * Modify regex and fix unittests (cherry picked from commit 0f268e70a1694f4f40e7251fb9488602d2c0a616) * Added changelog --- changelogs/fragments/fix_ios_user.yaml | 3 +++ lib/ansible/modules/network/ios/ios_user.py | 8 +------- 2 files changed, 4 insertions(+), 7 deletions(-) create mode 100644 changelogs/fragments/fix_ios_user.yaml diff --git a/changelogs/fragments/fix_ios_user.yaml b/changelogs/fragments/fix_ios_user.yaml new file mode 100644 index 00000000000..f89a06dbe60 --- /dev/null +++ b/changelogs/fragments/fix_ios_user.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: + - ios_user - fix unable to delete user admin issue (https://github.com/ansible/ansible/pull/44904) diff --git a/lib/ansible/modules/network/ios/ios_user.py b/lib/ansible/modules/network/ios/ios_user.py index 56a62adcdd9..5bd0f3c8bb9 100644 --- a/lib/ansible/modules/network/ios/ios_user.py +++ b/lib/ansible/modules/network/ios/ios_user.py @@ -241,7 +241,7 @@ def parse_privilege(data): def map_config_to_obj(module): data = get_config(module, flags=['| section username']) - match = re.findall(r'^username (\S+)', data, re.M) + match = re.findall(r'(?:^(?:u|\s{2}u))sername (\S+)', data, re.M) if not match: return list() @@ -392,12 +392,6 @@ def main(): result['commands'] = commands - # the ios cli prevents this by rule so capture it and display - # a nice failure message - for cmd in commands: - if 'no username admin' in cmd: - module.fail_json(msg='cannot delete the `admin` account') - if commands: if not module.check_mode: load_config(module, commands)