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 0f268e70a1)

* Added changelog
pull/45257/head
Nilashish Chakraborty 6 years ago committed by Matt Davis
parent 5ea238912f
commit 7113e50a42

@ -0,0 +1,3 @@
---
bugfixes:
- ios_user - fix unable to delete user admin issue (https://github.com/ansible/ansible/pull/44904)

@ -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)

Loading…
Cancel
Save