autonomic.gandi/library/gandi_dns.py

88 lines
1.9 KiB
Python
Raw Normal View History

2020-03-28 00:01:56 +00:00
#!/usr/bin/python3
2020-03-28 16:55:36 +00:00
import traceback
from subprocess import check_output
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
2020-03-28 00:01:56 +00:00
DOCUMENTATION = """
---
module: gandi_dns
2020-03-28 16:55:36 +00:00
short_description: Manage Gandi DNS entries.
requirements:
- python >= 3.8
- gandi.cli >= 1.5
author:
- Luke Murphy (@decentral1se)
options:
apirest_key:
description:
- The Gandi REST API key. It may also be specified by the C(APIREST_KEY)
environment variable. See U(https://github.com/Gandi/gandi.cli/blob/master/gandicli.man.rst#environment)
for more.
2020-03-28 16:55:36 +00:00
type: str
required: true
domain:
description: The domain name you're working with.
type: str
required: true
ipv4:
description: The IP v4 address that the domain refers to.
type: str
required: true
state:
description:
- The desired instance state.
type: str
choices:
- present
- absent
required: true
""" # noqa
2020-03-28 00:01:56 +00:00
EXAMPLES = """
- name: Create a new Gandi DNS entry
gandi_dns:
apirest_key: "{{ apirest_key }}"
domain: foobar.autonomic.zone
ipv4: 192.168.1.2
2020-03-28 16:55:36 +00:00
state: present
"""
RETURN = """
TODO
2020-03-28 00:01:56 +00:00
"""
2020-03-28 16:55:36 +00:00
GANDI_CLI_IMP_ERR = None
try:
from gandi import cli # noqa
HAS_GANDI_DEPENDENCY = True
except ImportError:
GANDI_IMP_ERR = traceback.format_exc()
HAS_GANDI_DEPENDENCY = False
def retrieve_domain(domain):
"""Retrieve information about an existing domain."""
output = subprocess.check_output(["gandi", ""])
2020-03-28 16:55:36 +00:00
2020-03-28 00:01:56 +00:00
def main():
2020-03-28 16:55:36 +00:00
"""Module entrypoint."""
2020-03-28 00:01:56 +00:00
module = AnsibleModule(argument_spec={})
2020-03-28 16:55:36 +00:00
if not HAS_GANDI_DEPENDENCY:
msg = missing_required_lib('gandi.cli')
module.fail_json(msg=msg, exception=GANDI_IMP_ERR)
if module.params['state'] == 'present':
domain = retrieve_domain(module.params['domain'])
if module.params['state'] == 'absent':
pass
2020-03-28 00:01:56 +00:00
if __name__ == "__main__":
main()