fix vyos_user aggregate (#28317)

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
This commit is contained in:
Trishna Guha 2017-08-17 12:44:55 +05:30 committed by GitHub
parent 403f6db53f
commit 2e211078ce
2 changed files with 15 additions and 7 deletions

View file

@ -27,7 +27,7 @@ DOCUMENTATION = """
--- ---
module: vyos_user module: vyos_user
version_added: "2.4" version_added: "2.4"
author: "Trishna Guha (@trishnag)" author: "Trishna Guha (@trishnaguha)"
short_description: Manage the collection of local users on VyOS device short_description: Manage the collection of local users on VyOS device
description: description:
- This module provides declarative management of the local usernames - This module provides declarative management of the local usernames
@ -231,18 +231,18 @@ def map_params_to_obj(module):
if not module.params['name'] and module.params['purge']: if not module.params['name'] and module.params['purge']:
return list() return list()
else: else:
aggregate = [{'name': module.params['name']}] aggregatelist = [{'name': module.params['name']}]
else: else:
aggregate = list() aggregatelist = list()
for item in aggregate: for item in aggregate:
if not isinstance(item, dict): if not isinstance(item, dict):
aggregate.append({'name': item}) aggregatelist.append({'name': item})
else: else:
aggregate.append(item) aggregatelist.append(item)
objects = list() objects = list()
for item in aggregate: for item in aggregatelist:
get_value = partial(get_param_value, item=item, module=module) get_value = partial(get_param_value, item=item, module=module)
item['password'] = get_value('password') item['password'] = get_value('password')
item['full_name'] = get_value('full_name') item['full_name'] = get_value('full_name')

View file

@ -1,5 +1,13 @@
--- ---
- name: Create user (SetUp) - name: Setup
vyos_config:
lines:
- delete system login user ansibletest1
- delete system login user ansibletest2
- delete system login user ansibletest3
provider: "{{ cli }}"
- name: Create user
vyos_user: vyos_user:
name: ansibletest1 name: ansibletest1
password: test password: test