diff --git a/plugins/modules/storage_box_type_info.py b/plugins/modules/storage_box_type_info.py new file mode 100644 index 0000000..01964ab --- /dev/null +++ b/plugins/modules/storage_box_type_info.py @@ -0,0 +1,185 @@ +#!/usr/bin/python + +# Copyright: (c) 2025, Hetzner Cloud GmbH +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + + +from __future__ import annotations + +DOCUMENTATION = """ +--- +module: storage_box_type_info + +short_description: Gather infos about the Hetzner Storage Box Types. + +description: + - Gather infos about available Hetzner Storage Box Types. + +author: + - Jonas Lammler (@jooola) + +options: + id: + description: + - ID of the Storage Box Type to get. + - If the ID is invalid, the module will fail. + type: int + name: + description: + - Name of the Storage Box Type to get. + type: str + +extends_documentation_fragment: + - hetzner.hcloud.hcloud +""" + +EXAMPLES = """ +- name: Gather Storage Box Types infos + hetzner.hcloud.storage_box_type_info: + register: output + +- name: Print the gathered infos + debug: + var: output.hcloud_storage_box_type_info +""" + +RETURN = """ +hcloud_storage_box_type_info: + description: List of Storage Box Types. + returned: always + type: list + contains: + id: + description: ID of the Storage Box Type. + returned: success + type: int + sample: 1937415 + name: + description: Name of the Storage Box Type. + returned: success + type: str + sample: bx21 + description: + description: Description of the Storage Box Type. + returned: success + type: str + sample: BX21 + snapshot_limit: + description: Maximum number of allowed manual snapshots. + returned: success + type: int + sample: 10 + automatic_snapshot_limit: + description: Maximum number of snapshots created automatically by a snapshot plan. + returned: success + type: int + sample: 10 + subaccounts_limit: + description: Maximum number of subaccounts. + returned: success + type: int + sample: 200 + size: + description: Available storage in bytes. + returned: success + type: int + sample: 1099511627776 + deprecation: + description: Deprecation details about the Storage Box Type. + returned: when deprecated + type: dict + contains: + announced: + description: Date when the deprecation was announced. + returned: success + type: str + sample: "2025-06-02T00:00:00Z" + unavailable_after: + description: | + Date when the resource will stop being available. + + The resource will be removed from the list endpoint, but details + about the resource can be fetched using its ID. + returned: success + type: str + sample: "2025-09-02T00:00:00Z" +""" + +from ansible.module_utils.basic import AnsibleModule + +from ..module_utils.hcloud import AnsibleHCloud +from ..module_utils.vendor.hcloud import HCloudException +from ..module_utils.vendor.hcloud.storage_box_types import BoundStorageBoxType + + +class AnsibleStorageBoxTypeInfo(AnsibleHCloud): + represent = "storage_box_type" + + storage_box_type: list[BoundStorageBoxType] | None = None + + def _prepare_result(self): + result = [] + + for o in self.storage_box_type or []: + if o is None: + continue + + result.append( + { + "id": o.id, + "name": o.name, + "description": o.description, + "snapshot_limit": o.snapshot_limit, + "automatic_snapshot_limit": o.automatic_snapshot_limit, + "subaccounts_limit": o.subaccounts_limit, + "size": o.size, + "deprecation": ( + { + "announced": o.deprecation.announced.isoformat(), + "unavailable_after": o.deprecation.unavailable_after.isoformat(), + } + if o.deprecation is not None + else None + ), + } + ) + return result + + def fetch(self): + try: + if (id_ := self.module.params.get("id")) is not None: + self.storage_box_type = [self.client.storage_box_types.get_by_id(id_)] + elif (name := self.module.params.get("name")) is not None: + self.storage_box_type = [self.client.storage_box_types.get_by_name(name)] + else: + self.storage_box_type = self.client.storage_box_types.get_all() + + except HCloudException as exception: + self.fail_json_hcloud(exception) + + @classmethod + def define_module(cls): + return AnsibleModule( + argument_spec=dict( + id={"type": "int"}, + name={"type": "str"}, + **super().base_module_arguments(), + ), + supports_check_mode=True, + ) + + +def main(): + module = AnsibleStorageBoxTypeInfo.define_module() + o = AnsibleStorageBoxTypeInfo(module) + + o.fetch() + result = o.get_result() + + module.exit_json( + hcloud_storage_box_type_info=result["storage_box_type"], + ) + + +if __name__ == "__main__": + main() diff --git a/tests/integration/common/defaults/main/common.yml b/tests/integration/common/defaults/main/common.yml index e8e4a1b..55726ab 100644 --- a/tests/integration/common/defaults/main/common.yml +++ b/tests/integration/common/defaults/main/common.yml @@ -24,3 +24,6 @@ hcloud_datacenter_name: hel1-dc2 hcloud_datacenter_id: 3 hcloud_network_zone_name: eu-central + +hcloud_storage_box_type_name: bx11 +hcloud_storage_box_type_id: 1333 diff --git a/tests/integration/targets/certificate/defaults/main/common.yml b/tests/integration/targets/certificate/defaults/main/common.yml index 0b15142..7306057 100644 --- a/tests/integration/targets/certificate/defaults/main/common.yml +++ b/tests/integration/targets/certificate/defaults/main/common.yml @@ -27,3 +27,6 @@ hcloud_datacenter_name: hel1-dc2 hcloud_datacenter_id: 3 hcloud_network_zone_name: eu-central + +hcloud_storage_box_type_name: bx11 +hcloud_storage_box_type_id: 1333 diff --git a/tests/integration/targets/certificate_info/defaults/main/common.yml b/tests/integration/targets/certificate_info/defaults/main/common.yml index 0b15142..7306057 100644 --- a/tests/integration/targets/certificate_info/defaults/main/common.yml +++ b/tests/integration/targets/certificate_info/defaults/main/common.yml @@ -27,3 +27,6 @@ hcloud_datacenter_name: hel1-dc2 hcloud_datacenter_id: 3 hcloud_network_zone_name: eu-central + +hcloud_storage_box_type_name: bx11 +hcloud_storage_box_type_id: 1333 diff --git a/tests/integration/targets/datacenter_info/defaults/main/common.yml b/tests/integration/targets/datacenter_info/defaults/main/common.yml index 0b15142..7306057 100644 --- a/tests/integration/targets/datacenter_info/defaults/main/common.yml +++ b/tests/integration/targets/datacenter_info/defaults/main/common.yml @@ -27,3 +27,6 @@ hcloud_datacenter_name: hel1-dc2 hcloud_datacenter_id: 3 hcloud_network_zone_name: eu-central + +hcloud_storage_box_type_name: bx11 +hcloud_storage_box_type_id: 1333 diff --git a/tests/integration/targets/filter_all/defaults/main/common.yml b/tests/integration/targets/filter_all/defaults/main/common.yml index 0b15142..7306057 100644 --- a/tests/integration/targets/filter_all/defaults/main/common.yml +++ b/tests/integration/targets/filter_all/defaults/main/common.yml @@ -27,3 +27,6 @@ hcloud_datacenter_name: hel1-dc2 hcloud_datacenter_id: 3 hcloud_network_zone_name: eu-central + +hcloud_storage_box_type_name: bx11 +hcloud_storage_box_type_id: 1333 diff --git a/tests/integration/targets/firewall/defaults/main/common.yml b/tests/integration/targets/firewall/defaults/main/common.yml index 0b15142..7306057 100644 --- a/tests/integration/targets/firewall/defaults/main/common.yml +++ b/tests/integration/targets/firewall/defaults/main/common.yml @@ -27,3 +27,6 @@ hcloud_datacenter_name: hel1-dc2 hcloud_datacenter_id: 3 hcloud_network_zone_name: eu-central + +hcloud_storage_box_type_name: bx11 +hcloud_storage_box_type_id: 1333 diff --git a/tests/integration/targets/firewall_info/defaults/main/common.yml b/tests/integration/targets/firewall_info/defaults/main/common.yml index 0b15142..7306057 100644 --- a/tests/integration/targets/firewall_info/defaults/main/common.yml +++ b/tests/integration/targets/firewall_info/defaults/main/common.yml @@ -27,3 +27,6 @@ hcloud_datacenter_name: hel1-dc2 hcloud_datacenter_id: 3 hcloud_network_zone_name: eu-central + +hcloud_storage_box_type_name: bx11 +hcloud_storage_box_type_id: 1333 diff --git a/tests/integration/targets/firewall_resource/defaults/main/common.yml b/tests/integration/targets/firewall_resource/defaults/main/common.yml index 0b15142..7306057 100644 --- a/tests/integration/targets/firewall_resource/defaults/main/common.yml +++ b/tests/integration/targets/firewall_resource/defaults/main/common.yml @@ -27,3 +27,6 @@ hcloud_datacenter_name: hel1-dc2 hcloud_datacenter_id: 3 hcloud_network_zone_name: eu-central + +hcloud_storage_box_type_name: bx11 +hcloud_storage_box_type_id: 1333 diff --git a/tests/integration/targets/floating_ip/defaults/main/common.yml b/tests/integration/targets/floating_ip/defaults/main/common.yml index 0b15142..7306057 100644 --- a/tests/integration/targets/floating_ip/defaults/main/common.yml +++ b/tests/integration/targets/floating_ip/defaults/main/common.yml @@ -27,3 +27,6 @@ hcloud_datacenter_name: hel1-dc2 hcloud_datacenter_id: 3 hcloud_network_zone_name: eu-central + +hcloud_storage_box_type_name: bx11 +hcloud_storage_box_type_id: 1333 diff --git a/tests/integration/targets/floating_ip_info/defaults/main/common.yml b/tests/integration/targets/floating_ip_info/defaults/main/common.yml index 0b15142..7306057 100644 --- a/tests/integration/targets/floating_ip_info/defaults/main/common.yml +++ b/tests/integration/targets/floating_ip_info/defaults/main/common.yml @@ -27,3 +27,6 @@ hcloud_datacenter_name: hel1-dc2 hcloud_datacenter_id: 3 hcloud_network_zone_name: eu-central + +hcloud_storage_box_type_name: bx11 +hcloud_storage_box_type_id: 1333 diff --git a/tests/integration/targets/image_info/defaults/main/common.yml b/tests/integration/targets/image_info/defaults/main/common.yml index 0b15142..7306057 100644 --- a/tests/integration/targets/image_info/defaults/main/common.yml +++ b/tests/integration/targets/image_info/defaults/main/common.yml @@ -27,3 +27,6 @@ hcloud_datacenter_name: hel1-dc2 hcloud_datacenter_id: 3 hcloud_network_zone_name: eu-central + +hcloud_storage_box_type_name: bx11 +hcloud_storage_box_type_id: 1333 diff --git a/tests/integration/targets/iso_info/defaults/main/common.yml b/tests/integration/targets/iso_info/defaults/main/common.yml index 0b15142..7306057 100644 --- a/tests/integration/targets/iso_info/defaults/main/common.yml +++ b/tests/integration/targets/iso_info/defaults/main/common.yml @@ -27,3 +27,6 @@ hcloud_datacenter_name: hel1-dc2 hcloud_datacenter_id: 3 hcloud_network_zone_name: eu-central + +hcloud_storage_box_type_name: bx11 +hcloud_storage_box_type_id: 1333 diff --git a/tests/integration/targets/load_balancer/defaults/main/common.yml b/tests/integration/targets/load_balancer/defaults/main/common.yml index 0b15142..7306057 100644 --- a/tests/integration/targets/load_balancer/defaults/main/common.yml +++ b/tests/integration/targets/load_balancer/defaults/main/common.yml @@ -27,3 +27,6 @@ hcloud_datacenter_name: hel1-dc2 hcloud_datacenter_id: 3 hcloud_network_zone_name: eu-central + +hcloud_storage_box_type_name: bx11 +hcloud_storage_box_type_id: 1333 diff --git a/tests/integration/targets/load_balancer_info/defaults/main/common.yml b/tests/integration/targets/load_balancer_info/defaults/main/common.yml index 0b15142..7306057 100644 --- a/tests/integration/targets/load_balancer_info/defaults/main/common.yml +++ b/tests/integration/targets/load_balancer_info/defaults/main/common.yml @@ -27,3 +27,6 @@ hcloud_datacenter_name: hel1-dc2 hcloud_datacenter_id: 3 hcloud_network_zone_name: eu-central + +hcloud_storage_box_type_name: bx11 +hcloud_storage_box_type_id: 1333 diff --git a/tests/integration/targets/load_balancer_network/defaults/main/common.yml b/tests/integration/targets/load_balancer_network/defaults/main/common.yml index 0b15142..7306057 100644 --- a/tests/integration/targets/load_balancer_network/defaults/main/common.yml +++ b/tests/integration/targets/load_balancer_network/defaults/main/common.yml @@ -27,3 +27,6 @@ hcloud_datacenter_name: hel1-dc2 hcloud_datacenter_id: 3 hcloud_network_zone_name: eu-central + +hcloud_storage_box_type_name: bx11 +hcloud_storage_box_type_id: 1333 diff --git a/tests/integration/targets/load_balancer_service/defaults/main/common.yml b/tests/integration/targets/load_balancer_service/defaults/main/common.yml index 0b15142..7306057 100644 --- a/tests/integration/targets/load_balancer_service/defaults/main/common.yml +++ b/tests/integration/targets/load_balancer_service/defaults/main/common.yml @@ -27,3 +27,6 @@ hcloud_datacenter_name: hel1-dc2 hcloud_datacenter_id: 3 hcloud_network_zone_name: eu-central + +hcloud_storage_box_type_name: bx11 +hcloud_storage_box_type_id: 1333 diff --git a/tests/integration/targets/load_balancer_target/defaults/main/common.yml b/tests/integration/targets/load_balancer_target/defaults/main/common.yml index 0b15142..7306057 100644 --- a/tests/integration/targets/load_balancer_target/defaults/main/common.yml +++ b/tests/integration/targets/load_balancer_target/defaults/main/common.yml @@ -27,3 +27,6 @@ hcloud_datacenter_name: hel1-dc2 hcloud_datacenter_id: 3 hcloud_network_zone_name: eu-central + +hcloud_storage_box_type_name: bx11 +hcloud_storage_box_type_id: 1333 diff --git a/tests/integration/targets/load_balancer_type_info/defaults/main/common.yml b/tests/integration/targets/load_balancer_type_info/defaults/main/common.yml index 0b15142..7306057 100644 --- a/tests/integration/targets/load_balancer_type_info/defaults/main/common.yml +++ b/tests/integration/targets/load_balancer_type_info/defaults/main/common.yml @@ -27,3 +27,6 @@ hcloud_datacenter_name: hel1-dc2 hcloud_datacenter_id: 3 hcloud_network_zone_name: eu-central + +hcloud_storage_box_type_name: bx11 +hcloud_storage_box_type_id: 1333 diff --git a/tests/integration/targets/location_info/defaults/main/common.yml b/tests/integration/targets/location_info/defaults/main/common.yml index 0b15142..7306057 100644 --- a/tests/integration/targets/location_info/defaults/main/common.yml +++ b/tests/integration/targets/location_info/defaults/main/common.yml @@ -27,3 +27,6 @@ hcloud_datacenter_name: hel1-dc2 hcloud_datacenter_id: 3 hcloud_network_zone_name: eu-central + +hcloud_storage_box_type_name: bx11 +hcloud_storage_box_type_id: 1333 diff --git a/tests/integration/targets/network/defaults/main/common.yml b/tests/integration/targets/network/defaults/main/common.yml index 0b15142..7306057 100644 --- a/tests/integration/targets/network/defaults/main/common.yml +++ b/tests/integration/targets/network/defaults/main/common.yml @@ -27,3 +27,6 @@ hcloud_datacenter_name: hel1-dc2 hcloud_datacenter_id: 3 hcloud_network_zone_name: eu-central + +hcloud_storage_box_type_name: bx11 +hcloud_storage_box_type_id: 1333 diff --git a/tests/integration/targets/network_info/defaults/main/common.yml b/tests/integration/targets/network_info/defaults/main/common.yml index 0b15142..7306057 100644 --- a/tests/integration/targets/network_info/defaults/main/common.yml +++ b/tests/integration/targets/network_info/defaults/main/common.yml @@ -27,3 +27,6 @@ hcloud_datacenter_name: hel1-dc2 hcloud_datacenter_id: 3 hcloud_network_zone_name: eu-central + +hcloud_storage_box_type_name: bx11 +hcloud_storage_box_type_id: 1333 diff --git a/tests/integration/targets/placement_group/defaults/main/common.yml b/tests/integration/targets/placement_group/defaults/main/common.yml index 0b15142..7306057 100644 --- a/tests/integration/targets/placement_group/defaults/main/common.yml +++ b/tests/integration/targets/placement_group/defaults/main/common.yml @@ -27,3 +27,6 @@ hcloud_datacenter_name: hel1-dc2 hcloud_datacenter_id: 3 hcloud_network_zone_name: eu-central + +hcloud_storage_box_type_name: bx11 +hcloud_storage_box_type_id: 1333 diff --git a/tests/integration/targets/primary_ip/defaults/main/common.yml b/tests/integration/targets/primary_ip/defaults/main/common.yml index 0b15142..7306057 100644 --- a/tests/integration/targets/primary_ip/defaults/main/common.yml +++ b/tests/integration/targets/primary_ip/defaults/main/common.yml @@ -27,3 +27,6 @@ hcloud_datacenter_name: hel1-dc2 hcloud_datacenter_id: 3 hcloud_network_zone_name: eu-central + +hcloud_storage_box_type_name: bx11 +hcloud_storage_box_type_id: 1333 diff --git a/tests/integration/targets/primary_ip_info/defaults/main/common.yml b/tests/integration/targets/primary_ip_info/defaults/main/common.yml index 0b15142..7306057 100644 --- a/tests/integration/targets/primary_ip_info/defaults/main/common.yml +++ b/tests/integration/targets/primary_ip_info/defaults/main/common.yml @@ -27,3 +27,6 @@ hcloud_datacenter_name: hel1-dc2 hcloud_datacenter_id: 3 hcloud_network_zone_name: eu-central + +hcloud_storage_box_type_name: bx11 +hcloud_storage_box_type_id: 1333 diff --git a/tests/integration/targets/rdns/defaults/main/common.yml b/tests/integration/targets/rdns/defaults/main/common.yml index 0b15142..7306057 100644 --- a/tests/integration/targets/rdns/defaults/main/common.yml +++ b/tests/integration/targets/rdns/defaults/main/common.yml @@ -27,3 +27,6 @@ hcloud_datacenter_name: hel1-dc2 hcloud_datacenter_id: 3 hcloud_network_zone_name: eu-central + +hcloud_storage_box_type_name: bx11 +hcloud_storage_box_type_id: 1333 diff --git a/tests/integration/targets/route/defaults/main/common.yml b/tests/integration/targets/route/defaults/main/common.yml index 0b15142..7306057 100644 --- a/tests/integration/targets/route/defaults/main/common.yml +++ b/tests/integration/targets/route/defaults/main/common.yml @@ -27,3 +27,6 @@ hcloud_datacenter_name: hel1-dc2 hcloud_datacenter_id: 3 hcloud_network_zone_name: eu-central + +hcloud_storage_box_type_name: bx11 +hcloud_storage_box_type_id: 1333 diff --git a/tests/integration/targets/server/defaults/main/common.yml b/tests/integration/targets/server/defaults/main/common.yml index 0b15142..7306057 100644 --- a/tests/integration/targets/server/defaults/main/common.yml +++ b/tests/integration/targets/server/defaults/main/common.yml @@ -27,3 +27,6 @@ hcloud_datacenter_name: hel1-dc2 hcloud_datacenter_id: 3 hcloud_network_zone_name: eu-central + +hcloud_storage_box_type_name: bx11 +hcloud_storage_box_type_id: 1333 diff --git a/tests/integration/targets/server_info/defaults/main/common.yml b/tests/integration/targets/server_info/defaults/main/common.yml index 0b15142..7306057 100644 --- a/tests/integration/targets/server_info/defaults/main/common.yml +++ b/tests/integration/targets/server_info/defaults/main/common.yml @@ -27,3 +27,6 @@ hcloud_datacenter_name: hel1-dc2 hcloud_datacenter_id: 3 hcloud_network_zone_name: eu-central + +hcloud_storage_box_type_name: bx11 +hcloud_storage_box_type_id: 1333 diff --git a/tests/integration/targets/server_network/defaults/main/common.yml b/tests/integration/targets/server_network/defaults/main/common.yml index 0b15142..7306057 100644 --- a/tests/integration/targets/server_network/defaults/main/common.yml +++ b/tests/integration/targets/server_network/defaults/main/common.yml @@ -27,3 +27,6 @@ hcloud_datacenter_name: hel1-dc2 hcloud_datacenter_id: 3 hcloud_network_zone_name: eu-central + +hcloud_storage_box_type_name: bx11 +hcloud_storage_box_type_id: 1333 diff --git a/tests/integration/targets/server_type_info/defaults/main/common.yml b/tests/integration/targets/server_type_info/defaults/main/common.yml index 0b15142..7306057 100644 --- a/tests/integration/targets/server_type_info/defaults/main/common.yml +++ b/tests/integration/targets/server_type_info/defaults/main/common.yml @@ -27,3 +27,6 @@ hcloud_datacenter_name: hel1-dc2 hcloud_datacenter_id: 3 hcloud_network_zone_name: eu-central + +hcloud_storage_box_type_name: bx11 +hcloud_storage_box_type_id: 1333 diff --git a/tests/integration/targets/ssh_key/defaults/main/common.yml b/tests/integration/targets/ssh_key/defaults/main/common.yml index 0b15142..7306057 100644 --- a/tests/integration/targets/ssh_key/defaults/main/common.yml +++ b/tests/integration/targets/ssh_key/defaults/main/common.yml @@ -27,3 +27,6 @@ hcloud_datacenter_name: hel1-dc2 hcloud_datacenter_id: 3 hcloud_network_zone_name: eu-central + +hcloud_storage_box_type_name: bx11 +hcloud_storage_box_type_id: 1333 diff --git a/tests/integration/targets/ssh_key_info/defaults/main/common.yml b/tests/integration/targets/ssh_key_info/defaults/main/common.yml index 0b15142..7306057 100644 --- a/tests/integration/targets/ssh_key_info/defaults/main/common.yml +++ b/tests/integration/targets/ssh_key_info/defaults/main/common.yml @@ -27,3 +27,6 @@ hcloud_datacenter_name: hel1-dc2 hcloud_datacenter_id: 3 hcloud_network_zone_name: eu-central + +hcloud_storage_box_type_name: bx11 +hcloud_storage_box_type_id: 1333 diff --git a/tests/integration/targets/storage_box_type_info/aliases b/tests/integration/targets/storage_box_type_info/aliases new file mode 100644 index 0000000..18b1111 --- /dev/null +++ b/tests/integration/targets/storage_box_type_info/aliases @@ -0,0 +1,3 @@ +cloud/hcloud +gather_facts/no +azp/group2 diff --git a/tests/integration/targets/storage_box_type_info/defaults/main/common.yml b/tests/integration/targets/storage_box_type_info/defaults/main/common.yml new file mode 100644 index 0000000..7306057 --- /dev/null +++ b/tests/integration/targets/storage_box_type_info/defaults/main/common.yml @@ -0,0 +1,32 @@ +# +# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead. +# +--- +# Azure Pipelines will configure this value to something similar to +# "azp-84824-1-hetzner-2-13-test-2-13-hcloud-3-9-1-default-i" +hcloud_prefix: "tests" + +# Used to namespace resources created by concurrent test pipelines/targets +hcloud_run_ns: "{{ hcloud_prefix | md5 }}" +hcloud_role_ns: "{{ role_name | split('_') | map('batch', 2) | map('first') | flatten() | join() }}" +hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}" + +# Used to easily update the server types and images across all our tests. +hcloud_server_type_name: cax11 +hcloud_server_type_id: 45 + +hcloud_server_type_upgrade_name: cax21 +hcloud_server_type_upgrade_id: 93 + +hcloud_image_name: debian-12 +hcloud_image_id: 114690389 # architecture=arm + +hcloud_location_name: hel1 +hcloud_location_id: 3 +hcloud_datacenter_name: hel1-dc2 +hcloud_datacenter_id: 3 + +hcloud_network_zone_name: eu-central + +hcloud_storage_box_type_name: bx11 +hcloud_storage_box_type_id: 1333 diff --git a/tests/integration/targets/storage_box_type_info/defaults/main/main.yml b/tests/integration/targets/storage_box_type_info/defaults/main/main.yml new file mode 100644 index 0000000..57f246a --- /dev/null +++ b/tests/integration/targets/storage_box_type_info/defaults/main/main.yml @@ -0,0 +1,3 @@ +# Copyright: (c) 2025, Hetzner Cloud GmbH +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- diff --git a/tests/integration/targets/storage_box_type_info/tasks/main.yml b/tests/integration/targets/storage_box_type_info/tasks/main.yml new file mode 100644 index 0000000..767fc46 --- /dev/null +++ b/tests/integration/targets/storage_box_type_info/tasks/main.yml @@ -0,0 +1,31 @@ +# +# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead. +# +--- +- name: Check if cleanup.yml exists + ansible.builtin.stat: + path: "{{ role_path }}/tasks/cleanup.yml" + register: cleanup_file + +- name: Check if prepare.yml exists + ansible.builtin.stat: + path: "{{ role_path }}/tasks/prepare.yml" + register: prepare_file + +- name: Include cleanup tasks + ansible.builtin.include_tasks: "{{ role_path }}/tasks/cleanup.yml" + when: cleanup_file.stat.exists + +- name: Include prepare tasks + ansible.builtin.include_tasks: "{{ role_path }}/tasks/prepare.yml" + when: prepare_file.stat.exists + +- name: Run tests + block: + - name: Include test tasks + ansible.builtin.include_tasks: "{{ role_path }}/tasks/test.yml" + + always: + - name: Include cleanup tasks + ansible.builtin.include_tasks: "{{ role_path }}/tasks/cleanup.yml" + when: cleanup_file.stat.exists diff --git a/tests/integration/targets/storage_box_type_info/tasks/test.yml b/tests/integration/targets/storage_box_type_info/tasks/test.yml new file mode 100644 index 0000000..c68cd50 --- /dev/null +++ b/tests/integration/targets/storage_box_type_info/tasks/test.yml @@ -0,0 +1,64 @@ +# Copyright: (c) 2025, Hetzner Cloud GmbH +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: Gather hcloud_storage_box_type_info + hetzner.hcloud.storage_box_type_info: + register: result +- name: Verify hcloud_storage_box_type_info + ansible.builtin.assert: + that: + - result.hcloud_storage_box_type_info | list | count >= 1 + +- name: Gather hcloud_storage_box_type_info in check mode + hetzner.hcloud.storage_box_type_info: + check_mode: true + register: result +- name: Verify hcloud_storage_box_type_info in check mode + ansible.builtin.assert: + that: + - result.hcloud_storage_box_type_info | list | count >= 1 + +- name: Gather hcloud_storage_box_type_info with correct id + hetzner.hcloud.storage_box_type_info: + id: "{{ hcloud_storage_box_type_id }}" + register: result +- name: Verify hcloud_storage_box_type_info with correct id + ansible.builtin.assert: + that: + - result.hcloud_storage_box_type_info | list | count == 1 + - result.hcloud_storage_box_type_info[0].id == hcloud_storage_box_type_id + - result.hcloud_storage_box_type_info[0].name == hcloud_storage_box_type_name + - result.hcloud_storage_box_type_info[0].description == "BX11" + - result.hcloud_storage_box_type_info[0].snapshot_limit == 10 + - result.hcloud_storage_box_type_info[0].automatic_snapshot_limit == 10 + - result.hcloud_storage_box_type_info[0].subaccounts_limit == 100 + - result.hcloud_storage_box_type_info[0].size == 1099511627776 + - result.hcloud_storage_box_type_info[0].deprecation is none + +- name: Gather hcloud_storage_box_type_info with wrong id + hetzner.hcloud.storage_box_type_info: + id: "{{ hcloud_storage_box_type_id }}4321" + ignore_errors: true + register: result +- name: Verify hcloud_storage_box_type_info with wrong id + ansible.builtin.assert: + that: + - result is failed + +- name: Gather hcloud_storage_box_type_info with correct name + hetzner.hcloud.storage_box_type_info: + name: "{{ hcloud_storage_box_type_name }}" + register: result +- name: Verify hcloud_storage_box_type_info with correct name + ansible.builtin.assert: + that: + - result.hcloud_storage_box_type_info | list | count == 1 + +- name: Gather hcloud_storage_box_type_info with wrong name + hetzner.hcloud.storage_box_type_info: + name: "{{ hcloud_storage_box_type_name }}-invalid" + register: result +- name: Verify hcloud_storage_box_type_info with wrong name + ansible.builtin.assert: + that: + - result.hcloud_storage_box_type_info | list | count == 0 diff --git a/tests/integration/targets/subnetwork/defaults/main/common.yml b/tests/integration/targets/subnetwork/defaults/main/common.yml index 0b15142..7306057 100644 --- a/tests/integration/targets/subnetwork/defaults/main/common.yml +++ b/tests/integration/targets/subnetwork/defaults/main/common.yml @@ -27,3 +27,6 @@ hcloud_datacenter_name: hel1-dc2 hcloud_datacenter_id: 3 hcloud_network_zone_name: eu-central + +hcloud_storage_box_type_name: bx11 +hcloud_storage_box_type_id: 1333 diff --git a/tests/integration/targets/volume/defaults/main/common.yml b/tests/integration/targets/volume/defaults/main/common.yml index 0b15142..7306057 100644 --- a/tests/integration/targets/volume/defaults/main/common.yml +++ b/tests/integration/targets/volume/defaults/main/common.yml @@ -27,3 +27,6 @@ hcloud_datacenter_name: hel1-dc2 hcloud_datacenter_id: 3 hcloud_network_zone_name: eu-central + +hcloud_storage_box_type_name: bx11 +hcloud_storage_box_type_id: 1333 diff --git a/tests/integration/targets/volume_attachment/defaults/main/common.yml b/tests/integration/targets/volume_attachment/defaults/main/common.yml index 0b15142..7306057 100644 --- a/tests/integration/targets/volume_attachment/defaults/main/common.yml +++ b/tests/integration/targets/volume_attachment/defaults/main/common.yml @@ -27,3 +27,6 @@ hcloud_datacenter_name: hel1-dc2 hcloud_datacenter_id: 3 hcloud_network_zone_name: eu-central + +hcloud_storage_box_type_name: bx11 +hcloud_storage_box_type_id: 1333 diff --git a/tests/integration/targets/volume_info/defaults/main/common.yml b/tests/integration/targets/volume_info/defaults/main/common.yml index 0b15142..7306057 100644 --- a/tests/integration/targets/volume_info/defaults/main/common.yml +++ b/tests/integration/targets/volume_info/defaults/main/common.yml @@ -27,3 +27,6 @@ hcloud_datacenter_name: hel1-dc2 hcloud_datacenter_id: 3 hcloud_network_zone_name: eu-central + +hcloud_storage_box_type_name: bx11 +hcloud_storage_box_type_id: 1333 diff --git a/tests/integration/targets/zone/defaults/main/common.yml b/tests/integration/targets/zone/defaults/main/common.yml index 0b15142..7306057 100644 --- a/tests/integration/targets/zone/defaults/main/common.yml +++ b/tests/integration/targets/zone/defaults/main/common.yml @@ -27,3 +27,6 @@ hcloud_datacenter_name: hel1-dc2 hcloud_datacenter_id: 3 hcloud_network_zone_name: eu-central + +hcloud_storage_box_type_name: bx11 +hcloud_storage_box_type_id: 1333 diff --git a/tests/integration/targets/zone_info/defaults/main/common.yml b/tests/integration/targets/zone_info/defaults/main/common.yml index 0b15142..7306057 100644 --- a/tests/integration/targets/zone_info/defaults/main/common.yml +++ b/tests/integration/targets/zone_info/defaults/main/common.yml @@ -27,3 +27,6 @@ hcloud_datacenter_name: hel1-dc2 hcloud_datacenter_id: 3 hcloud_network_zone_name: eu-central + +hcloud_storage_box_type_name: bx11 +hcloud_storage_box_type_id: 1333 diff --git a/tests/integration/targets/zone_rrset/defaults/main/common.yml b/tests/integration/targets/zone_rrset/defaults/main/common.yml index 0b15142..7306057 100644 --- a/tests/integration/targets/zone_rrset/defaults/main/common.yml +++ b/tests/integration/targets/zone_rrset/defaults/main/common.yml @@ -27,3 +27,6 @@ hcloud_datacenter_name: hel1-dc2 hcloud_datacenter_id: 3 hcloud_network_zone_name: eu-central + +hcloud_storage_box_type_name: bx11 +hcloud_storage_box_type_id: 1333 diff --git a/tests/integration/targets/zone_rrset_info/defaults/main/common.yml b/tests/integration/targets/zone_rrset_info/defaults/main/common.yml index 0b15142..7306057 100644 --- a/tests/integration/targets/zone_rrset_info/defaults/main/common.yml +++ b/tests/integration/targets/zone_rrset_info/defaults/main/common.yml @@ -27,3 +27,6 @@ hcloud_datacenter_name: hel1-dc2 hcloud_datacenter_id: 3 hcloud_network_zone_name: eu-central + +hcloud_storage_box_type_name: bx11 +hcloud_storage_box_type_id: 1333