Créer l’utilisateur si il n’existe pas (ou mettre à jour son mot de passe)
This commit is contained in:
parent
f5ef8983d8
commit
1ea786ecb4
|
@ -29,6 +29,10 @@ options:
|
|||
description: User name
|
||||
required: true
|
||||
type: str
|
||||
user_password:
|
||||
description: user password
|
||||
required: true
|
||||
type: str
|
||||
permissions:
|
||||
description: permissions given to user
|
||||
required: true
|
||||
|
@ -53,6 +57,7 @@ EXAMPLES = r'''
|
|||
zephir_user: admin_zephir
|
||||
zephir_user_password: eole
|
||||
user: admin
|
||||
user_password: admin
|
||||
permissions:
|
||||
- "Lecture"
|
||||
'''
|
||||
|
@ -75,6 +80,7 @@ from ansible.module_utils.basic import AnsibleModule
|
|||
|
||||
from zephir.eolerpclib import EoleProxy
|
||||
from zephir.web import config
|
||||
from zephir.utils.ldap_user import add_user, encrypt_passwd
|
||||
|
||||
def run_module():
|
||||
# define available arguments/parameters a user can pass to the module
|
||||
|
@ -105,6 +111,7 @@ def run_module():
|
|||
zephir_user=dict(type='str', required=True),
|
||||
zephir_user_password=dict(type='str', required=True),
|
||||
user=dict(type='str', required=True),
|
||||
user_password=dict(type='str', required=True),
|
||||
permissions=dict(type='list', required=True),
|
||||
state=dict(type='str', required=False, default='present'),
|
||||
)
|
||||
|
@ -138,6 +145,8 @@ def run_module():
|
|||
proxy_addr = "http://{0}:{1}@localhost:{2}/".format(module.params['zephir_user'], module.params['zephir_user_password'], port_zephir)
|
||||
proxy = EoleProxy(proxy_addr)
|
||||
|
||||
add_user(module.params['user'], encrypt_passwd(module.params['user_password']))
|
||||
|
||||
return_code, permissions = proxy.get_permissions(module.params['user'])
|
||||
if return_code:
|
||||
result['user'] = module.params['user']
|
||||
|
|
Loading…
Reference in New Issue