Skip to content

Commit

Permalink
ipa_user: Add userauthtype param (#951) (#1004)
Browse files Browse the repository at this point in the history
* ipa_user: Add userauthtype param

* Add changelog fragment

* Update changelogs/fragments/951-ipa_user-add-userauthtype-param.yaml

Co-authored-by: Andrew Klychkov <[email protected]>

* Update plugins/modules/identity/ipa/ipa_user.py

Co-authored-by: Andrew Klychkov <[email protected]>

* ipa_user: Add example for userauthtype

Co-authored-by: Lina He <[email protected]>
Co-authored-by: Andrew Klychkov <[email protected]>
(cherry picked from commit 104f6a3)

Co-authored-by: Lina He <[email protected]>
  • Loading branch information
patchback[bot] and linahe authored Sep 29, 2020
1 parent 0baceda commit c00147e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
3 changes: 3 additions & 0 deletions changelogs/fragments/951-ipa_user-add-userauthtype-param.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
minor_changes:
- "ipa_user - add ``userauthtype`` option (https://github.com/ansible-collections/community.general/pull/951)."
27 changes: 24 additions & 3 deletions plugins/modules/identity/ipa/ipa_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@
- Default home directory of the user.
type: str
version_added: '0.2.0'
userauthtype:
description:
- The authentication type to use for the user.
choices: ["password", "radius", "otp", "pkinit", "hardened"]
type: str
version_added: '1.2.0'
extends_documentation_fragment:
- community.general.ipa.documentation
Expand Down Expand Up @@ -139,6 +145,15 @@
ipa_user: admin
ipa_pass: topsecret
update_password: on_create
- name: Ensure pinky is present and using one time password authentication
community.general.ipa_user:
name: pinky
state: present
userauthtype: otp
ipa_host: ipa.example.com
ipa_user: admin
ipa_pass: topsecret
'''

RETURN = r'''
Expand Down Expand Up @@ -182,7 +197,8 @@ def user_enable(self, name):

def get_user_dict(displayname=None, givenname=None, krbpasswordexpiration=None, loginshell=None,
mail=None, nsaccountlock=False, sn=None, sshpubkey=None, telephonenumber=None,
title=None, userpassword=None, gidnumber=None, uidnumber=None, homedirectory=None):
title=None, userpassword=None, gidnumber=None, uidnumber=None, homedirectory=None,
userauthtype=None):
user = {}
if displayname is not None:
user['displayname'] = displayname
Expand Down Expand Up @@ -211,6 +227,8 @@ def get_user_dict(displayname=None, givenname=None, krbpasswordexpiration=None,
user['uidnumber'] = uidnumber
if homedirectory is not None:
user['homedirectory'] = homedirectory
if userauthtype is not None:
user['ipauserauthtype'] = userauthtype

return user

Expand Down Expand Up @@ -293,7 +311,8 @@ def ensure(module, client):
telephonenumber=module.params['telephonenumber'], title=module.params['title'],
userpassword=module.params['password'],
gidnumber=module.params.get('gidnumber'), uidnumber=module.params.get('uidnumber'),
homedirectory=module.params.get('homedirectory'))
homedirectory=module.params.get('homedirectory'),
userauthtype=module.params.get('userauthtype'))

update_password = module.params.get('update_password')
ipa_user = client.user_find(name=name)
Expand Down Expand Up @@ -340,7 +359,9 @@ def main():
choices=['present', 'absent', 'enabled', 'disabled']),
telephonenumber=dict(type='list', elements='str'),
title=dict(type='str'),
homedirectory=dict(type='str'))
homedirectory=dict(type='str'),
userauthtype=dict(type='str',
choices=['password', 'radius', 'otp', 'pkinit', 'hardened']))

module = AnsibleModule(argument_spec=argument_spec,
supports_check_mode=True)
Expand Down

0 comments on commit c00147e

Please sign in to comment.