Debian Codegraph @

ansible_collections/community/dns/plugins/modules/hosttech_dns_record.py

raw
1 #!/usr/bin/python
2 # Copyright (c) 2017-2021 Felix Fontein
3 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
4 # SPDX-License-Identifier: GPL-3.0-or-later
5
6 from __future__ import annotations
7
8 DOCUMENTATION = r"""
9 module: hosttech_dns_record
10
11 short_description: Add or delete a single record in Hosttech DNS service
12
13 version_added: 2.0.0
14
15 description:
16 - Creates and deletes single DNS records in Hosttech DNS service.
17 - This module replaces C(hosttech_dns_record) from community.dns before 2.0.0.
18 - If you do not want to add/remove values, but replace values, you will be interested in modifying a B(record set) and not
19 a single record. This is in particular important when working with C(CNAME) and C(SOA) records. Use the M(community.dns.hosttech_dns_record_set)
20 module for working with record sets.
21 extends_documentation_fragment:
22 - community.dns._hosttech
23 - community.dns._hosttech.record_default_ttl
24 - community.dns._hosttech.record_notes
25 - community.dns._hosttech.record_type_choices
26 - community.dns._hosttech.record_type_seealso
27 - community.dns._hosttech.zone_id_type
28 - community.dns._module_record
29 - community.dns._options.record_transformation
30 - community.dns._attributes
31 - community.dns._attributes.actiongroup_hosttech
32
33 attributes:
34 action_group:
35 version_added: 2.4.0
36
37 author:
38 - Felix Fontein (@felixfontein)
39 """
40
41 EXAMPLES = r"""
42 - name: Add a new.foo.com A record
43 community.dns.hosttech_dns_record:
44 state: present
45 zone: foo.com
46 record: new.foo.com
47 type: A
48 ttl: 7200
49 value: 1.1.1.1
50 hosttech_token: access_token
51
52 - name: Remove a new.foo.com A record
53 community.dns.hosttech_dns_record:
54 state: absent
55 zone_name: foo.com
56 record: new.foo.com
57 type: A
58 ttl: 7200
59 value: 2.2.2.2
60 hosttech_token: access_token
61 """
62
63 RETURN = r"""
64 zone_id:
65 description: The ID of the zone.
66 type: int
67 returned: success
68 sample: 23
69 """
70
71 from ansible.module_utils.basic import AnsibleModule
72
73 from ansible_collections.community.dns.plugins.module_utils._argspec import (
74 ModuleOptionProvider,
75 )
76 from ansible_collections.community.dns.plugins.module_utils._hosttech.api import (
77 create_hosttech_api,
78 create_hosttech_argument_spec,
79 create_hosttech_provider_information,
80 )
81 from ansible_collections.community.dns.plugins.module_utils._http import (
82 ModuleHTTPHelper,
83 )
84 from ansible_collections.community.dns.plugins.module_utils._module.record import (
85 create_module_argument_spec,
86 run_module,
87 )
88
89
90 def main() -> None:
91 provider_information = create_hosttech_provider_information()
92 argument_spec = create_hosttech_argument_spec()
93 argument_spec.merge(
94 create_module_argument_spec(provider_information=provider_information)
95 )
96 module = AnsibleModule(supports_check_mode=True, **argument_spec.to_kwargs())
97 run_module(
98 module,
99 lambda: create_hosttech_api(
100 ModuleOptionProvider(module), ModuleHTTPHelper(module)
101 ),
102 provider_information=provider_information,
103 )
104
105
106 if __name__ == "__main__":
107 main()