ipaclient_get_otp: Fix documentation sections and agument spec

ansible-test with ansible-2.14 is adding a lot of new tests to ensure
that the documentation section and the agument spec is complete. Needed
changes:

DOCUMENTATION section

- `type: str` needs to be set for string parameters
- `type: list` needs to be set for list parameters
- `elements: str` needs to be given for list of string parameters
- `required` tags need to be fixed according to the `argument_spec`
- `default` tag needs to match `argument_spec`
- `author` needs to be given with the github user also: `Name (@user)`
- `choices` needs to match `argument_spec`

RETURN section

- `type: string` is not valid and needs to be replaced by `type: str`
- `elements: str` needs to be given for list of string parameters

argument_spec

- `type='str'` needs to be set for string parameters
- `elements='str'` needs to be added to all list of string parameters

A call to ansible_ipa_client.check_imports has been added to check for import
errors.

The `copyright` date is extended with `-2022`.
This commit is contained in:
Thomas Woerner
2022-11-07 13:38:21 +01:00
parent c633b2dc88
commit e932f65b7c

View File

@@ -3,7 +3,7 @@
# Authors: # Authors:
# Florence Blanc-Renaud <frenaud@redhat.com> # Florence Blanc-Renaud <frenaud@redhat.com>
# #
# Copyright (C) 2017 Red Hat # Copyright (C) 2017-2022 Red Hat
# see file 'COPYING' for use and warranty information # see file 'COPYING' for use and warranty information
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
@@ -40,31 +40,44 @@ options:
principal: principal:
description: description:
User Principal allowed to promote replicas and join IPA realm User Principal allowed to promote replicas and join IPA realm
required: yes type: str
required: no
default: admin
ccache: ccache:
description: The local ccache description: The local ccache
required: yes type: path
required: no
fqdn: fqdn:
description: description:
The fully-qualified hostname of the host to add/modify/remove The fully-qualified hostname of the host to add/modify/remove
required: no type: str
required: yes
certificates: certificates:
description: A list of host certificates description: A list of host certificates
required: yes type: list
elements: str
required: no
sshpubkey: sshpubkey:
description: The SSH public key for the host description: The SSH public key for the host
required: yes type: str
required: no
ipaddress: ipaddress:
description: The IP address for the host description: The IP address for the host
required: yes type: str
required: no
random: random:
description: Generate a random password to be used in bulk enrollment description: Generate a random password to be used in bulk enrollment
required: yes type: bool
required: no
default: no
state: state:
description: The desired host state description: The desired host state
required: yes type: str
choices: ['present', 'absent']
default: present
required: no
author: author:
- "Florence Blanc-Renaud" - Florence Blanc-Renaud (@flo-renaud)
''' '''
EXAMPLES = ''' EXAMPLES = '''
@@ -87,11 +100,11 @@ host:
contains: contains:
dn: dn:
description: the DN of the host entry description: the DN of the host entry
type: string type: str
returned: always returned: always
fqdn: fqdn:
description: the fully qualified host name description: the fully qualified host name
type: string type: str
returned: always returned: always
has_keytab: has_keytab:
description: whether the host entry contains a keytab description: whether the host entry contains a keytab
@@ -107,19 +120,20 @@ host:
returned: always returned: always
randompassword: randompassword:
description: the OneTimePassword generated for this host description: the OneTimePassword generated for this host
type: string type: str
returned: changed returned: changed
certificates: certificates:
description: the list of host certificates description: the list of host certificates
type: list type: list
elements: str
returned: when present returned: when present
sshpubkey: sshpubkey:
description: the SSH public key for the host description: the SSH public key for the host
type: string type: str
returned: when present returned: when present
ipaddress: ipaddress:
description: the IP address for the host description: the IP address for the host
type: string type: str
returned: when present returned: when present
''' '''
@@ -128,9 +142,9 @@ import os
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils import six from ansible.module_utils import six
from ipalib import api, errors from ansible.module_utils.ansible_ipa_client import (
from ipaplatform.paths import paths check_imports, api, errors, paths, run
from ipapython.ipautil import run )
if six.PY3: if six.PY3:
unicode = str unicode = str
@@ -276,18 +290,21 @@ def main():
module = AnsibleModule( module = AnsibleModule(
argument_spec=dict( argument_spec=dict(
principal=dict(default='admin'), principal=dict(required=False, type='str', default='admin'),
ccache=dict(required=False, type='path'), ccache=dict(required=False, type='path'),
fqdn=dict(required=True), fqdn=dict(required=True, type='str'),
certificates=dict(required=False, type='list'), certificates=dict(required=False, type='list', elements='str'),
sshpubkey=dict(required=False), sshpubkey=dict(required=False, type='str'),
ipaddress=dict(required=False), ipaddress=dict(required=False, type='str'),
random=dict(default=False, type='bool'), random=dict(required=False, type='bool', default=False),
state=dict(default='present', choices=['present', 'absent']), state=dict(required=False, type='str',
choices=['present', 'absent'], default='present'),
), ),
supports_check_mode=True, supports_check_mode=True,
) )
check_imports(module)
ccache = module.params.get('ccache') ccache = module.params.get('ccache')
fqdn = unicode(module.params.get('fqdn')) fqdn = unicode(module.params.get('fqdn'))
state = module.params.get('state') state = module.params.get('state')