From 5db9ac23ee37dea480749bee4f3b7a96e1f60a4c Mon Sep 17 00:00:00 2001 From: Abhijeet Kasurde Date: Wed, 20 Dec 2017 21:29:52 +0530 Subject: [PATCH] freeipa: Refactor ipa_dnszone (#34078) Code refactoring of ipa_dnszone module - use ipa_argument_spec - use common documentation fragment Signed-off-by: Abhijeet Kasurde --- .../modules/identity/ipa/ipa_dnszone.py | 62 +++---------------- 1 file changed, 10 insertions(+), 52 deletions(-) diff --git a/lib/ansible/modules/identity/ipa/ipa_dnszone.py b/lib/ansible/modules/identity/ipa/ipa_dnszone.py index a5d9bcb442c..d01d785719d 100644 --- a/lib/ansible/modules/identity/ipa/ipa_dnszone.py +++ b/lib/ansible/modules/identity/ipa/ipa_dnszone.py @@ -29,33 +29,7 @@ options: required: false default: present choices: ["present", "absent"] - ipa_port: - description: Port of IPA server - required: false - default: 443 - ipa_host: - description: IP or hostname of IPA server - required: false - default: localhost - 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 +extends_documentation_fragment: ipa.documentation version_added: "2.5" ''' @@ -84,7 +58,7 @@ zone: ''' 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 @@ -135,30 +109,14 @@ def ensure(module, client): def main(): - module = AnsibleModule( - argument_spec=dict( - zone_name=dict(type='str', required=True), - ipa_prot=dict( - type='str', - default='https', - choices=['http', 'https'] - ), - ipa_host=dict( - type='str', - default='localhost' - ), - state=dict( - type='str', - default='present', - choices=['present', 'absent'] - ), - 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), - ), - supports_check_mode=True, - ) + argument_spec = ipa_argument_spec() + argument_spec.update(zone_name=dict(type='str', required=True), + state=dict(type='str', default='present', choices=['present', 'absent']), + ) + + module = AnsibleModule(argument_spec=argument_spec, + supports_check_mode=True, + ) client = DNSZoneIPAClient( module=module,