| 1 |
#!/usr/bin/python |
| 2 |
# Copyright (c) 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_zone_info |
| 10 |
|
| 11 |
short_description: Retrieve zone information in Hosttech DNS service |
| 12 |
|
| 13 |
version_added: 0.2.0 |
| 14 |
|
| 15 |
description: |
| 16 |
- Retrieves zone information in Hosttech DNS service. |
| 17 |
extends_documentation_fragment: |
| 18 |
- community.dns._hosttech |
| 19 |
- community.dns._hosttech.zone_id_type |
| 20 |
- community.dns._module_zone_info |
| 21 |
- community.dns._attributes |
| 22 |
- community.dns._attributes.actiongroup_hosttech |
| 23 |
- community.dns._attributes.info_module |
| 24 |
- community.dns._attributes.idempotent_not_modify_state |
| 25 |
|
| 26 |
attributes: |
| 27 |
action_group: |
| 28 |
version_added: 2.4.0 |
| 29 |
|
| 30 |
author: |
| 31 |
- Felix Fontein (@felixfontein) |
| 32 |
""" |
| 33 |
|
| 34 |
EXAMPLES = r""" |
| 35 |
- name: Retrieve details for foo.com zone |
| 36 |
community.dns.hosttech_dns_zone_info: |
| 37 |
zone_name: foo.com |
| 38 |
hosttech_username: foo |
| 39 |
hosttech_password: bar |
| 40 |
register: rec |
| 41 |
|
| 42 |
- name: Retrieve details for zone 23 |
| 43 |
community.dns.hosttech_dns_zone_info: |
| 44 |
zone_id: 23 |
| 45 |
hosttech_token: access_token |
| 46 |
""" |
| 47 |
|
| 48 |
RETURN = r""" |
| 49 |
zone_name: |
| 50 |
description: The name of the zone. |
| 51 |
type: int |
| 52 |
returned: success |
| 53 |
sample: example.com |
| 54 |
|
| 55 |
zone_id: |
| 56 |
description: The ID of the zone. |
| 57 |
type: int |
| 58 |
returned: success |
| 59 |
sample: 23 |
| 60 |
|
| 61 |
zone_info: |
| 62 |
description: |
| 63 |
- Extra information returned by the API. |
| 64 |
type: dict |
| 65 |
returned: success |
| 66 |
version_added: 2.0.0 |
| 67 |
sample: |
| 68 |
dnssec: true |
| 69 |
dnssec_email: [email protected] |
| 70 |
ds_records: [] |
| 71 |
email: [email protected] |
| 72 |
ttl: 3600 |
| 73 |
contains: |
| 74 |
dnssec: |
| 75 |
description: |
| 76 |
- Whether DNSSEC is enabled for the zone or not. |
| 77 |
type: bool |
| 78 |
returned: When O(hosttech_token) has been specified. |
| 79 |
dnssec_email: |
| 80 |
description: |
| 81 |
- The email address contacted when the DNSSEC key is changed. |
| 82 |
- Is V(none) if DNSSEC is not enabled. |
| 83 |
type: str |
| 84 |
returned: When O(hosttech_token) has been specified. |
| 85 |
ds_records: |
| 86 |
description: |
| 87 |
- The DS records. |
| 88 |
- See L(Section 5 of RFC 4034,https://datatracker.ietf.org/doc/html/rfc4034#section-5) and |
| 89 |
L(Section 2.1 of RFC 4034,https://datatracker.ietf.org/doc/html/rfc4034#section-2.1) for details. |
| 90 |
- Is V(none) if DNSSEC is not enabled. |
| 91 |
type: list |
| 92 |
elements: dict |
| 93 |
returned: When O(hosttech_token) has been specified. |
| 94 |
contains: |
| 95 |
algorithm: |
| 96 |
description: |
| 97 |
- This value is the algorithm number of the DNSKEY RR referred to by the DS record. |
| 98 |
- A list of values can be found in L(Appendix A.1 of RFC 4034,https://datatracker.ietf.org/doc/html/rfc4034#appendix-A.1). |
| 99 |
type: int |
| 100 |
sample: 8 |
| 101 |
digest: |
| 102 |
description: |
| 103 |
- A digest of the DNSKEY RR record this DS record refers to. |
| 104 |
type: str |
| 105 |
sample: 012356789ABCDEF0123456789ABCDEF012345678 |
| 106 |
digest_type: |
| 107 |
description: |
| 108 |
- This value identifies the algorithm used to construct the digest. |
| 109 |
- A list of values can be found in L(Appendix A.2 of RFC 4034,https://datatracker.ietf.org/doc/html/rfc4034#appendix-A.2). |
| 110 |
type: int |
| 111 |
sample: 1 |
| 112 |
flags: |
| 113 |
description: |
| 114 |
- The Zone Key flag. See L(Section 2.1.1 of RFC 4034,https://datatracker.ietf.org/doc/html/rfc4034#section-2.1.1) |
| 115 |
for details. |
| 116 |
type: int |
| 117 |
sample: 257 |
| 118 |
key_tag: |
| 119 |
description: |
| 120 |
- The Key Tag field lists the key tag of the DNSKEY RR referred to by the DS record. |
| 121 |
type: int |
| 122 |
sample: 12345 |
| 123 |
protocol: |
| 124 |
description: |
| 125 |
- Must be 3 according to RFC 4034. |
| 126 |
type: int |
| 127 |
sample: 3 |
| 128 |
public_key: |
| 129 |
description: |
| 130 |
- The public key material. |
| 131 |
type: str |
| 132 |
sample: >- |
| 133 |
MuhdzsQdqEGShwjtJDKZZjdKqUSGluFzTTinpuEeIRzLLcgkwgAPKWFa |
| 134 |
eQntNlmcNDeCziGwpdvhJnvKXEMbFcZwsaDIJuWqERxAQNGABWfPlCLh |
| 135 |
HQPnbpRPNKipSdBaUhuOubvFvjBpFAwiwSAapRDVsAgKvjXucfXpFfYb |
| 136 |
pCundbAXBWhbpHVbqgmGoixXzFSwUsGVYLPpBCiDlLJwzjRKYYaoVYge |
| 137 |
kMtKFYUVnWIKbectWkDFdVqXwkKigCUDiuTTJxOBRJRNzGiDNMWBjYSm |
| 138 |
bBCAHMaMYaghLbYTwyKXltdHTHwBwtswGNfpnEdSpKFzZJonBZArQfHD |
| 139 |
lfceKgmKwEF= |
| 140 |
email: |
| 141 |
description: |
| 142 |
- The zone's DNS contact mail in the SOA record. |
| 143 |
type: str |
| 144 |
ttl: |
| 145 |
description: |
| 146 |
- The zone's TTL. |
| 147 |
type: int |
| 148 |
""" |
| 149 |
|
| 150 |
from ansible.module_utils.basic import AnsibleModule |
| 151 |
|
| 152 |
from ansible_collections.community.dns.plugins.module_utils._argspec import ( |
| 153 |
ModuleOptionProvider, |
| 154 |
) |
| 155 |
from ansible_collections.community.dns.plugins.module_utils._hosttech.api import ( |
| 156 |
create_hosttech_api, |
| 157 |
create_hosttech_argument_spec, |
| 158 |
create_hosttech_provider_information, |
| 159 |
) |
| 160 |
from ansible_collections.community.dns.plugins.module_utils._http import ( |
| 161 |
ModuleHTTPHelper, |
| 162 |
) |
| 163 |
from ansible_collections.community.dns.plugins.module_utils._module.zone_info import ( |
| 164 |
create_module_argument_spec, |
| 165 |
run_module, |
| 166 |
) |
| 167 |
|
| 168 |
|
| 169 |
def main() -> None: |
| 170 |
provider_information = create_hosttech_provider_information() |
| 171 |
argument_spec = create_hosttech_argument_spec() |
| 172 |
argument_spec.merge( |
| 173 |
create_module_argument_spec(provider_information=provider_information) |
| 174 |
) |
| 175 |
module = AnsibleModule(supports_check_mode=True, **argument_spec.to_kwargs()) |
| 176 |
run_module( |
| 177 |
module, |
| 178 |
lambda: create_hosttech_api( |
| 179 |
ModuleOptionProvider(module), ModuleHTTPHelper(module) |
| 180 |
), |
| 181 |
provider_information=provider_information, |
| 182 |
) |
| 183 |
|
| 184 |
|
| 185 |
if __name__ == "__main__": |
| 186 |
main() |