[WIP] Add option to ipa_user for setting expiration date (#32369)

* Fixes #32058

* version_added
This commit is contained in:
akatch 2017-11-22 20:29:46 -06:00 committed by ansibot
parent 18a4cd3985
commit 3129cbb9e1

View file

@ -23,6 +23,12 @@ options:
description: Display name description: Display name
givenname: givenname:
description: First name description: First name
krbpasswordexpiration:
description:
- Date at which the user password will expire
- In the format YYYYMMddHHmmss
- e.g. 20180121182022 will expire on 21 January 2018 at 18:20:22
version_added: 2.5
loginshell: loginshell:
description: Login shell description: Login shell
mail: mail:
@ -75,6 +81,7 @@ EXAMPLES = '''
- ipa_user: - ipa_user:
name: pinky name: pinky
state: present state: present
krbpasswordexpiration: 20200119235959
givenname: Pinky givenname: Pinky
sn: Acme sn: Acme
mail: mail:
@ -138,11 +145,14 @@ class UserIPAClient(IPAClient):
return self._post_json(method='user_enable', name=name) return self._post_json(method='user_enable', name=name)
def get_user_dict(displayname=None, givenname=None, loginshell=None, mail=None, nsaccountlock=False, sn=None, def get_user_dict(displayname=None, givenname=None, krbpasswordexpiration=None, loginshell=None,
sshpubkey=None, telephonenumber=None, title=None, userpassword=None, gidnumber=None, uidnumber=None): mail=None, nsaccountlock=False, sn=None, sshpubkey=None, telephonenumber=None,
title=None, userpassword=None, gidnumber=None, uidnumber=None):
user = {} user = {}
if displayname is not None: if displayname is not None:
user['displayname'] = displayname user['displayname'] = displayname
if krbpasswordexpiration is not None:
user['krbpasswordexpiration'] = krbpasswordexpiration + "Z"
if givenname is not None: if givenname is not None:
user['givenname'] = givenname user['givenname'] = givenname
if loginshell is not None: if loginshell is not None:
@ -226,6 +236,7 @@ def ensure(module, client):
nsaccountlock = state == 'disabled' nsaccountlock = state == 'disabled'
module_user = get_user_dict(displayname=module.params.get('displayname'), module_user = get_user_dict(displayname=module.params.get('displayname'),
krbpasswordexpiration=module.params.get('krbpasswordexpiration'),
givenname=module.params.get('givenname'), givenname=module.params.get('givenname'),
loginshell=module.params['loginshell'], loginshell=module.params['loginshell'],
mail=module.params['mail'], sn=module.params['sn'], mail=module.params['mail'], sn=module.params['sn'],
@ -261,6 +272,7 @@ def main():
argument_spec = ipa_argument_spec() argument_spec = ipa_argument_spec()
argument_spec.update(displayname=dict(type='str'), argument_spec.update(displayname=dict(type='str'),
givenname=dict(type='str'), givenname=dict(type='str'),
krbpasswordexpiration=dict(type='str'),
loginshell=dict(type='str'), loginshell=dict(type='str'),
mail=dict(type='list'), mail=dict(type='list'),
sn=dict(type='str'), sn=dict(type='str'),