Change network *_user modules to use configured_password to set a users password (#28187)

* WIP, update eos_user args

* refactor password for ios_user

* add eos tests, fix ios tests

* fixed password check

* refactor iosxr_user password

* fixed password arg for nxos

* [WIP] fix vyos_user password

* fix vyos tests

* update docs for net_user

* fix typo

* fix eos tests

* add warning when attempting to use password arg

* fix sanity/unit tests

* fix eos unit tests

* fix vyos_user aggregate

* fix typo in eos documentation string

* re add configured_password to vyos tests after rebase
This commit is contained in:
David Newswanger 2017-08-17 09:36:44 -04:00 committed by Trishna Guha
commit b818e986b6
18 changed files with 329 additions and 70 deletions

View file

@ -48,7 +48,7 @@ options:
This argument accepts a string value and is mutually exclusive
with the C(aggregate) argument.
Please note that this option is not same as C(provider username).
password:
configured_password:
description:
- The password to be configured on the Cisco IOS device. The
password needs to be provided in clear and it will be encrypted
@ -127,7 +127,7 @@ EXAMPLES = """
- name: Change Password for User netop
ios_user:
name: netop
password: "{{ new_password }}"
configured_password: "{{ new_password }}"
update_password: always
state: present
@ -207,9 +207,9 @@ def map_obj_to_commands(updates, module):
if needs_update(want, have, 'privilege'):
add(commands, want, 'privilege %s' % want['privilege'])
if needs_update(want, have, 'password'):
if needs_update(want, have, 'configured_password'):
if update_password == 'always' or not have:
add(commands, want, 'secret %s' % want['password'])
add(commands, want, 'secret %s' % want['configured_password'])
if needs_update(want, have, 'nopassword'):
if want['nopassword']:
@ -249,7 +249,7 @@ def map_config_to_obj(module):
'name': user,
'state': 'present',
'nopassword': 'nopassword' in cfg,
'password': None,
'configured_password': None,
'privilege': parse_privilege(cfg),
'view': parse_view(cfg)
}
@ -301,7 +301,7 @@ def map_params_to_obj(module):
for item in aggregate:
get_value = partial(get_param_value, item=item, module=module)
item['password'] = get_value('password')
item['configured_password'] = get_value('configured_password')
item['nopassword'] = get_value('nopassword')
item['privilege'] = get_value('privilege')
item['view'] = get_value('view')
@ -330,7 +330,7 @@ def main():
element_spec = dict(
name=dict(),
password=dict(no_log=True),
configured_password=dict(no_log=True),
nopassword=dict(type='bool'),
update_password=dict(default='always', choices=['on_create', 'always']),
@ -360,6 +360,12 @@ def main():
supports_check_mode=True)
warnings = list()
if module.params['password'] and not module.params['configured_password']:
warnings.append(
'The "password" argument is used to authenticate the current connection. ' +
'To set a user password use "configured_password" instead.'
)
check_args(module, warnings)
result = {'changed': False}