From 49923edfba6d396140881d6a920e83f9ecf79f77 Mon Sep 17 00:00:00 2001 From: Kenny Woodson Date: Thu, 20 Aug 2015 11:44:27 -0400 Subject: fixed zbx_user. Update password playbook added --- roles/os_zabbix/library/zbx_user.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'roles/os_zabbix/library') diff --git a/roles/os_zabbix/library/zbx_user.py b/roles/os_zabbix/library/zbx_user.py index 50f6fc075..c45c9a75d 100644 --- a/roles/os_zabbix/library/zbx_user.py +++ b/roles/os_zabbix/library/zbx_user.py @@ -54,13 +54,15 @@ def get_usergroups(zapi, usergroups): if content['result']: ugroups.append({'usrgrpid': content['result'][0]['usrgrpid']}) - return ugroups - + return ugroups or None def get_usertype(user_type): ''' Determine zabbix user account type ''' + if not user_type: + return None + utype = 1 if 'super' in user_type: utype = 3 @@ -84,9 +86,9 @@ def main(): alias=dict(default=None, type='str'), name=dict(default=None, type='str'), surname=dict(default=None, type='str'), - user_type=dict(default='user', type='str'), + user_type=dict(default=None, type='str'), passwd=dict(default=None, type='str'), - usergroups=dict(default=None, type='list'), + usergroups=dict(default=[], type='list'), debug=dict(default=False, type='bool'), state=dict(default='present', type='str'), ), @@ -129,6 +131,9 @@ def main(): 'type': get_usertype(module.params['user_type']), } + # Remove any None valued params + _ = [params.pop(key, None) for key in params.keys() if params[key] is None] + if not exists(content): # if we didn't find it, create it content = zapi.get_content(zbx_class_name, 'create', params) -- cgit v1.2.3