Skip to content

Commit

Permalink
Fix ios_user issue CP in 2.6 (#45175)
Browse files Browse the repository at this point in the history
* Fix ios_user issues (#44904)

* Fix ios_user issues

* Modify regex and fix unittests

(cherry picked from commit 0f268e7)

* Added changelog
  • Loading branch information
NilashishC authored and mattclay committed Sep 4, 2018
1 parent 9acfbee commit 0c367e7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
3 changes: 3 additions & 0 deletions 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)
8 changes: 1 addition & 7 deletions lib/ansible/modules/network/ios/ios_user.py
Expand Up @@ -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()

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 0c367e7

Please sign in to comment.