shared argument spec for FreeIPA (#28950)

Adds unified argument spec and documentation updates for FreeIPA modules.

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
Abhijeet Kasurde 2017-09-08 00:37:15 +05:30 committed by René Moser
parent 67c7bd8745
commit 4a73390823
12 changed files with 197 additions and 537 deletions

View file

@ -155,3 +155,14 @@ class IPAClient(object):
add_method(name=name, item=diff) add_method(name=name, item=diff)
return changed return changed
def ipa_argument_spec():
return dict(
ipa_prot=dict(type='str', default='https', choices=['http', 'https']),
ipa_host=dict(type='str', default='ipa.example.com'),
ipa_port=dict(type='int', default=443),
ipa_user=dict(type='str', default='admin'),
ipa_pass=dict(type='str', required=True, no_log=True),
validate_certs=dict(type='bool', default=True),
)

View file

@ -46,33 +46,7 @@ options:
required: false required: false
default: present default: present
choices: ["present", "absent"] choices: ["present", "absent"]
ipa_port: extends_documentation_fragment: ipa.documentation
description: Port of IPA server
required: false
default: 443
ipa_host:
description: IP or hostname of IPA server
required: false
default: ipa.example.com
ipa_user:
description: Administrative account used on IPA server
required: false
default: admin
ipa_pass:
description: Password of administrative user
required: true
ipa_prot:
description: Protocol used by IPA server
required: false
default: https
choices: ["http", "https"]
validate_certs:
description:
- This only applies if C(ipa_prot) is I(https).
- If set to C(no), the SSL certificates will not be validated.
- This should only set to C(no) used on personally controlled sites using self-signed certificates.
required: false
default: true
version_added: "2.4" version_added: "2.4"
''' '''
@ -119,7 +93,7 @@ dnsrecord:
import traceback import traceback
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.ipa import IPAClient from ansible.module_utils.ipa import IPAClient, ipa_argument_spec
from ansible.module_utils._text import to_native from ansible.module_utils._text import to_native
@ -206,22 +180,17 @@ def ensure(module, client):
def main(): def main():
record_types = ['A', 'AAAA', 'PTR'] record_types = ['A', 'AAAA', 'PTR']
module = AnsibleModule( argument_spec = ipa_argument_spec()
argument_spec=dict( argument_spec.update(zone_name=dict(type='str', required=True),
zone_name=dict(type='str', required=True), record_name=dict(type='str', aliases=['name'], required=True),
record_name=dict(type='str', required=True, aliases=['name']), record_type=dict(type='str', default='A', choices=record_types),
record_type=dict(type='str', required=False, default='A', choices=record_types), record_value=dict(type='str', required=True),
record_value=dict(type='str', required=True), state=dict(type='str', default='present', choices=['present', 'absent']),
state=dict(type='str', required=False, default='present', choices=['present', 'absent']), )
ipa_prot=dict(type='str', required=False, default='https', choices=['http', 'https']),
ipa_host=dict(type='str', required=False, default='ipa.example.com'), module = AnsibleModule(argument_spec=argument_spec,
ipa_port=dict(type='int', required=False, default=443), supports_check_mode=True
ipa_user=dict(type='str', required=False, default='admin'), )
ipa_pass=dict(type='str', required=True, no_log=True),
validate_certs=dict(type='bool', required=False, default=True),
),
supports_check_mode=True,
)
client = DNSRecordIPAClient(module=module, client = DNSRecordIPAClient(module=module,
host=module.params['ipa_host'], host=module.params['ipa_host'],

View file

@ -27,11 +27,9 @@ options:
external: external:
description: description:
- Allow adding external non-IPA members from trusted domains. - Allow adding external non-IPA members from trusted domains.
required: false
gidnumber: gidnumber:
description: description:
- GID (use this option to set it manually). - GID (use this option to set it manually).
required: false
group: group:
description: description:
- List of group names assigned to this group. - List of group names assigned to this group.
@ -41,7 +39,6 @@ options:
nonposix: nonposix:
description: description:
- Create as a non-POSIX group. - Create as a non-POSIX group.
required: false
user: user:
description: description:
- List of user names assigned to this group. - List of user names assigned to this group.
@ -51,36 +48,9 @@ options:
state: state:
description: description:
- State to ensure - State to ensure
required: false
default: "present" default: "present"
choices: ["present", "absent"] choices: ["present", "absent"]
ipa_port: extends_documentation_fragment: ipa.documentation
description: Port of IPA server
required: false
default: 443
ipa_host:
description: IP or hostname of IPA server
required: false
default: "ipa.example.com"
ipa_user:
description: Administrative account used on IPA server
required: false
default: "admin"
ipa_pass:
description: Password of administrative user
required: true
ipa_prot:
description: Protocol used by IPA server
required: false
default: "https"
choices: ["http", "https"]
validate_certs:
description:
- This only applies if C(ipa_prot) is I(https).
- If set to C(no), the SSL certificates will not be validated.
- This should only set to C(no) used on personally controlled sites using self-signed certificates.
required: false
default: true
version_added: "2.3" version_added: "2.3"
''' '''
@ -133,7 +103,7 @@ group:
import traceback import traceback
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.ipa import IPAClient from ansible.module_utils.ipa import IPAClient, ipa_argument_spec
from ansible.module_utils._text import to_native from ansible.module_utils._text import to_native
@ -247,25 +217,19 @@ def ensure(module, client):
def main(): def main():
module = AnsibleModule( argument_spec = ipa_argument_spec()
argument_spec=dict( argument_spec.update(cn=dict(type='str', required=True, aliases=['name']),
cn=dict(type='str', required=True, aliases=['name']), description=dict(type='str'),
description=dict(type='str', required=False), external=dict(type='bool'),
external=dict(type='bool', required=False), gidnumber=dict(type='str', aliases=['gid']),
gidnumber=dict(type='str', required=False, aliases=['gid']), group=dict(type='list'),
group=dict(type='list', required=False), nonposix=dict(type='bool'),
nonposix=dict(type='bool', required=False), state=dict(type='str', default='present', choices=['present', 'absent']),
state=dict(type='str', required=False, default='present', choices=['present', 'absent']), user=dict(type='list'))
user=dict(type='list', required=False),
ipa_prot=dict(type='str', required=False, default='https', choices=['http', 'https']), module = AnsibleModule(argument_spec=argument_spec,
ipa_host=dict(type='str', required=False, default='ipa.example.com'), supports_check_mode=True,
ipa_port=dict(type='int', required=False, default=443), )
ipa_user=dict(type='str', required=False, default='admin'),
ipa_pass=dict(type='str', required=True, no_log=True),
validate_certs=dict(type='bool', required=False, default=True),
),
supports_check_mode=True,
)
client = GroupIPAClient(module=module, client = GroupIPAClient(module=module,
host=module.params['ipa_host'], host=module.params['ipa_host'],

View file

@ -27,7 +27,6 @@ options:
aliases: ["name"] aliases: ["name"]
description: description:
description: Description description: Description
required: false
host: host:
description: description:
- List of host names to assign. - List of host names to assign.
@ -36,7 +35,6 @@ options:
required: false required: false
hostcategory: hostcategory:
description: Host category description: Host category
required: false
choices: ['all'] choices: ['all']
hostgroup: hostgroup:
description: description:
@ -50,7 +48,6 @@ options:
- If option is omitted services will not be checked or changed. - If option is omitted services will not be checked or changed.
servicecategory: servicecategory:
description: Service category description: Service category
required: false
choices: ['all'] choices: ['all']
servicegroup: servicegroup:
description: description:
@ -64,7 +61,6 @@ options:
- If option is omitted source hosts will not be checked or changed. - If option is omitted source hosts will not be checked or changed.
sourcehostcategory: sourcehostcategory:
description: Source host category description: Source host category
required: false
choices: ['all'] choices: ['all']
sourcehostgroup: sourcehostgroup:
description: description:
@ -73,7 +69,6 @@ options:
- If option is omitted source host groups will not be checked or changed. - If option is omitted source host groups will not be checked or changed.
state: state:
description: State to ensure description: State to ensure
required: false
default: "present" default: "present"
choices: ["present", "absent", "enabled", "disabled"] choices: ["present", "absent", "enabled", "disabled"]
user: user:
@ -83,40 +78,13 @@ options:
- If option is omitted users will not be checked or changed. - If option is omitted users will not be checked or changed.
usercategory: usercategory:
description: User category description: User category
required: false
choices: ['all'] choices: ['all']
usergroup: usergroup:
description: description:
- List of user group names to assign. - List of user group names to assign.
- If an empty list if passed all assigned user groups will be removed from the rule. - If an empty list if passed all assigned user groups will be removed from the rule.
- If option is omitted user groups will not be checked or changed. - If option is omitted user groups will not be checked or changed.
ipa_port: extends_documentation_fragment: ipa.documentation
description: Port of IPA server
required: false
default: 443
ipa_host:
description: IP or hostname of IPA server
required: false
default: "ipa.example.com"
ipa_user:
description: Administrative account used on IPA server
required: false
default: "admin"
ipa_pass:
description: Password of administrative user
required: true
ipa_prot:
description: Protocol used by IPA server
required: false
default: "https"
choices: ["http", "https"]
validate_certs:
description:
- This only applies if C(ipa_prot) is I(https).
- If set to C(no), the SSL certificates will not be validated.
- This should only set to C(no) used on personally controlled sites using self-signed certificates.
required: false
default: true
version_added: "2.3" version_added: "2.3"
''' '''
@ -165,7 +133,7 @@ hbacrule:
import traceback import traceback
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.ipa import IPAClient from ansible.module_utils.ipa import IPAClient, ipa_argument_spec
from ansible.module_utils._text import to_native from ansible.module_utils._text import to_native
@ -329,33 +297,26 @@ def ensure(module, client):
def main(): def main():
module = AnsibleModule( argument_spec = ipa_argument_spec()
argument_spec=dict( argument_spec.update(cn=dict(type='str', required=True, aliases=['name']),
cn=dict(type='str', required=True, aliases=['name']), description=dict(type='str'),
description=dict(type='str', required=False), host=dict(type='list'),
host=dict(type='list', required=False), hostcategory=dict(type='str', choices=['all']),
hostcategory=dict(type='str', required=False, choices=['all']), hostgroup=dict(type='list'),
hostgroup=dict(type='list', required=False), service=dict(type='list'),
service=dict(type='list', required=False), servicecategory=dict(type='str', choices=['all']),
servicecategory=dict(type='str', required=False, choices=['all']), servicegroup=dict(type='list'),
servicegroup=dict(type='list', required=False), sourcehost=dict(type='list'),
sourcehost=dict(type='list', required=False), sourcehostcategory=dict(type='str', choices=['all']),
sourcehostcategory=dict(type='str', required=False, choices=['all']), sourcehostgroup=dict(type='list'),
sourcehostgroup=dict(type='list', required=False), state=dict(type='str', default='present', choices=['present', 'absent', 'enabled', 'disabled']),
state=dict(type='str', required=False, default='present', user=dict(type='list'),
choices=['present', 'absent', 'enabled', 'disabled']), usercategory=dict(type='str', choices=['all']),
user=dict(type='list', required=False), usergroup=dict(type='list'))
usercategory=dict(type='str', required=False, choices=['all']),
usergroup=dict(type='list', required=False), module = AnsibleModule(argument_spec=argument_spec,
ipa_prot=dict(type='str', required=False, default='https', choices=['http', 'https']), supports_check_mode=True
ipa_host=dict(type='str', required=False, default='ipa.example.com'), )
ipa_port=dict(type='int', required=False, default=443),
ipa_user=dict(type='str', required=False, default='admin'),
ipa_pass=dict(type='str', required=True, no_log=True),
validate_certs=dict(type='bool', required=False, default=True),
),
supports_check_mode=True,
)
client = HBACRuleIPAClient(module=module, client = HBACRuleIPAClient(module=module,
host=module.params['ipa_host'], host=module.params['ipa_host'],

View file

@ -28,7 +28,6 @@ options:
description: description:
description: description:
- A description of this host. - A description of this host.
required: false
force: force:
description: description:
- Force host name even if not in DNS. - Force host name even if not in DNS.
@ -36,29 +35,24 @@ options:
ip_address: ip_address:
description: description:
- Add the host to DNS with this IP address. - Add the host to DNS with this IP address.
required: false
mac_address: mac_address:
description: description:
- List of Hardware MAC address(es) off this host. - List of Hardware MAC address(es) off this host.
- If option is omitted MAC addresses will not be checked or changed. - If option is omitted MAC addresses will not be checked or changed.
- If an empty list is passed all assigned MAC addresses will be removed. - If an empty list is passed all assigned MAC addresses will be removed.
- MAC addresses that are already assigned but not passed will be removed. - MAC addresses that are already assigned but not passed will be removed.
required: false
aliases: ["macaddress"] aliases: ["macaddress"]
ns_host_location: ns_host_location:
description: description:
- Host location (e.g. "Lab 2") - Host location (e.g. "Lab 2")
required: false
aliases: ["nshostlocation"] aliases: ["nshostlocation"]
ns_hardware_platform: ns_hardware_platform:
description: description:
- Host hardware platform (e.g. "Lenovo T61") - Host hardware platform (e.g. "Lenovo T61")
required: false
aliases: ["nshardwareplatform"] aliases: ["nshardwareplatform"]
ns_os_version: ns_os_version:
description: description:
- Host operating system and version (e.g. "Fedora 9") - Host operating system and version (e.g. "Fedora 9")
required: false
aliases: ["nsosversion"] aliases: ["nsosversion"]
user_certificate: user_certificate:
description: description:
@ -66,40 +60,12 @@ options:
- If option is omitted certificates will not be checked or changed. - If option is omitted certificates will not be checked or changed.
- If an empty list is passed all assigned certificates will be removed. - If an empty list is passed all assigned certificates will be removed.
- Certificates already assigned but not passed will be removed. - Certificates already assigned but not passed will be removed.
required: false
aliases: ["usercertificate"] aliases: ["usercertificate"]
state: state:
description: State to ensure description: State to ensure
required: false
default: present default: present
choices: ["present", "absent", "disabled"] choices: ["present", "absent", "disabled"]
ipa_port: extends_documentation_fragment: ipa.documentation
description: Port of IPA server
required: false
default: 443
ipa_host:
description: IP or hostname of IPA server
required: false
default: ipa.example.com
ipa_user:
description: Administrative account used on IPA server
required: false
default: admin
ipa_pass:
description: Password of administrative user
required: true
ipa_prot:
description: Protocol used by IPA server
required: false
default: https
choices: ["http", "https"]
validate_certs:
description:
- This only applies if C(ipa_prot) is I(https).
- If set to C(no), the SSL certificates will not be validated.
- This should only set to C(no) used on personally controlled sites using self-signed certificates.
required: false
default: true
version_added: "2.3" version_added: "2.3"
''' '''
@ -159,7 +125,7 @@ host_diff:
import traceback import traceback
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.ipa import IPAClient from ansible.module_utils.ipa import IPAClient, ipa_argument_spec
from ansible.module_utils._text import to_native from ansible.module_utils._text import to_native
@ -252,28 +218,20 @@ def ensure(module, client):
def main(): def main():
module = AnsibleModule( argument_spec = ipa_argument_spec()
argument_spec=dict( argument_spec.update(description=dict(type='str'),
description=dict(type='str', required=False), fqdn=dict(type='str', required=True, aliases=['name']),
fqdn=dict(type='str', required=True, aliases=['name']), force=dict(type='bool'),
force=dict(type='bool', required=False), ip_address=dict(type='str'),
ip_address=dict(type='str', required=False), ns_host_location=dict(type='str', aliases=['nshostlocation']),
ns_host_location=dict(type='str', required=False, aliases=['nshostlocation']), ns_hardware_platform=dict(type='str', aliases=['nshardwareplatform']),
ns_hardware_platform=dict(type='str', required=False, aliases=['nshardwareplatform']), ns_os_version=dict(type='str', aliases=['nsosversion']),
ns_os_version=dict(type='str', required=False, aliases=['nsosversion']), user_certificate=dict(type='list', aliases=['usercertificate']),
user_certificate=dict(type='list', required=False, aliases=['usercertificate']), mac_address=dict(type='list', aliases=['macaddress']),
mac_address=dict(type='list', required=False, aliases=['macaddress']), state=dict(type='str', default='present', choices=['present', 'absent', 'enabled', 'disabled']))
state=dict(type='str', required=False, default='present',
choices=['present', 'absent', 'enabled', 'disabled']), module = AnsibleModule(argument_spec=argument_spec,
ipa_prot=dict(type='str', required=False, default='https', choices=['http', 'https']), supports_check_mode=True)
ipa_host=dict(type='str', required=False, default='ipa.example.com'),
ipa_port=dict(type='int', required=False, default=443),
ipa_user=dict(type='str', required=False, default='admin'),
ipa_pass=dict(type='str', required=True, no_log=True),
validate_certs=dict(type='bool', required=False, default=True),
),
supports_check_mode=True,
)
client = HostIPAClient(module=module, client = HostIPAClient(module=module,
host=module.params['ipa_host'], host=module.params['ipa_host'],

View file

@ -28,54 +28,24 @@ options:
description: description:
description: description:
- Description - Description
required: false
host: host:
description: description:
- List of hosts that belong to the host-group. - List of hosts that belong to the host-group.
- If an empty list is passed all hosts will be removed from the group. - If an empty list is passed all hosts will be removed from the group.
- If option is omitted hosts will not be checked or changed. - If option is omitted hosts will not be checked or changed.
- If option is passed all assigned hosts that are not passed will be unassigned from the group. - If option is passed all assigned hosts that are not passed will be unassigned from the group.
required: false
hostgroup: hostgroup:
description: description:
- List of host-groups than belong to that host-group. - List of host-groups than belong to that host-group.
- If an empty list is passed all host-groups will be removed from the group. - If an empty list is passed all host-groups will be removed from the group.
- If option is omitted host-groups will not be checked or changed. - If option is omitted host-groups will not be checked or changed.
- If option is passed all assigned hostgroups that are not passed will be unassigned from the group. - If option is passed all assigned hostgroups that are not passed will be unassigned from the group.
required: false
state: state:
description: description:
- State to ensure. - State to ensure.
required: false
default: "present" default: "present"
choices: ["present", "absent"] choices: ["present", "absent"]
ipa_port: extends_documentation_fragment: ipa.documentation
description: Port of IPA server
required: false
default: 443
ipa_host:
description: IP or hostname of IPA server
required: false
default: "ipa.example.com"
ipa_user:
description: Administrative account used on IPA server
required: false
default: "admin"
ipa_pass:
description: Password of administrative user
required: true
ipa_prot:
description: Protocol used by IPA server
required: false
default: "https"
choices: ["http", "https"]
validate_certs:
description:
- This only applies if C(ipa_prot) is I(https).
- If set to C(no), the SSL certificates will not be validated.
- This should only set to C(no) used on personally controlled sites using self-signed certificates.
required: false
default: true
version_added: "2.3" version_added: "2.3"
''' '''
@ -112,7 +82,7 @@ hostgroup:
import traceback import traceback
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.ipa import IPAClient from ansible.module_utils.ipa import IPAClient, ipa_argument_spec
from ansible.module_utils._text import to_native from ansible.module_utils._text import to_native
@ -207,23 +177,15 @@ def ensure(module, client):
def main(): def main():
module = AnsibleModule( argument_spec = ipa_argument_spec()
argument_spec=dict( argument_spec.update(cn=dict(type='str', required=True, aliases=['name']),
cn=dict(type='str', required=True, aliases=['name']), description=dict(type='str'),
description=dict(type='str', required=False), host=dict(type='list'),
host=dict(type='list', required=False), hostgroup=dict(type='list'),
hostgroup=dict(type='list', required=False), state=dict(type='str', default='present', choices=['present', 'absent', 'enabled', 'disabled']))
state=dict(type='str', required=False, default='present',
choices=['present', 'absent', 'enabled', 'disabled']), module = AnsibleModule(argument_spec=argument_spec,
ipa_prot=dict(type='str', required=False, default='https', choices=['http', 'https']), supports_check_mode=True)
ipa_host=dict(type='str', required=False, default='ipa.example.com'),
ipa_port=dict(type='int', required=False, default=443),
ipa_user=dict(type='str', required=False, default='admin'),
ipa_pass=dict(type='str', required=True, no_log=True),
validate_certs=dict(type='bool', required=False, default=True),
),
supports_check_mode=True,
)
client = HostGroupIPAClient(module=module, client = HostGroupIPAClient(module=module,
host=module.params['ipa_host'], host=module.params['ipa_host'],

View file

@ -28,7 +28,6 @@ options:
description: description:
description: description:
- A description of this role-group. - A description of this role-group.
required: false
group: group:
description: description:
- List of group names assign to this role. - List of group names assign to this role.
@ -41,21 +40,18 @@ options:
- If an empty list is passed all assigned hosts will be unassigned from the role. - If an empty list is passed all assigned hosts will be unassigned from the role.
- If option is omitted hosts will not be checked or changed. - If option is omitted hosts will not be checked or changed.
- If option is passed all assigned hosts that are not passed will be unassigned from the role. - If option is passed all assigned hosts that are not passed will be unassigned from the role.
required: false
hostgroup: hostgroup:
description: description:
- List of host group names to assign. - List of host group names to assign.
- If an empty list is passed all assigned host groups will be removed from the role. - If an empty list is passed all assigned host groups will be removed from the role.
- If option is omitted host groups will not be checked or changed. - If option is omitted host groups will not be checked or changed.
- If option is passed all assigned hostgroups that are not passed will be unassigned from the role. - If option is passed all assigned hostgroups that are not passed will be unassigned from the role.
required: false
privilege: privilege:
description: description:
- List of privileges granted to the role. - List of privileges granted to the role.
- If an empty list is passed all assigned privileges will be removed. - If an empty list is passed all assigned privileges will be removed.
- If option is omitted privileges will not be checked or changed. - If option is omitted privileges will not be checked or changed.
- If option is passed all assigned privileges that are not passed will be removed. - If option is passed all assigned privileges that are not passed will be removed.
required: false
default: None default: None
version_added: "2.4" version_added: "2.4"
service: service:
@ -64,10 +60,8 @@ options:
- If an empty list is passed all assigned services will be removed from the role. - If an empty list is passed all assigned services will be removed from the role.
- If option is omitted services will not be checked or changed. - If option is omitted services will not be checked or changed.
- If option is passed all assigned services that are not passed will be removed from the role. - If option is passed all assigned services that are not passed will be removed from the role.
required: false
state: state:
description: State to ensure description: State to ensure
required: false
default: "present" default: "present"
choices: ["present", "absent"] choices: ["present", "absent"]
user: user:
@ -75,34 +69,7 @@ options:
- List of user names to assign. - List of user names to assign.
- If an empty list is passed all assigned users will be removed from the role. - If an empty list is passed all assigned users will be removed from the role.
- If option is omitted users will not be checked or changed. - If option is omitted users will not be checked or changed.
required: false extends_documentation_fragment: ipa.documentation
ipa_port:
description: Port of IPA server
required: false
default: 443
ipa_host:
description: IP or hostname of IPA server
required: false
default: "ipa.example.com"
ipa_user:
description: Administrative account used on IPA server
required: false
default: "admin"
ipa_pass:
description: Password of administrative user
required: true
ipa_prot:
description: Protocol used by IPA server
required: false
default: "https"
choices: ["http", "https"]
validate_certs:
description:
- This only applies if C(ipa_prot) is I(https).
- If set to C(no), the SSL certificates will not be validated.
- This should only set to C(no) used on personally controlled sites using self-signed certificates.
required: false
default: true
version_added: "2.3" version_added: "2.3"
''' '''
@ -154,7 +121,7 @@ role:
import traceback import traceback
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.ipa import IPAClient from ansible.module_utils.ipa import IPAClient, ipa_argument_spec
from ansible.module_utils._text import to_native from ansible.module_utils._text import to_native
@ -294,26 +261,19 @@ def ensure(module, client):
def main(): def main():
module = AnsibleModule( argument_spec = ipa_argument_spec()
argument_spec=dict( argument_spec.update(cn=dict(type='str', required=True, aliases=['name']),
cn=dict(type='str', required=True, aliases=['name']), description=dict(type='str'),
description=dict(type='str', required=False), group=dict(type='list'),
group=dict(type='list', required=False), host=dict(type='list'),
host=dict(type='list', required=False), hostgroup=dict(type='list'),
hostgroup=dict(type='list', required=False), privilege=dict(type='list'),
privilege=dict(type='list', required=False), service=dict(type='list'),
service=dict(type='list', required=False), state=dict(type='str', default='present', choices=['present', 'absent']),
state=dict(type='str', required=False, default='present', choices=['present', 'absent']), user=dict(type='list'))
user=dict(type='list', required=False),
ipa_prot=dict(type='str', required=False, default='https', choices=['http', 'https']), module = AnsibleModule(argument_spec=argument_spec,
ipa_host=dict(type='str', required=False, default='ipa.example.com'), supports_check_mode=True)
ipa_port=dict(type='int', required=False, default=443),
ipa_user=dict(type='str', required=False, default='admin'),
ipa_pass=dict(type='str', required=True, no_log=True),
validate_certs=dict(type='bool', required=False, default=True),
),
supports_check_mode=True,
)
client = RoleIPAClient(module=module, client = RoleIPAClient(module=module,
host=module.params['ipa_host'], host=module.params['ipa_host'],

View file

@ -27,39 +27,11 @@ options:
description: description:
description: description:
- A description of this command. - A description of this command.
required: false
state: state:
description: State to ensure description: State to ensure
required: false
default: present default: present
choices: ['present', 'absent'] choices: ['present', 'absent']
ipa_port: extends_documentation_fragment: ipa.documentation
description: Port of IPA server
required: false
default: 443
ipa_host:
description: IP or hostname of IPA server
required: false
default: "ipa.example.com"
ipa_user:
description: Administrative account used on IPA server
required: false
default: "admin"
ipa_pass:
description: Password of administrative user
required: true
ipa_prot:
description: Protocol used by IPA server
required: false
default: "https"
choices: ["http", "https"]
validate_certs:
description:
- This only applies if C(ipa_prot) is I(https).
- If set to C(no), the SSL certificates will not be validated.
- This should only set to C(no) used on personally controlled sites using self-signed certificates.
required: false
default: true
version_added: "2.3" version_added: "2.3"
''' '''
@ -91,7 +63,7 @@ sudocmd:
import traceback import traceback
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.ipa import IPAClient from ansible.module_utils.ipa import IPAClient, ipa_argument_spec
from ansible.module_utils._text import to_native from ansible.module_utils._text import to_native
@ -155,21 +127,13 @@ def ensure(module, client):
def main(): def main():
module = AnsibleModule( argument_spec = ipa_argument_spec()
argument_spec=dict( argument_spec.update(description=dict(type='str'),
description=dict(type='str', required=False), state=dict(type='str', default='present', choices=['present', 'absent', 'enabled', 'disabled']),
state=dict(type='str', required=False, default='present', sudocmd=dict(type='str', required=True, aliases=['name']))
choices=['present', 'absent', 'enabled', 'disabled']),
sudocmd=dict(type='str', required=True, aliases=['name']), module = AnsibleModule(argument_spec=argument_spec,
ipa_prot=dict(type='str', required=False, default='https', choices=['http', 'https']), supports_check_mode=True)
ipa_host=dict(type='str', required=False, default='ipa.example.com'),
ipa_port=dict(type='int', required=False, default=443),
ipa_user=dict(type='str', required=False, default='admin'),
ipa_pass=dict(type='str', required=True, no_log=True),
validate_certs=dict(type='bool', required=False, default=True),
),
supports_check_mode=True,
)
client = SudoCmdIPAClient(module=module, client = SudoCmdIPAClient(module=module,
host=module.params['ipa_host'], host=module.params['ipa_host'],

View file

@ -29,7 +29,6 @@ options:
- Group description. - Group description.
state: state:
description: State to ensure description: State to ensure
required: false
default: present default: present
choices: ['present', 'absent'] choices: ['present', 'absent']
sudocmd: sudocmd:
@ -37,34 +36,7 @@ options:
- List of sudo commands to assign to the group. - List of sudo commands to assign to the group.
- If an empty list is passed all assigned commands will be removed from the group. - If an empty list is passed all assigned commands will be removed from the group.
- If option is omitted sudo commands will not be checked or changed. - If option is omitted sudo commands will not be checked or changed.
required: false extends_documentation_fragment: ipa.documentation
ipa_port:
description: Port of IPA server
required: false
default: 443
ipa_host:
description: IP or hostname of IPA server
required: false
default: "ipa.example.com"
ipa_user:
description: Administrative account used on IPA server
required: false
default: "admin"
ipa_pass:
description: Password of administrative user
required: true
ipa_prot:
description: Protocol used by IPA server
required: false
default: "https"
choices: ["http", "https"]
validate_certs:
description:
- This only applies if C(ipa_prot) is I(https).
- If set to C(no), the SSL certificates will not be validated.
- This should only set to C(no) used on personally controlled sites using self-signed certificates.
required: false
default: true
version_added: "2.3" version_added: "2.3"
''' '''
@ -98,7 +70,7 @@ sudocmdgroup:
import traceback import traceback
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.ipa import IPAClient from ansible.module_utils.ipa import IPAClient, ipa_argument_spec
from ansible.module_utils._text import to_native from ansible.module_utils._text import to_native
@ -180,22 +152,14 @@ def ensure(module, client):
def main(): def main():
module = AnsibleModule( argument_spec = ipa_argument_spec()
argument_spec=dict( argument_spec.update(cn=dict(type='str', required=True, aliases=['name']),
cn=dict(type='str', required=True, aliases=['name']), description=dict(type='str'),
description=dict(type='str', required=False), state=dict(type='str', default='present', choices=['present', 'absent', 'enabled', 'disabled']),
state=dict(type='str', required=False, default='present', sudocmd=dict(type='list'))
choices=['present', 'absent', 'enabled', 'disabled']),
sudocmd=dict(type='list', required=False), module = AnsibleModule(argument_spec=argument_spec,
ipa_prot=dict(type='str', required=False, default='https', choices=['http', 'https']), supports_check_mode=True)
ipa_host=dict(type='str', required=False, default='ipa.example.com'),
ipa_port=dict(type='int', required=False, default=443),
ipa_user=dict(type='str', required=False, default='admin'),
ipa_pass=dict(type='str', required=True, no_log=True),
validate_certs=dict(type='bool', required=False, default=True),
),
supports_check_mode=True,
)
client = SudoCmdGroupIPAClient(module=module, client = SudoCmdGroupIPAClient(module=module,
host=module.params['ipa_host'], host=module.params['ipa_host'],

View file

@ -29,83 +29,48 @@ options:
description: description:
- Command category the rule applies to. - Command category the rule applies to.
choices: ['all'] choices: ['all']
required: false
cmd: cmd:
description: description:
- List of commands assigned to the rule. - List of commands assigned to the rule.
- If an empty list is passed all commands will be removed from the rule. - If an empty list is passed all commands will be removed from the rule.
- If option is omitted commands will not be checked or changed. - If option is omitted commands will not be checked or changed.
required: false
host: host:
description: description:
- List of hosts assigned to the rule. - List of hosts assigned to the rule.
- If an empty list is passed all hosts will be removed from the rule. - If an empty list is passed all hosts will be removed from the rule.
- If option is omitted hosts will not be checked or changed. - If option is omitted hosts will not be checked or changed.
- Option C(hostcategory) must be omitted to assign hosts. - Option C(hostcategory) must be omitted to assign hosts.
required: false
hostcategory: hostcategory:
description: description:
- Host category the rule applies to. - Host category the rule applies to.
- If 'all' is passed one must omit C(host) and C(hostgroup). - If 'all' is passed one must omit C(host) and C(hostgroup).
- Option C(host) and C(hostgroup) must be omitted to assign 'all'. - Option C(host) and C(hostgroup) must be omitted to assign 'all'.
choices: ['all'] choices: ['all']
required: false
hostgroup: hostgroup:
description: description:
- List of host groups assigned to the rule. - List of host groups assigned to the rule.
- If an empty list is passed all host groups will be removed from the rule. - If an empty list is passed all host groups will be removed from the rule.
- If option is omitted host groups will not be checked or changed. - If option is omitted host groups will not be checked or changed.
- Option C(hostcategory) must be omitted to assign host groups. - Option C(hostcategory) must be omitted to assign host groups.
required: false
user: user:
description: description:
- List of users assigned to the rule. - List of users assigned to the rule.
- If an empty list is passed all users will be removed from the rule. - If an empty list is passed all users will be removed from the rule.
- If option is omitted users will not be checked or changed. - If option is omitted users will not be checked or changed.
required: false
usercategory: usercategory:
description: description:
- User category the rule applies to. - User category the rule applies to.
choices: ['all'] choices: ['all']
required: false
usergroup: usergroup:
description: description:
- List of user groups assigned to the rule. - List of user groups assigned to the rule.
- If an empty list is passed all user groups will be removed from the rule. - If an empty list is passed all user groups will be removed from the rule.
- If option is omitted user groups will not be checked or changed. - If option is omitted user groups will not be checked or changed.
required: false
state: state:
description: State to ensure description: State to ensure
required: false
default: present default: present
choices: ['present', 'absent', 'enabled', 'disabled'] choices: ['present', 'absent', 'enabled', 'disabled']
ipa_port: extends_documentation_fragment: ipa.documentation
description: Port of IPA server
required: false
default: 443
ipa_host:
description: IP or hostname of IPA server
required: false
default: "ipa.example.com"
ipa_user:
description: Administrative account used on IPA server
required: false
default: "admin"
ipa_pass:
description: Password of administrative user
required: true
ipa_prot:
description: Protocol used by IPA server
required: false
default: "https"
choices: ["http", "https"]
validate_certs:
description:
- This only applies if C(ipa_prot) is I(https).
- If set to C(no), the SSL certificates will not be validated.
- This should only set to C(no) used on personally controlled sites using self-signed certificates.
required: false
default: true
version_added: "2.3" version_added: "2.3"
''' '''
@ -150,7 +115,7 @@ sudorule:
import traceback import traceback
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.ipa import IPAClient from ansible.module_utils.ipa import IPAClient, ipa_argument_spec
from ansible.module_utils._text import to_native from ansible.module_utils._text import to_native
@ -335,35 +300,27 @@ def ensure(module, client):
def main(): def main():
module = AnsibleModule( argument_spec = ipa_argument_spec()
argument_spec=dict( argument_spec.update(cmd=dict(type='list', required=False),
cmd=dict(type='list', required=False), cmdcategory=dict(type='str', required=False, choices=['all']),
cmdcategory=dict(type='str', required=False, choices=['all']), cn=dict(type='str', required=True, aliases=['name']),
cn=dict(type='str', required=True, aliases=['name']), description=dict(type='str', required=False),
description=dict(type='str', required=False), host=dict(type='list', required=False),
host=dict(type='list', required=False), hostcategory=dict(type='str', required=False, choices=['all']),
hostcategory=dict(type='str', required=False, choices=['all']), hostgroup=dict(type='list', required=False),
hostgroup=dict(type='list', required=False), sudoopt=dict(type='list', required=False),
sudoopt=dict(type='list', required=False), state=dict(type='str', required=False, default='present', choices=['present', 'absent', 'enabled', 'disabled']),
state=dict(type='str', required=False, default='present', user=dict(type='list', required=False),
choices=['present', 'absent', 'enabled', 'disabled']), usercategory=dict(type='str', required=False, choices=['all']),
user=dict(type='list', required=False), usergroup=dict(type='list', required=False))
usercategory=dict(type='str', required=False, choices=['all']),
usergroup=dict(type='list', required=False), module = AnsibleModule(argument_spec=argument_spec,
ipa_prot=dict(type='str', required=False, default='https', choices=['http', 'https']), mutually_exclusive=[['cmdcategory', 'cmd'],
ipa_host=dict(type='str', required=False, default='ipa.example.com'), ['hostcategory', 'host'],
ipa_port=dict(type='int', required=False, default=443), ['hostcategory', 'hostgroup'],
ipa_user=dict(type='str', required=False, default='admin'), ['usercategory', 'user'],
ipa_pass=dict(type='str', required=True, no_log=True), ['usercategory', 'usergroup']],
validate_certs=dict(type='bool', required=False, default=True), supports_check_mode=True)
),
mutually_exclusive=[['cmdcategory', 'cmd'],
['hostcategory', 'host'],
['hostcategory', 'hostgroup'],
['usercategory', 'user'],
['usercategory', 'usergroup']],
supports_check_mode=True,
)
client = SudoRuleIPAClient(module=module, client = SudoRuleIPAClient(module=module,
host=module.params['ipa_host'], host=module.params['ipa_host'],

View file

@ -21,35 +21,27 @@ description:
options: options:
displayname: displayname:
description: Display name description: Display name
required: false
givenname: givenname:
description: First name description: First name
required: false
loginshell: loginshell:
description: Login shell description: Login shell
required: false
mail: mail:
description: description:
- List of mail addresses assigned to the user. - List of mail addresses assigned to the user.
- If an empty list is passed all assigned email addresses will be deleted. - If an empty list is passed all assigned email addresses will be deleted.
- If None is passed email addresses will not be checked or changed. - If None is passed email addresses will not be checked or changed.
required: false
password: password:
description: description:
- Password - Password for new user
required: false
sn: sn:
description: Surname description: Surname
required: false
sshpubkey: sshpubkey:
description: description:
- List of public SSH key. - List of public SSH key.
- If an empty list is passed all assigned public keys will be deleted. - If an empty list is passed all assigned public keys will be deleted.
- If None is passed SSH public keys will not be checked or changed. - If None is passed SSH public keys will not be checked or changed.
required: false
state: state:
description: State to ensure description: State to ensure
required: false
default: "present" default: "present"
choices: ["present", "absent", "enabled", "disabled"] choices: ["present", "absent", "enabled", "disabled"]
telephonenumber: telephonenumber:
@ -57,41 +49,13 @@ options:
- List of telephone numbers assigned to the user. - List of telephone numbers assigned to the user.
- If an empty list is passed all assigned telephone numbers will be deleted. - If an empty list is passed all assigned telephone numbers will be deleted.
- If None is passed telephone numbers will not be checked or changed. - If None is passed telephone numbers will not be checked or changed.
required: false
title: title:
description: Title description: Title
required: false
uid: uid:
description: uid of the user description: uid of the user
required: true required: true
aliases: ["name"] aliases: ["name"]
ipa_port: extends_documentation_fragment: ipa.documentation
description: Port of IPA server
required: false
default: 443
ipa_host:
description: IP or hostname of IPA server
required: false
default: "ipa.example.com"
ipa_user:
description: Administrative account used on IPA server
required: false
default: "admin"
ipa_pass:
description: Password of administrative user
required: true
ipa_prot:
description: Protocol used by IPA server
required: false
default: "https"
choices: ["http", "https"]
validate_certs:
description:
- This only applies if C(ipa_prot) is I(https).
- If set to C(no), the SSL certificates will not be validated.
- This should only set to C(no) used on personally controlled sites using self-signed certificates.
required: false
default: true
version_added: "2.3" version_added: "2.3"
requirements: requirements:
- base64 - base64
@ -137,7 +101,7 @@ import hashlib
import traceback import traceback
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.ipa import IPAClient from ansible.module_utils.ipa import IPAClient, ipa_argument_spec
from ansible.module_utils._text import to_native from ansible.module_utils._text import to_native
@ -279,29 +243,22 @@ def ensure(module, client):
def main(): def main():
module = AnsibleModule( argument_spec = ipa_argument_spec()
argument_spec=dict( argument_spec.update(displayname=dict(type='str'),
displayname=dict(type='str', required=False), givenname=dict(type='str'),
givenname=dict(type='str', required=False), loginshell=dict(type='str'),
loginshell=dict(type='str', required=False), mail=dict(type='list'),
mail=dict(type='list', required=False), sn=dict(type='str'),
sn=dict(type='str', required=False), uid=dict(type='str', required=True, aliases=['name']),
uid=dict(type='str', required=True, aliases=['name']), password=dict(type='str', no_log=True),
password=dict(type='str', required=False, no_log=True), sshpubkey=dict(type='list'),
sshpubkey=dict(type='list', required=False), state=dict(type='str', default='present',
state=dict(type='str', required=False, default='present', choices=['present', 'absent', 'enabled', 'disabled']),
choices=['present', 'absent', 'enabled', 'disabled']), telephonenumber=dict(type='list'),
telephonenumber=dict(type='list', required=False), title=dict(type='str'))
title=dict(type='str', required=False),
ipa_prot=dict(type='str', required=False, default='https', choices=['http', 'https']), module = AnsibleModule(argument_spec=argument_spec,
ipa_host=dict(type='str', required=False, default='ipa.example.com'), supports_check_mode=True)
ipa_port=dict(type='int', required=False, default=443),
ipa_user=dict(type='str', required=False, default='admin'),
ipa_pass=dict(type='str', required=True, no_log=True),
validate_certs=dict(type='bool', required=False, default=True),
),
supports_check_mode=True,
)
client = UserIPAClient(module=module, client = UserIPAClient(module=module,
host=module.params['ipa_host'], host=module.params['ipa_host'],

View file

@ -0,0 +1,33 @@
# Copyright (c) 2017, Ansible Project
# Copyright (c) 2017, Abhijeet Kasurde (akasurde@redhat.com)
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
class ModuleDocFragment(object):
# Parameters for FreeIPA/IPA modules
DOCUMENTATION = '''
options:
ipa_port:
description: Port of IPA server
default: 443
ipa_host:
description: IP or hostname of IPA server
default: ipa.example.com
ipa_user:
description: Administrative account used on IPA server
default: admin
ipa_pass:
description: Password of administrative user
required: true
ipa_prot:
description: Protocol used by IPA server
default: https
choices: ["http", "https"]
validate_certs:
description:
- This only applies if C(ipa_prot) is I(https).
- If set to C(no), the SSL certificates will not be validated.
- This should only set to C(no) used on personally controlled sites using self-signed certificates.
default: true
'''