diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 12:04:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 12:04:41 +0000 |
commit | 975f66f2eebe9dadba04f275774d4ab83f74cf25 (patch) | |
tree | 89bd26a93aaae6a25749145b7e4bca4a1e75b2be /ansible_collections/community/dns/plugins/inventory | |
parent | Initial commit. (diff) | |
download | ansible-975f66f2eebe9dadba04f275774d4ab83f74cf25.tar.xz ansible-975f66f2eebe9dadba04f275774d4ab83f74cf25.zip |
Adding upstream version 7.7.0+dfsg.upstream/7.7.0+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/community/dns/plugins/inventory')
-rw-r--r-- | ansible_collections/community/dns/plugins/inventory/hetzner_dns_records.py | 94 | ||||
-rw-r--r-- | ansible_collections/community/dns/plugins/inventory/hosttech_dns_records.py | 101 |
2 files changed, 195 insertions, 0 deletions
diff --git a/ansible_collections/community/dns/plugins/inventory/hetzner_dns_records.py b/ansible_collections/community/dns/plugins/inventory/hetzner_dns_records.py new file mode 100644 index 000000000..970cd8631 --- /dev/null +++ b/ansible_collections/community/dns/plugins/inventory/hetzner_dns_records.py @@ -0,0 +1,94 @@ +# -*- coding: utf-8 -*- +# +# Copyright (c) 2021 Felix Fontein +# Copyright (c) 2020 Markus Bergholz <markuman+spambelongstogoogle@gmail.com> +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = ''' +name: hetzner_dns_records + +short_description: Create inventory from Hetzner DNS records + +version_added: 2.0.0 + +description: + - This plugin allows to create an inventory from Hetzner DNS records. + - >- + For Ansible to be able to identify a YAML file as an inventory for this plugin, the inventory file must contain + C(plugin: community.dns.hetzner_dns_records) and its filename must end with C(hetzner_dns.yaml) or C(hetzner_dns.yml) + +options: + plugin: + description: The name of this plugin. Should always be set to C(community.dns.hetzner_dns_records) for this plugin to recognize it as its own. + # TODO: add `required: true` in 3.0.0 + # required: true + choices: + - community.dns.hetzner_dns_records + type: str + +extends_documentation_fragment: + - community.dns.hetzner + - community.dns.hetzner.plugin + - community.dns.hetzner.record_type_choices_records_inventory + - community.dns.hetzner.zone_id_type + - community.dns.inventory_records + - community.dns.options.record_transformation + +notes: + - The provider-specific I(hetzner_token) option can be templated. + +author: + - Markus Bergholz (@markuman) <markuman+spambelongstogoogle@gmail.com> + - Felix Fontein (@felixfontein) + +seealso: + - module: community.dns.hetzner_dns_record_set_info + - module: community.dns.hetzner_dns_record_info +''' + +EXAMPLES = ''' +# filename must end with hetzner_dns.yaml or hetzner_dns.yml + +plugin: community.dns.hetzner_dns_records +zone_name: domain.de +filters: + type: + - TXT +txt_transformation: unquoted + +# You can also configure the token by putting secret value into this file, +# but this is discouraged. Use a lookup like below, or leave it away and +# set it with the HETZNER_DNS_TOKEN environment variable. +hetzner_token: >- + {{ (lookup('community.sops.sops', 'keys/hetzner.sops.yml') | from_yaml).hetzner_dns_token }} +''' + +from ansible_collections.community.dns.plugins.module_utils.http import ( + OpenURLHelper, +) + +from ansible_collections.community.dns.plugins.module_utils.hetzner.api import ( + create_hetzner_api, + create_hetzner_provider_information, +) + +from ansible_collections.community.dns.plugins.plugin_utils.templated_options import ( + TemplatedOptionProvider, +) + +from ansible_collections.community.dns.plugins.plugin_utils.inventory.records import ( + RecordsInventoryModule, +) + + +class InventoryModule(RecordsInventoryModule): + NAME = 'community.dns.hetzner_dns_records' + VALID_ENDINGS = ('hetzner_dns.yaml', 'hetzner_dns.yml') + + def setup_api(self): + self.provider_information = create_hetzner_provider_information() + self.api = create_hetzner_api(TemplatedOptionProvider(self, self.templar), OpenURLHelper()) diff --git a/ansible_collections/community/dns/plugins/inventory/hosttech_dns_records.py b/ansible_collections/community/dns/plugins/inventory/hosttech_dns_records.py new file mode 100644 index 000000000..aa840510d --- /dev/null +++ b/ansible_collections/community/dns/plugins/inventory/hosttech_dns_records.py @@ -0,0 +1,101 @@ +# -*- coding: utf-8 -*- +# +# Copyright (c) 2021 Felix Fontein +# Copyright (c) 2020 Markus Bergholz <markuman+spambelongstogoogle@gmail.com> +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = ''' +name: hosttech_dns_records + +short_description: Create inventory from Hosttech DNS records + +version_added: 2.0.0 + +description: + - This plugin allows to create an inventory from Hosttech DNS records. + - >- + For Ansible to be able to identify a YAML file as an inventory for this plugin, the inventory file must contain + C(plugin: community.dns.hosttech_dns_records) and its filename must end with C(hosttech_dns.yaml) or C(hosttech_dns.yml) + +options: + plugin: + description: The name of this plugin. Should always be set to C(community.dns.hosttech_dns_records) for this plugin to recognize it as its own. + # TODO: add `required: true` in 3.0.0 + # required: true + choices: + - community.dns.hosttech_dns_records + type: str + + # We need to overwrite zone_id to be of type string, otherwise templating cannot be passed in + zone_id: + type: raw + # If there wouldn't be ansible-base 2.10, this should be string instead. ansible-base will + # not accept an integer for type=string options, whence type=string breaks backwards + # compatibility with previous type=int... + # type: string + +extends_documentation_fragment: + - community.dns.hosttech + - community.dns.hosttech.plugin + - community.dns.hosttech.record_type_choices_records_inventory + - community.dns.hosttech.zone_id_type + - community.dns.inventory_records + - community.dns.options.record_transformation + +notes: + - The provider-specific I(hosttech_username), I(hosttech_password), and I(hosttech_token) options can be templated. + +author: + - Markus Bergholz (@markuman) <markuman+spambelongstogoogle@gmail.com> + - Felix Fontein (@felixfontein) + +seealso: + - module: community.dns.hosttech_dns_record_set_info + - module: community.dns.hosttech_dns_record_info +''' + +EXAMPLES = ''' +# filename must end with hosttech_dns.yaml or hosttech_dns.yml + +plugin: community.dns.hosttech_dns_records +zone_name: domain.ch +filters: + type: + - AAAA + +# You can also configure the token by putting secret value into this file, +# but this is discouraged. Use a lookup like below, or leave it away and +# set it with the ANSIBLE_HOSTTECH_DNS_TOKEN environment variable. +hosttech_token: >- + {{ (lookup('community.sops.sops', 'keys/hosttech.sops.yml') | from_yaml).hosttech_dns_token }} +''' + +from ansible_collections.community.dns.plugins.module_utils.http import ( + OpenURLHelper, +) + +from ansible_collections.community.dns.plugins.module_utils.hosttech.api import ( + create_hosttech_api, + create_hosttech_provider_information, +) + +from ansible_collections.community.dns.plugins.plugin_utils.templated_options import ( + TemplatedOptionProvider, +) + +from ansible_collections.community.dns.plugins.plugin_utils.inventory.records import ( + RecordsInventoryModule, +) + + +class InventoryModule(RecordsInventoryModule): + NAME = 'community.dns.hosttech_dns_records' + VALID_ENDINGS = ('hosttech_dns.yaml', 'hosttech_dns.yml') + + def setup_api(self): + self.provider_information = create_hosttech_provider_information() + self.api = create_hosttech_api(TemplatedOptionProvider(self, self.templar), OpenURLHelper()) |