dnsimple: fix missing defaults and doc (#58116)

* dnsimple: fix missing defaults and doc

* fix sanity
This commit is contained in:
René Moser 2019-06-26 13:21:13 +02:00 committed by GitHub
parent 7d6f417f32
commit f2cc447b4d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 23 deletions

View file

@ -29,44 +29,56 @@ options:
description: description:
- Account email. If omitted, the environment variables C(DNSIMPLE_EMAIL) and C(DNSIMPLE_API_TOKEN) will be looked for. - Account email. If omitted, the environment variables C(DNSIMPLE_EMAIL) and C(DNSIMPLE_API_TOKEN) will be looked for.
- "If those aren't found, a C(.dnsimple) file will be looked for, see: U(https://github.com/mikemaccana/dnsimple-python#getting-started)." - "If those aren't found, a C(.dnsimple) file will be looked for, see: U(https://github.com/mikemaccana/dnsimple-python#getting-started)."
type: str
account_api_token: account_api_token:
description: description:
- Account API token. See I(account_email) for more information. - Account API token. See I(account_email) for more information.
type: str
domain: domain:
description: description:
- Domain to work with. Can be the domain name (e.g. "mydomain.com") or the numeric ID of the domain in DNSimple. - Domain to work with. Can be the domain name (e.g. "mydomain.com") or the numeric ID of the domain in DNSimple.
- If omitted, a list of domains will be returned. - If omitted, a list of domains will be returned.
- If domain is present but the domain doesn't exist, it will be created. - If domain is present but the domain doesn't exist, it will be created.
type: str
record: record:
description: description:
- Record to add, if blank a record for the domain will be created, supports the wildcard (*). - Record to add, if blank a record for the domain will be created, supports the wildcard (*).
type: str
record_ids: record_ids:
description: description:
- List of records to ensure they either exist or do not exist. - List of records to ensure they either exist or do not exist.
type: list
type: type:
description: description:
- The type of DNS record to create. - The type of DNS record to create.
choices: [ 'A', 'ALIAS', 'CNAME', 'MX', 'SPF', 'URL', 'TXT', 'NS', 'SRV', 'NAPTR', 'PTR', 'AAAA', 'SSHFP', 'HINFO', 'POOL' ] choices: [ 'A', 'ALIAS', 'CNAME', 'MX', 'SPF', 'URL', 'TXT', 'NS', 'SRV', 'NAPTR', 'PTR', 'AAAA', 'SSHFP', 'HINFO', 'POOL' ]
type: str
ttl: ttl:
description: description:
- The TTL to give the new record in seconds. - The TTL to give the new record in seconds.
default: 3600 default: 3600
type: int
value: value:
description: description:
- Record value. - Record value.
- Must be specified when trying to ensure a record exists. - Must be specified when trying to ensure a record exists.
type: str
priority: priority:
description: description:
- Record priority. - Record priority.
type: int
state: state:
description: description:
- whether the record should exist or not. - whether the record should exist or not.
choices: [ 'present', 'absent' ] choices: [ 'present', 'absent' ]
default: present
type: str
solo: solo:
description: description:
- Whether the record should be the only one for that record type and record name. - Whether the record should be the only one for that record type and record name.
- Only use with C(state) is set to C(present) on a record. - Only use with C(state) is set to C(present) on a record.
type: 'bool' type: 'bool'
default: no
requirements: requirements:
- "dnsimple >= 1.0.0" - "dnsimple >= 1.0.0"
author: "Alex Coomans (@drcapulet)" author: "Alex Coomans (@drcapulet)"
@ -159,18 +171,18 @@ from ansible.module_utils.basic import AnsibleModule, missing_required_lib
def main(): def main():
module = AnsibleModule( module = AnsibleModule(
argument_spec=dict( argument_spec=dict(
account_email=dict(required=False), account_email=dict(type='str'),
account_api_token=dict(required=False, no_log=True), account_api_token=dict(type='str', no_log=True),
domain=dict(required=False), domain=dict(type='str'),
record=dict(required=False), record=dict(type='str'),
record_ids=dict(required=False, type='list'), record_ids=dict(type='list'),
type=dict(required=False, choices=['A', 'ALIAS', 'CNAME', 'MX', 'SPF', 'URL', 'TXT', 'NS', 'SRV', 'NAPTR', 'PTR', 'AAAA', 'SSHFP', 'HINFO', type=dict(type='str', choices=['A', 'ALIAS', 'CNAME', 'MX', 'SPF', 'URL', 'TXT', 'NS', 'SRV', 'NAPTR', 'PTR', 'AAAA', 'SSHFP', 'HINFO',
'POOL']), 'POOL']),
ttl=dict(required=False, default=3600, type='int'), ttl=dict(type='int', default=3600),
value=dict(required=False), value=dict(type='str'),
priority=dict(required=False, type='int'), priority=dict(type='int'),
state=dict(required=False, choices=['present', 'absent']), state=dict(type='str', choices=['present', 'absent'], default='present'),
solo=dict(required=False, type='bool'), solo=dict(type='bool', default=False),
), ),
required_together=[ required_together=[
['record', 'value'] ['record', 'value']
@ -227,15 +239,15 @@ def main():
module.exit_json(changed=True) module.exit_json(changed=True)
else: else:
module.exit_json(changed=True, result=client.add_domain(domain)['domain']) module.exit_json(changed=True, result=client.add_domain(domain)['domain'])
elif state == 'absent':
# state is absent
else:
if dr: if dr:
if not module.check_mode: if not module.check_mode:
client.delete(domain) client.delete(domain)
module.exit_json(changed=True) module.exit_json(changed=True)
else: else:
module.exit_json(changed=False) module.exit_json(changed=False)
else:
module.fail_json(msg="'%s' is an unknown value for the state argument" % state)
# need the not none check since record could be an empty string # need the not none check since record could be an empty string
if domain and record is not None: if domain and record is not None:
@ -290,15 +302,15 @@ def main():
module.exit_json(changed=True) module.exit_json(changed=True)
else: else:
module.exit_json(changed=True, result=client.add_record(str(domain), data)['record']) module.exit_json(changed=True, result=client.add_record(str(domain), data)['record'])
elif state == 'absent':
# state is absent
else:
if rr: if rr:
if not module.check_mode: if not module.check_mode:
client.delete_record(str(domain), rr['id']) client.delete_record(str(domain), rr['id'])
module.exit_json(changed=True) module.exit_json(changed=True)
else: else:
module.exit_json(changed=False) module.exit_json(changed=False)
else:
module.fail_json(msg="'%s' is an unknown value for the state argument" % state)
# Make sure these record_ids either all exist or none # Make sure these record_ids either all exist or none
if domain and record_ids: if domain and record_ids:
@ -310,7 +322,9 @@ def main():
module.fail_json(msg="Missing the following records: %s" % difference) module.fail_json(msg="Missing the following records: %s" % difference)
else: else:
module.exit_json(changed=False) module.exit_json(changed=False)
elif state == 'absent':
# state is absent
else:
difference = list(set(wanted_records) & set(current_records)) difference = list(set(wanted_records) & set(current_records))
if difference: if difference:
if not module.check_mode: if not module.check_mode:
@ -319,8 +333,6 @@ def main():
module.exit_json(changed=True) module.exit_json(changed=True)
else: else:
module.exit_json(changed=False) module.exit_json(changed=False)
else:
module.fail_json(msg="'%s' is an unknown value for the state argument" % state)
except DNSimpleException as e: except DNSimpleException as e:
module.fail_json(msg="Unable to contact DNSimple: %s" % e.message) module.fail_json(msg="Unable to contact DNSimple: %s" % e.message)

View file

@ -1603,8 +1603,6 @@ lib/ansible/modules/monitoring/zabbix/zabbix_template.py E338
lib/ansible/modules/net_tools/basics/get_url.py E337 lib/ansible/modules/net_tools/basics/get_url.py E337
lib/ansible/modules/net_tools/basics/uri.py E337 lib/ansible/modules/net_tools/basics/uri.py E337
lib/ansible/modules/net_tools/cloudflare_dns.py E337 lib/ansible/modules/net_tools/cloudflare_dns.py E337
lib/ansible/modules/net_tools/dnsimple.py E337
lib/ansible/modules/net_tools/dnsimple.py E338
lib/ansible/modules/net_tools/dnsmadeeasy.py E337 lib/ansible/modules/net_tools/dnsmadeeasy.py E337
lib/ansible/modules/net_tools/dnsmadeeasy.py E338 lib/ansible/modules/net_tools/dnsmadeeasy.py E338
lib/ansible/modules/net_tools/ipinfoio_facts.py E337 lib/ansible/modules/net_tools/ipinfoio_facts.py E337