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)