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
|
description: User name
|
||||||
required: true
|
required: true
|
||||||
type: str
|
type: str
|
||||||
|
user_password:
|
||||||
|
description: user password
|
||||||
|
required: true
|
||||||
|
type: str
|
||||||
permissions:
|
permissions:
|
||||||
description: permissions given to user
|
description: permissions given to user
|
||||||
required: true
|
required: true
|
||||||
|
@ -53,6 +57,7 @@ EXAMPLES = r'''
|
||||||
zephir_user: admin_zephir
|
zephir_user: admin_zephir
|
||||||
zephir_user_password: eole
|
zephir_user_password: eole
|
||||||
user: admin
|
user: admin
|
||||||
|
user_password: admin
|
||||||
permissions:
|
permissions:
|
||||||
- "Lecture"
|
- "Lecture"
|
||||||
'''
|
'''
|
||||||
|
@ -75,6 +80,7 @@ from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
||||||
from zephir.eolerpclib import EoleProxy
|
from zephir.eolerpclib import EoleProxy
|
||||||
from zephir.web import config
|
from zephir.web import config
|
||||||
|
from zephir.utils.ldap_user import add_user, encrypt_passwd
|
||||||
|
|
||||||
def run_module():
|
def run_module():
|
||||||
# define available arguments/parameters a user can pass to the 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=dict(type='str', required=True),
|
||||||
zephir_user_password=dict(type='str', required=True),
|
zephir_user_password=dict(type='str', required=True),
|
||||||
user=dict(type='str', required=True),
|
user=dict(type='str', required=True),
|
||||||
|
user_password=dict(type='str', required=True),
|
||||||
permissions=dict(type='list', required=True),
|
permissions=dict(type='list', required=True),
|
||||||
state=dict(type='str', required=False, default='present'),
|
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_addr = "http://{0}:{1}@localhost:{2}/".format(module.params['zephir_user'], module.params['zephir_user_password'], port_zephir)
|
||||||
proxy = EoleProxy(proxy_addr)
|
proxy = EoleProxy(proxy_addr)
|
||||||
|
|
||||||
|
add_user(module.params['user'], encrypt_passwd(module.params['user_password']))
|
||||||
|
|
||||||
return_code, permissions = proxy.get_permissions(module.params['user'])
|
return_code, permissions = proxy.get_permissions(module.params['user'])
|
||||||
if return_code:
|
if return_code:
|
||||||
result['user'] = module.params['user']
|
result['user'] = module.params['user']
|
||||||
|
|
Loading…
Reference in New Issue