summaryrefslogtreecommitdiffstats
path: root/ansible_collections/hetzner/hcloud/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-18 05:52:22 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-18 05:52:22 +0000
commit38b7c80217c4e72b1d8988eb1e60bb6e77334114 (patch)
tree356e9fd3762877d07cde52d21e77070aeff7e789 /ansible_collections/hetzner/hcloud/tests
parentAdding upstream version 7.7.0+dfsg. (diff)
downloadansible-38b7c80217c4e72b1d8988eb1e60bb6e77334114.tar.xz
ansible-38b7c80217c4e72b1d8988eb1e60bb6e77334114.zip
Adding upstream version 9.4.0+dfsg.upstream/9.4.0+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/hetzner/hcloud/tests')
-rw-r--r--ansible_collections/hetzner/hcloud/tests/config.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/constraints.txt2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/README.md27
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/common/defaults/main/common.yml9
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/common/tasks/main.yml28
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/constraints.txt1
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/requirements.txt5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/certificate/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/certificate/defaults/main/common.yml12
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/certificate/defaults/main/main.yml5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/certificate/meta/main.yml (renamed from ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/meta/main.yml)3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/certificate/tasks/cleanup.yml5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/certificate/tasks/main.yml31
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/certificate/tasks/test.yml (renamed from ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/tasks/main.yml)54
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/certificate_info/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/certificate_info/defaults/main/common.yml12
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/certificate_info/defaults/main/main.yml (renamed from ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/defaults/main.yml)3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/certificate_info/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/certificate_info/tasks/cleanup.yml5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/certificate_info/tasks/main.yml31
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/certificate_info/tasks/prepare.yml10
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/certificate_info/tasks/test.yml77
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/datacenter_info/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/datacenter_info/defaults/main/common.yml12
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/datacenter_info/defaults/main/main.yml (renamed from ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/defaults/main.yml)4
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/datacenter_info/tasks/main.yml31
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/datacenter_info/tasks/test.yml58
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/firewall/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/firewall/defaults/main/common.yml12
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/firewall/defaults/main/main.yml5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/firewall/tasks/cleanup.yml10
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/firewall/tasks/main.yml31
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/firewall/tasks/prepare.yml8
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/firewall/tasks/test.yml197
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_info/aliases (renamed from ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/aliases)0
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_info/defaults/main/common.yml12
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_info/defaults/main/main.yml5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_info/tasks/cleanup.yml10
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_info/tasks/main.yml31
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_info/tasks/prepare.yml35
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_info/tasks/test.yml93
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_resource/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_resource/defaults/main/common.yml12
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_resource/defaults/main/main.yml5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_resource/tasks/cleanup.yml10
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_resource/tasks/main.yml31
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_resource/tasks/prepare.yml25
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_resource/tasks/test.yml95
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip/defaults/main/common.yml12
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip/defaults/main/main.yml5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip/tasks/main.yml31
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip/tasks/test.yml (renamed from ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/tasks/main.yml)130
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip_info/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip_info/defaults/main/common.yml12
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip_info/defaults/main/main.yml (renamed from ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/defaults/main.yml)3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip_info/tasks/cleanup.yml5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip_info/tasks/main.yml31
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip_info/tasks/prepare.yml9
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip_info/tasks/test.yml77
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/defaults/main.yml6
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/meta/main.yml5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/tasks/main.yml66
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/tasks/main.yml39
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_firewall/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_firewall/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_firewall/tasks/main.yml210
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/defaults/main.yml6
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/tasks/main.yml87
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/defaults/main.yml7
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/tasks/main.yml93
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/tasks/main.yml247
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/defaults/main.yml6
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/tasks/main.yml128
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/defaults/main.yml6
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/defaults/main.yml7
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_type_info/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_type_info/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_type_info/tasks/main.yml38
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/tasks/main.yml57
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/aliases3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/defaults/main.yml5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/tasks/main.yml117
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_placement_group/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_placement_group/defaults/main.yml6
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_placement_group/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_primary_ip/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_primary_ip/defaults/main.yml6
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_primary_ip/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/defaults/main.yml8
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/tasks/main.yml224
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/defaults/main.yml5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/defaults/main.yml8
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/main.yml8
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/defaults/main.yml5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/tasks/main.yml128
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/aliases3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/defaults/main.yml6
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/tasks/main.yml38
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/defaults/main.yml11
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/meta/main.yml5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/meta/main.yml5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/tasks/main.yml68
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/defaults/main.yml6
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/tasks/main.yml125
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/defaults/main.yml6
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/defaults/main.yml5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/tasks/main.yml101
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/image_info/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/image_info/defaults/main/common.yml12
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/image_info/defaults/main/main.yml6
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/image_info/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/image_info/tasks/cleanup.yml5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/image_info/tasks/main.yml31
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/image_info/tasks/prepare.yml23
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/image_info/tasks/test.yml104
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/iso_info/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/iso_info/defaults/main/common.yml12
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/iso_info/defaults/main/main.yml7
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/iso_info/tasks/main.yml31
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/iso_info/tasks/test.yml73
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer/defaults/main/common.yml12
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer/defaults/main/main.yml (renamed from ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/defaults/main.yml)3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer/tasks/cleanup.yml5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer/tasks/main.yml31
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer/tasks/test.yml145
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_info/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_info/defaults/main/common.yml12
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_info/defaults/main/main.yml5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_info/meta/main.yml0
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_info/tasks/cleanup.yml10
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_info/tasks/main.yml31
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_info/tasks/prepare.yml33
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_info/tasks/test.yml86
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_network/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_network/defaults/main/common.yml12
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_network/defaults/main/main.yml5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_network/tasks/main.yml31
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_network/tasks/test.yml (renamed from ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/tasks/main.yml)68
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_service/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_service/defaults/main/common.yml12
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_service/defaults/main/main.yml (renamed from ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/defaults/main.yml)3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_service/tasks/main.yml31
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_service/tasks/test.yml (renamed from ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/tasks/main.yml)62
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_target/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_target/defaults/main/common.yml12
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_target/defaults/main/main.yml7
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_target/tasks/main.yml31
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_target/tasks/test.yml (renamed from ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/tasks/main.yml)66
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_type_info/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_type_info/defaults/main/common.yml12
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_type_info/defaults/main/main.yml (renamed from ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_type_info/defaults/main.yml)2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_type_info/tasks/main.yml31
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_type_info/tasks/test.yml56
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/location_info/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/location_info/defaults/main/common.yml12
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/location_info/defaults/main/main.yml (renamed from ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/defaults/main.yml)2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/location_info/tasks/main.yml31
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/location_info/tasks/test.yml56
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/network/aliases3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/network/defaults/main/common.yml12
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/network/defaults/main/main.yml5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/network/tasks/main.yml31
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/network/tasks/test.yml (renamed from ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/tasks/main.yml)117
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/network_info/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/network_info/defaults/main/common.yml12
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/network_info/defaults/main/main.yml4
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/network_info/tasks/cleanup.yml5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/network_info/tasks/main.yml31
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/network_info/tasks/prepare.yml23
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/network_info/tasks/test.yml79
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/placement_group/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/placement_group/defaults/main/common.yml12
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/placement_group/defaults/main/main.yml6
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/placement_group/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/placement_group/tasks/cleanup.yml5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/placement_group/tasks/main.yml31
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/placement_group/tasks/prepare.yml6
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/placement_group/tasks/test.yml (renamed from ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_placement_group/tasks/main.yml)48
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip/defaults/main/common.yml12
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip/defaults/main/main.yml (renamed from ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/defaults/main.yml)4
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip/tasks/main.yml31
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip/tasks/test.yml (renamed from ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_primary_ip/tasks/main.yml)51
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip_info/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip_info/defaults/main/common.yml12
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip_info/defaults/main/main.yml4
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip_info/tasks/cleanup.yml5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip_info/tasks/main.yml31
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip_info/tasks/prepare.yml9
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip_info/tasks/test.yml77
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/rdns/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/rdns/defaults/main/common.yml12
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/rdns/defaults/main/main.yml8
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/rdns/tasks/cleanup.yml20
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/rdns/tasks/main.yml31
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/rdns/tasks/prepare.yml32
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/rdns/tasks/test.yml148
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/route/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/route/defaults/main/common.yml12
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/route/defaults/main/main.yml4
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/route/tasks/main.yml31
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/route/tasks/test.yml (renamed from ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/tasks/main.yml)40
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/server/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/server/defaults/main/common.yml12
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/server/defaults/main/main.yml8
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/server/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/server/tasks/cleanup.yml5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/server/tasks/main.yml31
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/server/tasks/prepare.yml6
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/server/tasks/test.yml8
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/server/tasks/test_basic.yml (renamed from ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/basic.yml)168
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/server/tasks/test_firewalls.yml (renamed from ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/firewalls.yml)34
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/server/tasks/test_primary_ips.yml (renamed from ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/primary_ips.yml)28
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/server/tasks/test_private_network_only.yml (renamed from ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/private_network_only.yml)52
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/server/tasks/test_validation.yml (renamed from ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/validation.yml)18
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/server_info/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/server_info/defaults/main/common.yml12
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/server_info/defaults/main/main.yml4
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/server_info/tasks/cleanup.yml10
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/server_info/tasks/main.yml31
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/server_info/tasks/prepare.yml22
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/server_info/tasks/test.yml89
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/server_network/aliases3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/server_network/defaults/main/common.yml12
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/server_network/defaults/main/main.yml (renamed from ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/defaults/main.yml)4
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/server_network/tasks/main.yml31
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/server_network/tasks/test.yml (renamed from ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/tasks/main.yml)98
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/server_type_info/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/server_type_info/defaults/main/common.yml12
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/server_type_info/defaults/main/main.yml7
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/server_type_info/tasks/main.yml31
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/server_type_info/tasks/test.yml69
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/setup_hcloud_cli/tasks/main.yml16
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/setup_selfsigned_certificate/tasks/main.yml58
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/setup_ssh_keypair/tasks/main.yml19
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/setup_sshkey/tasks/main.yml55
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key/defaults/main/common.yml12
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key/defaults/main/main.yml (renamed from ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_firewall/defaults/main.yml)4
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key/tasks/cleanup.yml10
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key/tasks/main.yml31
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key/tasks/test.yml (renamed from ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/tasks/main.yml)82
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key_info/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key_info/defaults/main/common.yml12
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key_info/defaults/main/main.yml4
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key_info/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key_info/tasks/cleanup.yml5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key_info/tasks/main.yml31
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key_info/tasks/prepare.yml8
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key_info/tasks/test.yml77
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/subnetwork/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/subnetwork/defaults/main/common.yml12
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/subnetwork/defaults/main/main.yml23
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/subnetwork/tasks/cleanup.yml5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/subnetwork/tasks/main.yml31
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/subnetwork/tasks/prepare.yml11
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/subnetwork/tasks/test.yml103
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/volume/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/volume/defaults/main/common.yml12
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/volume/defaults/main/main.yml (renamed from ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/defaults/main.yml)4
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/volume/tasks/main.yml31
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/volume/tasks/test.yml (renamed from ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/tasks/main.yml)81
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/volume_info/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/volume_info/defaults/main/common.yml12
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/volume_info/defaults/main/main.yml4
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/volume_info/tasks/cleanup.yml5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/volume_info/tasks/main.yml31
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/volume_info/tasks/prepare.yml9
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/volume_info/tasks/test.yml81
-rw-r--r--ansible_collections/hetzner/hcloud/tests/requirements.yml8
-rw-r--r--ansible_collections/hetzner/hcloud/tests/sanity/ignore-2.12.txt2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/sanity/ignore-2.13.txt71
-rw-r--r--ansible_collections/hetzner/hcloud/tests/sanity/ignore-2.14.txt70
-rw-r--r--ansible_collections/hetzner/hcloud/tests/sanity/ignore-2.15.txt3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/sanity/ignore-2.16.txt1
-rw-r--r--ansible_collections/hetzner/hcloud/tests/unit/module_utils/test_hcloud.py125
-rw-r--r--ansible_collections/hetzner/hcloud/tests/unit/requirements.txt2
-rwxr-xr-xansible_collections/hetzner/hcloud/tests/utils/ci.sh141
-rwxr-xr-xansible_collections/hetzner/hcloud/tests/utils/gitlab/gitlab.sh68
-rwxr-xr-xansible_collections/hetzner/hcloud/tests/utils/gitlab/sanity.sh34
-rwxr-xr-xansible_collections/hetzner/hcloud/tests/utils/shippable/check_matrix.py120
-rwxr-xr-xansible_collections/hetzner/hcloud/tests/utils/shippable/hcloud.sh34
-rwxr-xr-xansible_collections/hetzner/hcloud/tests/utils/shippable/sanity.sh27
-rwxr-xr-xansible_collections/hetzner/hcloud/tests/utils/shippable/shippable.sh213
-rwxr-xr-xansible_collections/hetzner/hcloud/tests/utils/shippable/timing.py16
-rwxr-xr-xansible_collections/hetzner/hcloud/tests/utils/shippable/timing.sh5
332 files changed, 5144 insertions, 3188 deletions
diff --git a/ansible_collections/hetzner/hcloud/tests/config.yml b/ansible_collections/hetzner/hcloud/tests/config.yml
new file mode 100644
index 000000000..340add1aa
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/config.yml
@@ -0,0 +1,3 @@
+---
+modules:
+ python_requires: ">=3.8"
diff --git a/ansible_collections/hetzner/hcloud/tests/constraints.txt b/ansible_collections/hetzner/hcloud/tests/constraints.txt
new file mode 100644
index 000000000..7e72ee478
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/constraints.txt
@@ -0,0 +1,2 @@
+python-dateutil>=2.7.5
+requests>=2.20
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/README.md b/ansible_collections/hetzner/hcloud/tests/integration/README.md
new file mode 100644
index 000000000..e3bb08319
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/README.md
@@ -0,0 +1,27 @@
+# Integration tests
+
+This document provides information to work with the integration tests.
+
+## Guidelines
+
+A set of guidelines to follow when writing integrations tests.
+
+### Prepare and cleanup
+
+The integration tests use a small testing framework that helps to set up and teardown any resources needed or generated by the tests. This small testing framework is located in the `tests/integration/common` directory. The files within the `common` directory are then duplicated and kept in sync in all the integration tests targets (`tests/integration/targets/hcloud_*`).
+
+- Use a `tasks/prepare.yml` file to set up resources needed during the tests.
+- Use a `tasks/cleanup.yml` file to teardown resources from the `tasts/prepare.yml` tasks **and** the resources generated by the tests.
+- Use a `tasks/test.yml` file to defines your tests.
+- You may explode the tests into multiple `tasks/test-*.yml` files and import them in the `tasks/test.yml` file.
+- The `tasks/cleanup.yml` file cannot use variables present in the `tasks/prepare.yml` file because cleanup should also run before the prepare tasks.
+
+### Naming convention
+
+The integration tests handle a lot of different variables, names, identifier. To reduce this complexity, make sure to use the following naming conventions:
+
+- Any test resources MUST be registered using the `test_<resource>` variable name (e.g. `test_server` or `test_floating_ip`) and MUST be created and cleaned in the `tasks/prepare.yml` and `tasks/cleanup.yml`. The scope of this variable is the entire target.
+- In `tasks/prepare.yml`, tasks names MUST start with: `Create test_<resource>` (e.g. `Create test_server` or `Create test_floating_ip`)
+- In `tasks/cleanup.yml`, tasks names MUST start with: `Cleanup test_<resource>` (e.g. `Cleanup test_server` or `Cleanup test_floating_ip`)
+- Any fact starting with `_` is scoped to the current file and MUST NOT be used outside of it.
+- Any test result MUST be registered using the `result` variable name unless it is required in a future test, in that case it MUST use the `<resource>` variable name as prefix.
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/common/defaults/main/common.yml b/ansible_collections/hetzner/hcloud/tests/integration/common/defaults/main/common.yml
new file mode 100644
index 000000000..e45380565
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/common/defaults/main/common.yml
@@ -0,0 +1,9 @@
+---
+# 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('first') | join() }}"
+hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/common/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/common/tasks/main.yml
new file mode 100644
index 000000000..c3f93a394
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/common/tasks/main.yml
@@ -0,0 +1,28 @@
+---
+- 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/ansible_collections/hetzner/hcloud/tests/integration/constraints.txt b/ansible_collections/hetzner/hcloud/tests/integration/constraints.txt
deleted file mode 100644
index 19d5ecf28..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/constraints.txt
+++ /dev/null
@@ -1 +0,0 @@
-hcloud >= 1.10.0 # minimum version
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/requirements.txt b/ansible_collections/hetzner/hcloud/tests/integration/requirements.txt
index d3249deff..8b3801627 100644
--- a/ansible_collections/hetzner/hcloud/tests/integration/requirements.txt
+++ b/ansible_collections/hetzner/hcloud/tests/integration/requirements.txt
@@ -1,2 +1,5 @@
netaddr
-hcloud
+cryptography
+
+python-dateutil
+requests
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/certificate/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/certificate/aliases
new file mode 100644
index 000000000..0e887600e
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/certificate/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+azp/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/certificate/defaults/main/common.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/certificate/defaults/main/common.yml
new file mode 100644
index 000000000..e316b233c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/certificate/defaults/main/common.yml
@@ -0,0 +1,12 @@
+#
+# 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('first') | join() }}"
+hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/certificate/defaults/main/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/certificate/defaults/main/main.yml
new file mode 100644
index 000000000..e94b57771
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/certificate/defaults/main/main.yml
@@ -0,0 +1,5 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_certificate_name: "{{ hcloud_ns }}"
+hcloud_dns_test_domain: "{{ (hcloud_ns + 100 | random | string) | md5 }}.hc-integrations-test.de"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/certificate/meta/main.yml
index 34657c1c2..163f4db09 100644
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/meta/main.yml
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/certificate/meta/main.yml
@@ -1,4 +1,3 @@
+---
dependencies:
- setup_selfsigned_certificate
-collections:
- - hetzner.cloud
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/certificate/tasks/cleanup.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/certificate/tasks/cleanup.yml
new file mode 100644
index 000000000..2513909aa
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/certificate/tasks/cleanup.yml
@@ -0,0 +1,5 @@
+---
+- name: cleanup test certificate
+ hetzner.hcloud.certificate:
+ name: "{{ hcloud_certificate_name }}"
+ state: absent
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/certificate/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/certificate/tasks/main.yml
new file mode 100644
index 000000000..767fc465b
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/certificate/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/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/certificate/tasks/test.yml
index 615c89d0e..240e6a18c 100644
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/tasks/main.yml
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/certificate/tasks/test.yml
@@ -2,10 +2,10 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
- name: test missing required parameters on create certificate
- hcloud_certificate:
+ hetzner.hcloud.certificate:
name: "{{ hcloud_certificate_name }}"
register: result
- ignore_errors: yes
+ ignore_errors: true
- name: verify fail test missing required parameters on create certificate
assert:
that:
@@ -13,22 +13,22 @@
- 'result.msg == "missing required arguments: certificate, private_key"'
- name: test create certificate with check mode
- hcloud_certificate:
+ hetzner.hcloud.certificate:
name: "{{ hcloud_certificate_name }}"
- certificate: "{{ certificate_example_com }}"
- private_key: "{{ certificate_example_com_key }}"
+ certificate: "{{ test_certificate_content }}"
+ private_key: "{{ test_certificate_privatekey_content }}"
register: result
- check_mode: yes
+ check_mode: true
- name: test create certificate with check mode
assert:
that:
- result is changed
- name: test create certificate
- hcloud_certificate:
+ hetzner.hcloud.certificate:
name: "{{ hcloud_certificate_name }}"
- certificate: "{{ certificate_example_com }}"
- private_key: "{{ certificate_example_com_key }}"
+ certificate: "{{ test_certificate_content }}"
+ private_key: "{{ test_certificate_privatekey_content }}"
labels:
key: value
my-label: label
@@ -37,15 +37,15 @@
assert:
that:
- certificate is changed
- - certificate.hcloud_certificate.name == "{{ hcloud_certificate_name }}"
+ - certificate.hcloud_certificate.name == hcloud_certificate_name
- certificate.hcloud_certificate.domain_names[0] == "www.example.com"
- certificate.hcloud_certificate.labels.key == "value"
- name: test create certificate idempotence
- hcloud_certificate:
+ hetzner.hcloud.certificate:
name: "{{ hcloud_certificate_name }}"
- certificate: "{{ certificate_example_com }}"
- private_key: "{{ certificate_example_com_key }}"
+ certificate: "{{ test_certificate_content }}"
+ private_key: "{{ test_certificate_privatekey_content }}"
register: result
- name: verify create certificate idempotence
assert:
@@ -53,18 +53,18 @@
- result is not changed
- name: test update certificate with check mode
- hcloud_certificate:
+ hetzner.hcloud.certificate:
id: "{{ certificate.hcloud_certificate.id }}"
name: "changed-{{ hcloud_certificate_name }}"
register: result
- check_mode: yes
+ check_mode: true
- name: test create certificate with check mode
assert:
that:
- result is changed
- name: test update certificate
- hcloud_certificate:
+ hetzner.hcloud.certificate:
id: "{{ certificate.hcloud_certificate.id }}"
name: "changed-{{ hcloud_certificate_name }}"
labels:
@@ -77,7 +77,7 @@
- result.hcloud_certificate.name == "changed-{{ hcloud_certificate_name }}"
- name: test update certificate with same labels
- hcloud_certificate:
+ hetzner.hcloud.certificate:
id: "{{ certificate.hcloud_certificate.id }}"
name: "changed-{{ hcloud_certificate_name }}"
labels:
@@ -89,7 +89,7 @@
- result is not changed
- name: test update certificate with other labels
- hcloud_certificate:
+ hetzner.hcloud.certificate:
id: "{{ certificate.hcloud_certificate.id }}"
name: "changed-{{ hcloud_certificate_name }}"
labels:
@@ -102,7 +102,7 @@
- result is changed
- name: test rename certificate
- hcloud_certificate:
+ hetzner.hcloud.certificate:
id: "{{ certificate.hcloud_certificate.id }}"
name: "{{ hcloud_certificate_name }}"
register: result
@@ -110,10 +110,10 @@
assert:
that:
- result is changed
- - result.hcloud_certificate.name == "{{ hcloud_certificate_name }}"
+ - result.hcloud_certificate.name == hcloud_certificate_name
- name: absent certificate
- hcloud_certificate:
+ hetzner.hcloud.certificate:
id: "{{ certificate.hcloud_certificate.id }}"
state: absent
register: result
@@ -129,7 +129,7 @@
hcloud_dns_test_domain: "{{ hcloud_dns_test_domain }}"
- name: test create managed certificate
- hcloud_certificate:
+ hetzner.hcloud.certificate:
name: "{{ hcloud_certificate_name }}"
domain_names:
- "{{ hcloud_dns_test_domain }}"
@@ -141,15 +141,15 @@
assert:
that:
- result is changed
- - result.hcloud_certificate.name == "{{ hcloud_certificate_name }}"
- - result.hcloud_certificate.domain_names[0] == "{{ hcloud_dns_test_domain }}"
+ - result.hcloud_certificate.name == hcloud_certificate_name
+ - result.hcloud_certificate.domain_names[0] == hcloud_dns_test_domain
-- name: absent certificate
- hcloud_certificate:
+- name: test delete certificate
+ hetzner.hcloud.certificate:
id: "{{ result.hcloud_certificate.id }}"
state: absent
register: result
-- name: verify absent certificate
+- name: verify test delete certificate
assert:
that:
- result is success
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/certificate_info/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/certificate_info/aliases
new file mode 100644
index 000000000..0e887600e
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/certificate_info/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+azp/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/certificate_info/defaults/main/common.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/certificate_info/defaults/main/common.yml
new file mode 100644
index 000000000..e316b233c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/certificate_info/defaults/main/common.yml
@@ -0,0 +1,12 @@
+#
+# 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('first') | join() }}"
+hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/certificate_info/defaults/main/main.yml
index 05502aa91..5220424ed 100644
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/defaults/main.yml
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/certificate_info/defaults/main/main.yml
@@ -1,5 +1,4 @@
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
-hcloud_server_type_name: "cx11"
-hcloud_server_type_id: 1
+hcloud_certificate_name: "{{ hcloud_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/certificate_info/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/certificate_info/meta/main.yml
new file mode 100644
index 000000000..163f4db09
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/certificate_info/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_selfsigned_certificate
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/certificate_info/tasks/cleanup.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/certificate_info/tasks/cleanup.yml
new file mode 100644
index 000000000..59a50c8f7
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/certificate_info/tasks/cleanup.yml
@@ -0,0 +1,5 @@
+---
+- name: Cleanup test_certificate
+ hetzner.hcloud.certificate:
+ name: "{{ hcloud_certificate_name }}"
+ state: absent
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/certificate_info/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/certificate_info/tasks/main.yml
new file mode 100644
index 000000000..767fc465b
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/certificate_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/ansible_collections/hetzner/hcloud/tests/integration/targets/certificate_info/tasks/prepare.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/certificate_info/tasks/prepare.yml
new file mode 100644
index 000000000..bb1dacdc5
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/certificate_info/tasks/prepare.yml
@@ -0,0 +1,10 @@
+---
+- name: Create test_certificate
+ hetzner.hcloud.certificate:
+ name: "{{ hcloud_certificate_name }}"
+ certificate: "{{ test_certificate_content }}"
+ private_key: "{{ test_certificate_privatekey_content }}"
+ labels:
+ key: value
+ my-label: label
+ register: test_certificate
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/certificate_info/tasks/test.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/certificate_info/tasks/test.yml
new file mode 100644
index 000000000..d15db0aee
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/certificate_info/tasks/test.yml
@@ -0,0 +1,77 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: Gather hcloud_certificate_info
+ hetzner.hcloud.certificate_info:
+ register: result
+- name: Verify hcloud_certificate_info
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_certificate_info | list | count >= 1
+
+- name: Gather hcloud_certificate_info in check mode
+ hetzner.hcloud.certificate_info:
+ check_mode: true
+ register: result
+- name: Verify hcloud_certificate_info in check mode
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_certificate_info | list | count >= 1
+
+- name: Gather hcloud_certificate_info with correct id
+ hetzner.hcloud.certificate_info:
+ id: "{{ test_certificate.hcloud_certificate.id }}"
+ register: result
+- name: Verify hcloud_certificate_info with correct id
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_certificate_info | list | count == 1
+
+- name: Gather hcloud_certificate_info with wrong id
+ hetzner.hcloud.certificate_info:
+ id: "{{ test_certificate.hcloud_certificate.id }}4321"
+ ignore_errors: true
+ register: result
+- name: Verify hcloud_certificate_info with wrong id
+ ansible.builtin.assert:
+ that:
+ - result is failed
+
+- name: Gather hcloud_certificate_info with correct name
+ hetzner.hcloud.certificate_info:
+ name: "{{ hcloud_certificate_name }}"
+ register: result
+- name: Verify hcloud_certificate_info with correct name
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_certificate_info | list | count == 1
+
+- name: Gather hcloud_certificate_info with wrong name
+ hetzner.hcloud.certificate_info:
+ name: "{{ hcloud_certificate_name }}-invalid"
+ register: result
+- name: Verify hcloud_certificate_info with wrong name
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_certificate_info | list | count == 0
+
+- name: Gather hcloud_certificate_info with correct label selector
+ hetzner.hcloud.certificate_info:
+ label_selector: "key=value"
+ register: result
+- name: Verify hcloud_certificate_info with correct label selector
+ ansible.builtin.assert:
+ that:
+ - >
+ result.hcloud_certificate_info
+ | selectattr('name', 'equalto', hcloud_certificate_name)
+ | list | count == 1
+
+- name: Gather hcloud_certificate_info with wrong label selector
+ hetzner.hcloud.certificate_info:
+ label_selector: "key!=value"
+ register: result
+- name: Verify hcloud_certificate_info with wrong label selector
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_certificate_info | list | count == 0
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/datacenter_info/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/datacenter_info/aliases
new file mode 100644
index 000000000..0e887600e
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/datacenter_info/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+azp/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/datacenter_info/defaults/main/common.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/datacenter_info/defaults/main/common.yml
new file mode 100644
index 000000000..e316b233c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/datacenter_info/defaults/main/common.yml
@@ -0,0 +1,12 @@
+#
+# 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('first') | join() }}"
+hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/datacenter_info/defaults/main/main.yml
index b9e045f40..61490c913 100644
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/defaults/main.yml
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/datacenter_info/defaults/main/main.yml
@@ -1,6 +1,6 @@
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
-hcloud_datacenter_name: "fsn1-dc14"
hcloud_datacenter_id: 4
-hcloud_location_name: "fsn1"
+hcloud_datacenter_name: fsn1-dc14
+hcloud_location_name: fsn1
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/datacenter_info/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/datacenter_info/tasks/main.yml
new file mode 100644
index 000000000..767fc465b
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/datacenter_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/ansible_collections/hetzner/hcloud/tests/integration/targets/datacenter_info/tasks/test.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/datacenter_info/tasks/test.yml
new file mode 100644
index 000000000..530b4ddb2
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/datacenter_info/tasks/test.yml
@@ -0,0 +1,58 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: Gather hcloud_datacenter_info
+ hetzner.hcloud.datacenter_info:
+ register: result
+- name: Verify hcloud_datacenter_info
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_datacenter_info | list | count >= 5
+
+- name: Gather hcloud_datacenter_info in check mode
+ hetzner.hcloud.datacenter_info:
+ check_mode: true
+ register: result
+- name: Verify hcloud_datacenter_info in check mode
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_datacenter_info | list | count >= 5
+
+- name: Gather hcloud_datacenter_info with correct id
+ hetzner.hcloud.datacenter_info:
+ id: "{{ hcloud_datacenter_id }}"
+ register: result
+- name: Verify hcloud_datacenter_info with correct id
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_datacenter_info | list | count == 1
+ - result.hcloud_datacenter_info[0].name == hcloud_datacenter_name
+ - result.hcloud_datacenter_info[0].location == hcloud_location_name
+
+- name: Gather hcloud_datacenter_info with wrong id
+ hetzner.hcloud.datacenter_info:
+ id: "{{ hcloud_datacenter_id }}4321"
+ ignore_errors: true
+ register: result
+- name: Verify hcloud_datacenter_info with wrong id
+ ansible.builtin.assert:
+ that:
+ - result is failed
+
+- name: Gather hcloud_datacenter_info with correct name
+ hetzner.hcloud.datacenter_info:
+ name: "{{ hcloud_datacenter_name }}"
+ register: result
+- name: Verify hcloud_datacenter_info with correct name
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_datacenter_info | list | count == 1
+
+- name: Gather hcloud_datacenter_info with wrong name
+ hetzner.hcloud.datacenter_info:
+ name: "{{ hcloud_datacenter_name }}-invalid"
+ register: result
+- name: Verify hcloud_datacenter_info with wrong name
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_datacenter_info | list | count == 0
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall/aliases
new file mode 100644
index 000000000..0e887600e
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+azp/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall/defaults/main/common.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall/defaults/main/common.yml
new file mode 100644
index 000000000..e316b233c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall/defaults/main/common.yml
@@ -0,0 +1,12 @@
+#
+# 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('first') | join() }}"
+hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall/defaults/main/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall/defaults/main/main.yml
new file mode 100644
index 000000000..989e14fd1
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall/defaults/main/main.yml
@@ -0,0 +1,5 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_firewall_name: "{{ hcloud_ns }}"
+hcloud_server_name: "{{ hcloud_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall/tasks/cleanup.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall/tasks/cleanup.yml
new file mode 100644
index 000000000..37fbd3413
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall/tasks/cleanup.yml
@@ -0,0 +1,10 @@
+---
+- name: Cleanup test_server
+ hetzner.hcloud.server:
+ name: "{{ hcloud_server_name }}"
+ state: absent
+
+- name: Cleanup test_firewall
+ hetzner.hcloud.firewall:
+ name: "{{ hcloud_firewall_name }}"
+ state: absent
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall/tasks/main.yml
new file mode 100644
index 000000000..767fc465b
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall/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/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall/tasks/prepare.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall/tasks/prepare.yml
new file mode 100644
index 000000000..cf6daa322
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall/tasks/prepare.yml
@@ -0,0 +1,8 @@
+---
+- name: Create test_server
+ hetzner.hcloud.server:
+ name: "{{ hcloud_server_name }}"
+ server_type: cx11
+ image: ubuntu-22.04
+ state: stopped
+ register: test_server
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall/tasks/test.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall/tasks/test.yml
new file mode 100644
index 000000000..57059848f
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall/tasks/test.yml
@@ -0,0 +1,197 @@
+# Copyright: (c) 2020, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: Test missing required parameters
+ hetzner.hcloud.firewall:
+ state: present
+ ignore_errors: true
+ register: result
+- name: Verify missing required parameters
+ ansible.builtin.assert:
+ that:
+ - result is failed
+ - 'result.msg == "one of the following is required: id, name"'
+
+- name: Test create with check mode
+ hetzner.hcloud.firewall:
+ name: "{{ hcloud_firewall_name }}"
+ rules:
+ - description: allow icmp in
+ direction: in
+ protocol: icmp
+ source_ips: ["0.0.0.0/0", "::/0"]
+ labels:
+ key: value
+ check_mode: true
+ register: result
+- name: Verify create with check mode
+ ansible.builtin.assert:
+ that:
+ - result is changed
+
+- name: Test create
+ hetzner.hcloud.firewall:
+ name: "{{ hcloud_firewall_name }}"
+ rules:
+ - description: allow icmp in
+ direction: in
+ protocol: icmp
+ source_ips: ["0.0.0.0/0", "::/0"]
+ labels:
+ key: value
+ register: result
+- name: Verify create
+ ansible.builtin.assert:
+ that:
+ - result is changed
+ - result.hcloud_firewall.name == hcloud_firewall_name
+ - result.hcloud_firewall.rules | list | count == 1
+ - result.hcloud_firewall.rules[0].description == "allow icmp in"
+ - result.hcloud_firewall.rules[0].direction == "in"
+ - result.hcloud_firewall.rules[0].protocol == "icmp"
+ - result.hcloud_firewall.rules[0].source_ips == ["0.0.0.0/0", "::/0"]
+ - result.hcloud_firewall.labels.key == "value"
+ - result.hcloud_firewall.applied_to | list | count == 0
+
+- name: Test create idempotency
+ hetzner.hcloud.firewall:
+ name: "{{ hcloud_firewall_name }}"
+ rules:
+ - description: allow icmp in
+ direction: in
+ protocol: icmp
+ source_ips: ["0.0.0.0/0", "::/0"]
+ labels:
+ key: value
+ register: result
+- name: Verify create idempotency
+ ansible.builtin.assert:
+ that:
+ - result is not changed
+
+- name: Assign firewall to test_server
+ hetzner.hcloud.firewall_resource:
+ firewall: "{{ hcloud_firewall_name }}"
+ servers: ["{{ test_server.hcloud_server.name }}"]
+ state: present
+
+- name: Test update
+ hetzner.hcloud.firewall:
+ name: "{{ hcloud_firewall_name }}"
+ rules:
+ - description: allow icmp in
+ direction: in
+ protocol: icmp
+ source_ips: ["0.0.0.0/0", "::/0"]
+ - description: allow http in
+ direction: in
+ protocol: tcp
+ port: 80
+ source_ips: ["0.0.0.0/0", "::/0"]
+ - description: allow http out
+ direction: out
+ protocol: tcp
+ port: 80
+ destination_ips: ["0.0.0.0/0", "::/0"]
+ labels:
+ key: value
+ label: label
+ register: result
+- name: Verify update
+ ansible.builtin.assert:
+ that:
+ - result is changed
+ - result.hcloud_firewall.name == hcloud_firewall_name
+ - result.hcloud_firewall.rules | list | count == 3
+ - result.hcloud_firewall.rules[0].description == "allow icmp in"
+ - result.hcloud_firewall.rules[0].direction == "in"
+ - result.hcloud_firewall.rules[0].protocol == "icmp"
+ - result.hcloud_firewall.rules[0].source_ips == ["0.0.0.0/0", "::/0"]
+ - result.hcloud_firewall.rules[1].description == "allow http in"
+ - result.hcloud_firewall.rules[1].direction == "in"
+ - result.hcloud_firewall.rules[1].protocol == "tcp"
+ - result.hcloud_firewall.rules[1].port == "80"
+ - result.hcloud_firewall.rules[1].source_ips == ["0.0.0.0/0", "::/0"]
+ - result.hcloud_firewall.rules[2].description == "allow http out"
+ - result.hcloud_firewall.rules[2].direction == "out"
+ - result.hcloud_firewall.rules[2].protocol == "tcp"
+ - result.hcloud_firewall.rules[2].port == "80"
+ - result.hcloud_firewall.rules[2].destination_ips == ["0.0.0.0/0", "::/0"]
+ - result.hcloud_firewall.labels.key == "value"
+ - result.hcloud_firewall.labels.label == "label"
+
+- name: Test update idempotency
+ hetzner.hcloud.firewall:
+ name: "{{ hcloud_firewall_name }}"
+ rules:
+ - description: allow icmp in
+ direction: in
+ protocol: icmp
+ source_ips: ["0.0.0.0/0", "::/0"]
+ - description: allow http in
+ direction: in
+ protocol: tcp
+ port: 80
+ source_ips: ["0.0.0.0/0", "::/0"]
+ - description: allow http out
+ direction: out
+ protocol: tcp
+ port: 80
+ destination_ips: ["0.0.0.0/0", "::/0"]
+ labels:
+ key: value
+ label: label
+ register: result
+- name: Verify update idempotency
+ ansible.builtin.assert:
+ that:
+ - result is not changed
+
+- name: Test update name
+ hetzner.hcloud.firewall:
+ id: "{{ result.hcloud_firewall.id }}"
+ name: "changed-{{ hcloud_firewall_name }}"
+ register: result
+- name: Verify update name
+ ansible.builtin.assert:
+ that:
+ - result is changed
+ - result.hcloud_firewall.name == "changed-" + hcloud_firewall_name
+
+- name: Test update name and labels
+ hetzner.hcloud.firewall:
+ id: "{{ result.hcloud_firewall.id }}"
+ name: "{{ hcloud_firewall_name }}"
+ labels:
+ key: value
+ register: result
+- name: Verify update name and labels
+ ansible.builtin.assert:
+ that:
+ - result is changed
+ - result.hcloud_firewall.name == hcloud_firewall_name
+ - result.hcloud_firewall.labels.key == "value"
+ - result.hcloud_firewall.labels.label is not defined
+
+- name: Test delete
+ hetzner.hcloud.firewall:
+ name: "{{ hcloud_firewall_name }}"
+ state: absent
+ ignore_errors: true
+ register: result
+- name: Verify delete
+ ansible.builtin.assert:
+ that:
+ - result is failed
+ - '"is still in use" in result.msg'
+
+- name: Test delete with force
+ hetzner.hcloud.firewall:
+ name: "{{ hcloud_firewall_name }}"
+ force: true
+ state: absent
+ register: result
+- name: Verify delete with force
+ ansible.builtin.assert:
+ that:
+ - result is changed
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_info/aliases
index 55ec821a4..55ec821a4 100644
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/aliases
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_info/aliases
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_info/defaults/main/common.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_info/defaults/main/common.yml
new file mode 100644
index 000000000..e316b233c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_info/defaults/main/common.yml
@@ -0,0 +1,12 @@
+#
+# 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('first') | join() }}"
+hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_info/defaults/main/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_info/defaults/main/main.yml
new file mode 100644
index 000000000..441e948ed
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_info/defaults/main/main.yml
@@ -0,0 +1,5 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_server_name: "{{ hcloud_ns }}"
+hcloud_firewall_name: "{{ hcloud_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_info/tasks/cleanup.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_info/tasks/cleanup.yml
new file mode 100644
index 000000000..37fbd3413
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_info/tasks/cleanup.yml
@@ -0,0 +1,10 @@
+---
+- name: Cleanup test_server
+ hetzner.hcloud.server:
+ name: "{{ hcloud_server_name }}"
+ state: absent
+
+- name: Cleanup test_firewall
+ hetzner.hcloud.firewall:
+ name: "{{ hcloud_firewall_name }}"
+ state: absent
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_info/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_info/tasks/main.yml
new file mode 100644
index 000000000..767fc465b
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_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/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_info/tasks/prepare.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_info/tasks/prepare.yml
new file mode 100644
index 000000000..17d4ebcc4
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_info/tasks/prepare.yml
@@ -0,0 +1,35 @@
+---
+- name: Create test_server
+ hetzner.hcloud.server:
+ name: "{{ hcloud_server_name }}"
+ server_type: cx11
+ image: ubuntu-22.04
+ labels:
+ firewall: "{{ hcloud_firewall_name }}"
+ state: stopped
+ register: test_server
+
+- name: Create test_firewall
+ hetzner.hcloud.firewall:
+ name: "{{ hcloud_firewall_name }}"
+ labels:
+ key: value
+ rules:
+ - description: allow icmp from anywhere
+ direction: in
+ protocol: icmp
+ source_ips:
+ - 0.0.0.0/0
+ - ::/0
+ state: present
+ register: test_firewall
+
+- name: Create test_firewall_resource
+ hetzner.hcloud.firewall_resource:
+ firewall: "{{ hcloud_firewall_name }}"
+ servers:
+ - "{{ hcloud_server_name }}"
+ label_selectors:
+ - firewall={{ hcloud_firewall_name }}
+ state: present
+ register: test_firewall_resource
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_info/tasks/test.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_info/tasks/test.yml
new file mode 100644
index 000000000..fc9a38af2
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_info/tasks/test.yml
@@ -0,0 +1,93 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: Gather hcloud_firewall_info
+ hetzner.hcloud.firewall_info:
+ register: result
+- name: Verify hcloud_firewall_info
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_firewall_info | list | count >= 1
+
+- name: Gather hcloud_firewall_info in check mode
+ hetzner.hcloud.firewall_info:
+ check_mode: true
+ register: result
+- name: Verify hcloud_firewall_info in check mode
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_firewall_info | list | count >= 1
+
+- name: Gather hcloud_firewall_info with correct id
+ hetzner.hcloud.firewall_info:
+ id: "{{ test_firewall.hcloud_firewall.id }}"
+ register: result
+- name: Verify hcloud_firewall_info with correct id
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_firewall_info | list | count == 1
+ - result.hcloud_firewall_info[0].name == hcloud_firewall_name
+ - result.hcloud_firewall_info[0].labels.key == "value"
+ - result.hcloud_firewall_info[0].rules | list | count == 1
+ - result.hcloud_firewall_info[0].rules[0].description == "allow icmp from anywhere"
+ - result.hcloud_firewall_info[0].rules[0].direction == "in"
+ - result.hcloud_firewall_info[0].rules[0].protocol == "icmp"
+ - result.hcloud_firewall_info[0].rules[0].source_ips == ["0.0.0.0/0", "::/0"]
+ - result.hcloud_firewall_info[0].applied_to | list | count == 2
+ - >
+ result.hcloud_firewall_info[0].applied_to
+ | selectattr('type', 'equalto', 'label_selector')
+ | list | count == 1
+ - >
+ result.hcloud_firewall_info[0].applied_to
+ | selectattr('type', 'equalto', 'server')
+ | list | count == 1
+
+- name: Gather hcloud_firewall_info with wrong id
+ hetzner.hcloud.firewall_info:
+ id: "{{ test_firewall.hcloud_firewall.id }}4321"
+ ignore_errors: true
+ register: result
+- name: Verify hcloud_firewall_info with wrong id
+ ansible.builtin.assert:
+ that:
+ - result is failed
+
+- name: Gather hcloud_firewall_info with correct name
+ hetzner.hcloud.firewall_info:
+ name: "{{ hcloud_firewall_name }}"
+ register: result
+- name: Verify hcloud_firewall_info with correct name
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_firewall_info | list | count == 1
+
+- name: Gather hcloud_firewall_info with wrong name
+ hetzner.hcloud.firewall_info:
+ name: "{{ hcloud_firewall_name }}-invalid"
+ register: result
+- name: Verify hcloud_firewall_info with wrong name
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_firewall_info | list | count == 0
+
+- name: Gather hcloud_firewall_info with correct label selector
+ hetzner.hcloud.firewall_info:
+ label_selector: "key=value"
+ register: result
+- name: Verify hcloud_firewall_info with correct label selector
+ ansible.builtin.assert:
+ that:
+ - >
+ result.hcloud_firewall_info
+ | selectattr('name', 'equalto', hcloud_firewall_name)
+ | list | count == 1
+
+- name: Gather hcloud_firewall_info with wrong label selector
+ hetzner.hcloud.firewall_info:
+ label_selector: "key!=value"
+ register: result
+- name: Verify hcloud_firewall_info with wrong label selector
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_firewall_info | list | count == 0
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_resource/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_resource/aliases
new file mode 100644
index 000000000..0e887600e
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_resource/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+azp/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_resource/defaults/main/common.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_resource/defaults/main/common.yml
new file mode 100644
index 000000000..e316b233c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_resource/defaults/main/common.yml
@@ -0,0 +1,12 @@
+#
+# 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('first') | join() }}"
+hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_resource/defaults/main/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_resource/defaults/main/main.yml
new file mode 100644
index 000000000..441e948ed
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_resource/defaults/main/main.yml
@@ -0,0 +1,5 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_server_name: "{{ hcloud_ns }}"
+hcloud_firewall_name: "{{ hcloud_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_resource/tasks/cleanup.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_resource/tasks/cleanup.yml
new file mode 100644
index 000000000..37fbd3413
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_resource/tasks/cleanup.yml
@@ -0,0 +1,10 @@
+---
+- name: Cleanup test_server
+ hetzner.hcloud.server:
+ name: "{{ hcloud_server_name }}"
+ state: absent
+
+- name: Cleanup test_firewall
+ hetzner.hcloud.firewall:
+ name: "{{ hcloud_firewall_name }}"
+ state: absent
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_resource/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_resource/tasks/main.yml
new file mode 100644
index 000000000..767fc465b
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_resource/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/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_resource/tasks/prepare.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_resource/tasks/prepare.yml
new file mode 100644
index 000000000..6fb6fd2df
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_resource/tasks/prepare.yml
@@ -0,0 +1,25 @@
+---
+- name: Create test_server
+ hetzner.hcloud.server:
+ name: "{{ hcloud_server_name }}"
+ server_type: cx11
+ image: ubuntu-22.04
+ labels:
+ key: value
+ state: stopped
+ register: test_server
+
+- name: Create test_firewall
+ hetzner.hcloud.firewall:
+ name: "{{ hcloud_firewall_name }}"
+ labels:
+ key: value
+ rules:
+ - description: allow icmp from anywhere
+ direction: in
+ protocol: icmp
+ source_ips:
+ - 0.0.0.0/0
+ - ::/0
+ state: present
+ register: test_firewall
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_resource/tasks/test.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_resource/tasks/test.yml
new file mode 100644
index 000000000..088e78413
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/firewall_resource/tasks/test.yml
@@ -0,0 +1,95 @@
+# Copyright: (c) 2020, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: Test missing required parameters
+ hetzner.hcloud.firewall_resource:
+ firewall: "{{ hcloud_firewall_name }}"
+ state: present
+ ignore_errors: true
+ register: result
+- name: Verify missing required parameters
+ ansible.builtin.assert:
+ that:
+ - result is failed
+ - 'result.msg == "one of the following is required: servers, label_selectors"'
+
+- name: Test create with check mode
+ hetzner.hcloud.firewall_resource:
+ firewall: "{{ hcloud_firewall_name }}"
+ servers: ["{{ hcloud_server_name }}"]
+ check_mode: true
+ register: result
+- name: Verify create with check mode
+ ansible.builtin.assert:
+ that:
+ - result is changed
+
+- name: Test create
+ hetzner.hcloud.firewall_resource:
+ firewall: "{{ hcloud_firewall_name }}"
+ servers: ["{{ hcloud_server_name }}"]
+ register: result
+- name: Verify create
+ ansible.builtin.assert:
+ that:
+ - result is changed
+ - result.hcloud_firewall_resource.firewall == hcloud_firewall_name
+ - result.hcloud_firewall_resource.servers | list | count == 1
+ - result.hcloud_firewall_resource.servers[0] == hcloud_server_name
+ - result.hcloud_firewall_resource.label_selectors | list | count == 0
+
+- name: Test create idempotency
+ hetzner.hcloud.firewall_resource:
+ firewall: "{{ hcloud_firewall_name }}"
+ servers: ["{{ hcloud_server_name }}"]
+ register: result
+- name: Verify create idempotency
+ ansible.builtin.assert:
+ that:
+ - result is not changed
+
+- name: Test update
+ hetzner.hcloud.firewall_resource:
+ firewall: "{{ hcloud_firewall_name }}"
+ label_selectors:
+ - key=value
+ register: result
+- name: Verify update
+ ansible.builtin.assert:
+ that:
+ - result is changed
+ - result.hcloud_firewall_resource.label_selectors | list | count == 1
+ - result.hcloud_firewall_resource.label_selectors[0] == "key=value"
+
+- name: Test update idempotency
+ hetzner.hcloud.firewall_resource:
+ firewall: "{{ hcloud_firewall_name }}"
+ label_selectors:
+ - key=value
+ register: result
+- name: Verify update idempotency
+ ansible.builtin.assert:
+ that:
+ - result is not changed
+
+- name: Test delete servers
+ hetzner.hcloud.firewall_resource:
+ firewall: "{{ hcloud_firewall_name }}"
+ servers: ["{{ hcloud_server_name }}"]
+ state: absent
+ register: result
+- name: Verify delete
+ ansible.builtin.assert:
+ that:
+ - result is changed
+
+- name: Test delete label_selectors
+ hetzner.hcloud.firewall_resource:
+ firewall: "{{ hcloud_firewall_name }}"
+ label_selectors: ["key=value"]
+ state: absent
+ register: result
+- name: Verify delete
+ ansible.builtin.assert:
+ that:
+ - result is changed
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip/aliases
new file mode 100644
index 000000000..a6a90a6bf
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+azp/group3
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip/defaults/main/common.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip/defaults/main/common.yml
new file mode 100644
index 000000000..e316b233c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip/defaults/main/common.yml
@@ -0,0 +1,12 @@
+#
+# 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('first') | join() }}"
+hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip/defaults/main/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip/defaults/main/main.yml
new file mode 100644
index 000000000..a2d33ff80
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip/defaults/main/main.yml
@@ -0,0 +1,5 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_floating_ip_name: "{{ hcloud_ns }}"
+hcloud_server_name: "{{ hcloud_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip/tasks/main.yml
new file mode 100644
index 000000000..767fc465b
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip/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/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip/tasks/test.yml
index 8ada4172f..fba06e308 100644
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/tasks/main.yml
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip/tasks/test.yml
@@ -1,11 +1,26 @@
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
+- name: setup ensure server is absent
+ hetzner.hcloud.server:
+ name: "{{ hcloud_server_name }}"
+ state: absent
+
+- name: setup ensure another server is absent
+ hetzner.hcloud.server:
+ name: "{{ hcloud_server_name }}2"
+ state: absent
+
+- name: setup ensure floating ip is absent
+ hetzner.hcloud.floating_ip:
+ name: "{{ hcloud_floating_ip_name }}"
+ state: absent
+
- name: setup server
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
server_type: cx11
- image: ubuntu-18.04
+ image: ubuntu-22.04
state: started
location: "fsn1"
register: main_server
@@ -15,10 +30,10 @@
- main_server is changed
- name: setup another server
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}2"
server_type: cx11
- image: ubuntu-18.04
+ image: ubuntu-22.04
state: started
register: main_server2
- name: verify setup another server
@@ -27,10 +42,10 @@
- main_server2 is changed
- name: test missing type parameter on create Floating IP
- hcloud_floating_ip:
+ hetzner.hcloud.floating_ip:
name: "{{ hcloud_floating_ip_name }}"
register: result
- ignore_errors: yes
+ ignore_errors: true
- name: verify fail test missing type parameter on create Floating IP
assert:
that:
@@ -38,11 +53,11 @@
- 'result.msg == "missing required arguments: type"'
- name: test missing required parameters on create Floating IP
- hcloud_floating_ip:
+ hetzner.hcloud.floating_ip:
name: "{{ hcloud_floating_ip_name }}"
type: ipv4
register: result
- ignore_errors: yes
+ ignore_errors: true
- name: verify fail test missing required parameters on create Floating IP
assert:
that:
@@ -50,26 +65,25 @@
- 'result.msg == "one of the following is required: home_location, server"'
- name: test missing type parameter on delete Floating IP
- hcloud_floating_ip:
+ hetzner.hcloud.floating_ip:
type: ipv4
home_location: "fsn1"
state: "absent"
register: result
- ignore_errors: yes
+ ignore_errors: true
- name: verify fail test missing type parameter on delete Floating IP
assert:
that:
- result is failed
- 'result.msg == "one of the following is required: id, name"'
-
- name: test invalid type
- hcloud_floating_ip:
+ hetzner.hcloud.floating_ip:
name: "{{ hcloud_floating_ip_name }}"
type: ipv5
home_location: "fsn1"
register: result
- ignore_errors: yes
+ ignore_errors: true
- name: verify invalid type
assert:
that:
@@ -77,12 +91,12 @@
- 'result.msg == "value of type must be one of: ipv4, ipv6, got: ipv5"'
- name: test invalid location
- hcloud_floating_ip:
+ hetzner.hcloud.floating_ip:
name: "{{ hcloud_floating_ip_name }}"
type: ipv4
home_location: "abc"
register: result
- ignore_errors: yes
+ ignore_errors: true
- name: verify invalid location
assert:
that:
@@ -90,20 +104,20 @@
- result.msg == "invalid input in fields 'server', 'home_location'"
- name: test create Floating IP with check mode
- hcloud_floating_ip:
+ hetzner.hcloud.floating_ip:
name: "{{ hcloud_floating_ip_name }}"
description: "Web Server"
type: ipv4
home_location: "fsn1"
register: floatingIP
- check_mode: yes
+ check_mode: true
- name: verify test create Floating IP with check mode
assert:
that:
- floatingIP is changed
- name: test create Floating IP
- hcloud_floating_ip:
+ hetzner.hcloud.floating_ip:
name: "{{ hcloud_floating_ip_name }}"
description: "Web Server"
type: ipv4
@@ -118,7 +132,7 @@
- floatingIP.hcloud_floating_ip.home_location == "fsn1"
- name: test create Floating IP idempotency
- hcloud_floating_ip:
+ hetzner.hcloud.floating_ip:
name: "{{ hcloud_floating_ip_name }}"
description: "Web Server"
type: ipv4
@@ -130,12 +144,12 @@
- floatingIP is not changed
- name: test update Floating IP with check mode
- hcloud_floating_ip:
+ hetzner.hcloud.floating_ip:
name: "{{ hcloud_floating_ip_name }}"
description: "changed-description"
type: ipv4
home_location: "fsn1"
- check_mode: yes
+ check_mode: true
register: floatingIP
- name: verify test create Floating IP with check mode
assert:
@@ -144,7 +158,7 @@
- floatingIP.hcloud_floating_ip.description == "Web Server"
- name: test update Floating IP
- hcloud_floating_ip:
+ hetzner.hcloud.floating_ip:
name: "{{ hcloud_floating_ip_name }}"
description: "changed-description"
type: ipv4
@@ -159,7 +173,7 @@
- floatingIP.hcloud_floating_ip.description == "changed-description"
- name: test update Floating IP idempotency
- hcloud_floating_ip:
+ hetzner.hcloud.floating_ip:
name: "{{ hcloud_floating_ip_name }}"
description: "changed-description"
type: ipv4
@@ -173,7 +187,7 @@
- floatingIP is not changed
- name: test update Floating IP with same labels
- hcloud_floating_ip:
+ hetzner.hcloud.floating_ip:
name: "{{ hcloud_floating_ip_name }}"
type: ipv4
home_location: "fsn1"
@@ -186,7 +200,7 @@
- floatingIP is not changed
- name: test update Floating IP with other labels
- hcloud_floating_ip:
+ hetzner.hcloud.floating_ip:
name: "{{ hcloud_floating_ip_name }}"
type: ipv4
home_location: "fsn1"
@@ -200,7 +214,7 @@
- floatingIP is changed
- name: test update Floating IP with other labels in different order
- hcloud_floating_ip:
+ hetzner.hcloud.floating_ip:
name: "{{ hcloud_floating_ip_name }}"
type: ipv4
home_location: "fsn1"
@@ -214,21 +228,21 @@
- floatingIP is not changed
- name: test assign Floating IP with checkmode
- hcloud_floating_ip:
+ hetzner.hcloud.floating_ip:
name: "{{ hcloud_floating_ip_name }}"
description: "changed-description"
type: ipv4
server: "{{ main_server.hcloud_server.name }}"
- check_mode: yes
+ check_mode: true
register: floatingIP
- name: verify test assign Floating IP with checkmode
assert:
that:
- floatingIP is changed
- - floatingIP.hcloud_floating_ip.server != "{{ main_server.hcloud_server.name }}"
+ - floatingIP.hcloud_floating_ip.server != main_server.hcloud_server.name
- name: test assign Floating IP
- hcloud_floating_ip:
+ hetzner.hcloud.floating_ip:
name: "{{ hcloud_floating_ip_name }}"
description: "changed-description"
type: ipv4
@@ -238,10 +252,10 @@
assert:
that:
- floatingIP is changed
- - floatingIP.hcloud_floating_ip.server == "{{ main_server.hcloud_server.name }}"
+ - floatingIP.hcloud_floating_ip.server == main_server.hcloud_server.name
- name: test assign Floating IP idempotency
- hcloud_floating_ip:
+ hetzner.hcloud.floating_ip:
name: "{{ hcloud_floating_ip_name }}"
description: "changed-description"
type: ipv4
@@ -253,7 +267,7 @@
- floatingIP is not changed
- name: test unassign Floating IP
- hcloud_floating_ip:
+ hetzner.hcloud.floating_ip:
name: "{{ hcloud_floating_ip_name }}"
type: ipv4
home_location: "fsn1"
@@ -262,10 +276,10 @@
assert:
that:
- floatingIP is changed
- - floatingIP.hcloud_floating_ip.server != "{{ main_server.hcloud_server.name }}"
+ - floatingIP.hcloud_floating_ip.server != main_server.hcloud_server.name
- name: test unassign Floating IP idempotency
- hcloud_floating_ip:
+ hetzner.hcloud.floating_ip:
name: "{{ hcloud_floating_ip_name }}"
type: ipv4
home_location: "fsn1"
@@ -276,7 +290,7 @@
- floatingIP is not changed
- name: test assign Floating IP again
- hcloud_floating_ip:
+ hetzner.hcloud.floating_ip:
name: "{{ hcloud_floating_ip_name }}"
type: ipv4
server: "{{ main_server.hcloud_server.name }}"
@@ -285,10 +299,10 @@
assert:
that:
- floatingIP is changed
- - floatingIP.hcloud_floating_ip.server == "{{ main_server.hcloud_server.name }}"
+ - floatingIP.hcloud_floating_ip.server == main_server.hcloud_server.name
- name: test already assigned Floating IP assign without force
- hcloud_floating_ip:
+ hetzner.hcloud.floating_ip:
name: "{{ hcloud_floating_ip_name }}"
type: ipv4
server: "{{ main_server2.hcloud_server.name }}"
@@ -297,23 +311,23 @@
assert:
that:
- floatingIP is changed
- - floatingIP.hcloud_floating_ip.server == "{{ main_server.hcloud_server.name }}"
+ - floatingIP.hcloud_floating_ip.server == main_server.hcloud_server.name
- name: test already assigned Floating IP assign with force
- hcloud_floating_ip:
+ hetzner.hcloud.floating_ip:
name: "{{ hcloud_floating_ip_name }}"
type: ipv4
- force: yes
+ force: true
server: "{{ main_server2.hcloud_server.name }}"
register: floatingIP
- name: verify test already assigned Floating IP assign with force
assert:
that:
- floatingIP is changed
- - floatingIP.hcloud_floating_ip.server == "{{ main_server2.hcloud_server.name }}"
+ - floatingIP.hcloud_floating_ip.server == main_server2.hcloud_server.name
- name: test update Floating IP delete protection
- hcloud_floating_ip:
+ hetzner.hcloud.floating_ip:
name: "{{ hcloud_floating_ip_name }}"
type: ipv4
delete_protection: true
@@ -325,7 +339,7 @@
- floatingIP.hcloud_floating_ip.delete_protection is sameas true
- name: test update Floating IP delete protection idempotency
- hcloud_floating_ip:
+ hetzner.hcloud.floating_ip:
name: "{{ hcloud_floating_ip_name }}"
type: ipv4
delete_protection: true
@@ -337,7 +351,7 @@
- floatingIP.hcloud_floating_ip.delete_protection is sameas true
- name: test Floating IP without delete protection set to be idempotent
- hcloud_floating_ip:
+ hetzner.hcloud.floating_ip:
name: "{{ hcloud_floating_ip_name }}"
type: ipv4
register: floatingIP
@@ -348,11 +362,11 @@
- floatingIP.hcloud_floating_ip.delete_protection is sameas true
- name: test delete Floating IP fails if it is protected
- hcloud_floating_ip:
+ hetzner.hcloud.floating_ip:
name: "{{ hcloud_floating_ip_name }}"
state: "absent"
register: result
- ignore_errors: yes
+ ignore_errors: true
- name: verify test delete floating ip
assert:
that:
@@ -360,7 +374,7 @@
- 'result.msg == "Floating IP deletion is protected"'
- name: test update Floating IP delete protection
- hcloud_floating_ip:
+ hetzner.hcloud.floating_ip:
name: "{{ hcloud_floating_ip_name }}"
type: ipv4
delete_protection: false
@@ -372,7 +386,7 @@
- floatingIP.hcloud_floating_ip.delete_protection is sameas false
- name: test delete floating ip
- hcloud_floating_ip:
+ hetzner.hcloud.floating_ip:
name: "{{ hcloud_floating_ip_name }}"
state: "absent"
register: result
@@ -382,7 +396,7 @@
- result is changed
- name: test create ipv6 floating ip
- hcloud_floating_ip:
+ hetzner.hcloud.floating_ip:
name: "{{ hcloud_floating_ip_name }}"
type: ipv6
home_location: "fsn1"
@@ -394,7 +408,7 @@
- result is changed
- name: test delete ipv6 floating ip
- hcloud_floating_ip:
+ hetzner.hcloud.floating_ip:
name: "{{ hcloud_floating_ip_name }}"
state: "absent"
register: result
@@ -404,7 +418,7 @@
- result is changed
- name: cleanup
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
state: absent
register: result
@@ -413,7 +427,7 @@
that:
- result is changed
- name: cleanup another server
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ main_server2.hcloud_server.name }}"
state: absent
register: result
@@ -423,7 +437,7 @@
- result is changed
- name: test create Floating IP with delete protection
- hcloud_floating_ip:
+ hetzner.hcloud.floating_ip:
name: "{{ hcloud_floating_ip_name }}"
type: ipv4
home_location: fsn1
@@ -436,11 +450,11 @@
- floatingIP.hcloud_floating_ip.delete_protection is sameas true
- name: test delete Floating IP fails if it is protected
- hcloud_floating_ip:
+ hetzner.hcloud.floating_ip:
name: "{{ hcloud_floating_ip_name }}"
state: "absent"
register: result
- ignore_errors: yes
+ ignore_errors: true
- name: verify test delete floating ip
assert:
that:
@@ -448,7 +462,7 @@
- 'result.msg == "Floating IP deletion is protected"'
- name: test update Floating IP delete protection
- hcloud_floating_ip:
+ hetzner.hcloud.floating_ip:
name: "{{ hcloud_floating_ip_name }}"
type: ipv4
delete_protection: false
@@ -460,7 +474,7 @@
- floatingIP.hcloud_floating_ip.delete_protection is sameas false
- name: test delete floating ip
- hcloud_floating_ip:
+ hetzner.hcloud.floating_ip:
name: "{{ hcloud_floating_ip_name }}"
state: "absent"
register: result
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip_info/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip_info/aliases
new file mode 100644
index 000000000..a6a90a6bf
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip_info/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+azp/group3
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip_info/defaults/main/common.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip_info/defaults/main/common.yml
new file mode 100644
index 000000000..e316b233c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip_info/defaults/main/common.yml
@@ -0,0 +1,12 @@
+#
+# 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('first') | join() }}"
+hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip_info/defaults/main/main.yml
index 15188e181..ffa5e4833 100644
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/defaults/main.yml
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip_info/defaults/main/main.yml
@@ -1,5 +1,4 @@
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
-hcloud_prefix: "tests"
-hcloud_ssh_key_name: "{{hcloud_prefix}}-f"
+hcloud_floating_ip_name: "{{ hcloud_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip_info/tasks/cleanup.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip_info/tasks/cleanup.yml
new file mode 100644
index 000000000..611d8e00c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip_info/tasks/cleanup.yml
@@ -0,0 +1,5 @@
+---
+- name: Cleanup test_floating_ip
+ hetzner.hcloud.floating_ip:
+ name: "{{ hcloud_floating_ip_name }}"
+ state: absent
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip_info/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip_info/tasks/main.yml
new file mode 100644
index 000000000..767fc465b
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip_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/ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip_info/tasks/prepare.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip_info/tasks/prepare.yml
new file mode 100644
index 000000000..26230ad54
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip_info/tasks/prepare.yml
@@ -0,0 +1,9 @@
+---
+- name: Create test_floating_ip
+ hetzner.hcloud.floating_ip:
+ name: "{{ hcloud_floating_ip_name }}"
+ home_location: fsn1
+ type: ipv4
+ labels:
+ key: value
+ register: test_floating_ip
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip_info/tasks/test.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip_info/tasks/test.yml
new file mode 100644
index 000000000..51fb56eb3
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/floating_ip_info/tasks/test.yml
@@ -0,0 +1,77 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: Gather hcloud_floating_ip_info
+ hetzner.hcloud.floating_ip_info:
+ register: result
+- name: Verify hcloud_floating_ip_info
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_floating_ip_info | list | count >= 1
+
+- name: Gather hcloud_floating_ip_info in check mode
+ hetzner.hcloud.floating_ip_info:
+ check_mode: true
+ register: result
+- name: Verify hcloud_floating_ip_info in check mode
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_floating_ip_info | list | count >= 1
+
+- name: Gather hcloud_floating_ip_info with correct id
+ hetzner.hcloud.floating_ip_info:
+ id: "{{ test_floating_ip.hcloud_floating_ip.id }}"
+ register: result
+- name: Verify hcloud_floating_ip_info with correct id
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_floating_ip_info | list | count == 1
+
+- name: Gather hcloud_floating_ip_info with wrong id
+ hetzner.hcloud.floating_ip_info:
+ id: "{{ test_floating_ip.hcloud_floating_ip.id }}4321"
+ ignore_errors: true
+ register: result
+- name: Verify hcloud_floating_ip_info with wrong id
+ ansible.builtin.assert:
+ that:
+ - result is failed
+
+- name: Gather hcloud_floating_ip_info with correct name
+ hetzner.hcloud.floating_ip_info:
+ name: "{{ hcloud_floating_ip_name }}"
+ register: result
+- name: Verify hcloud_floating_ip_info with correct name
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_floating_ip_info | list | count == 1
+
+- name: Gather hcloud_floating_ip_info with wrong name
+ hetzner.hcloud.floating_ip_info:
+ name: "{{ hcloud_floating_ip_name }}-invalid"
+ register: result
+- name: Verify hcloud_floating_ip_info with wrong name
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_floating_ip_info | list | count == 0
+
+- name: Gather hcloud_floating_ip_info with correct label selector
+ hetzner.hcloud.floating_ip_info:
+ label_selector: "key=value"
+ register: result
+- name: Verify hcloud_floating_ip_info with correct label selector
+ ansible.builtin.assert:
+ that:
+ - >
+ result.hcloud_floating_ip_info
+ | selectattr('name', 'equalto', hcloud_floating_ip_name)
+ | list | count == 1
+
+- name: Gather hcloud_floating_ip_info with wrong label selector
+ hetzner.hcloud.floating_ip_info:
+ label_selector: "key!=value"
+ register: result
+- name: Verify hcloud_floating_ip_info with wrong label selector
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_floating_ip_info | list | count == 0
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/defaults/main.yml
deleted file mode 100644
index 58312aec1..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/defaults/main.yml
+++ /dev/null
@@ -1,6 +0,0 @@
-# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
----
-hcloud_prefix: "tests"
-hcloud_certificate_name: "{{hcloud_prefix}}-integration"
-hcloud_dns_test_domain: "{{hcloud_prefix | truncate(19, False, 'ans')}}-{{100 | random }}.hc-certs.de"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/meta/main.yml
deleted file mode 100644
index e531064ca..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/meta/main.yml
+++ /dev/null
@@ -1,5 +0,0 @@
-dependencies:
- - setup_selfsigned_certificate
-collections:
- - community.general.ipfilter
- - hetzner.cloud
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/aliases
deleted file mode 100644
index 55ec821a4..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/hcloud
-shippable/hcloud/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/tasks/main.yml
deleted file mode 100644
index d7128db34..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/tasks/main.yml
+++ /dev/null
@@ -1,66 +0,0 @@
-# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
----
-
-- name: create certificate
- hcloud_certificate:
- name: "{{ hcloud_certificate_name }}"
- certificate: "{{ certificate_example_com }}"
- private_key: "{{ certificate_example_com_key }}"
- labels:
- key: value
- my-label: label
- register: certificate
-- name: verify create certificate
- assert:
- that:
- - certificate is changed
- - certificate.hcloud_certificate.name == "{{ hcloud_certificate_name }}"
- - certificate.hcloud_certificate.domain_names[0] == "www.example.com"
- - certificate.hcloud_certificate.labels.key == "value"
-
-- name: test gather hcloud certificate infos in check mode
- hcloud_certificate_info:
- register: hcloud_certificate
- check_mode: yes
-- name: verify test gather hcloud certificate infos in check mode
- assert:
- that:
- - hcloud_certificate.hcloud_certificate_info| list | count >= 1
-
-- name: test gather hcloud certificate infos
- hcloud_certificate_info:
- register: hcloud_certificate
- check_mode: yes
-- name: verify test gather hcloud certificate infos
- assert:
- that:
- - hcloud_certificate.hcloud_certificate_info| list | count >= 1
-
-- name: test gather hcloud certificate infos with correct label selector
- hcloud_certificate_info:
- label_selector: "key=value"
- register: hcloud_certificate
-- name: verify test gather hcloud certificate infos with correct label selector
- assert:
- that:
- - hcloud_certificate.hcloud_certificate_info|selectattr('name','equalto','{{ hcloud_certificate_name }}') | list | count == 1
-
-- name: test gather hcloud certificate infos with wrong label selector
- hcloud_certificate_info:
- label_selector: "key!=value"
- register: hcloud_certificate
-- name: verify test gather hcloud certificate infos with wrong label selector
- assert:
- that:
- - hcloud_certificate.hcloud_certificate_info | list | count == 0
-
-- name: absent certificate
- hcloud_certificate:
- id: "{{ certificate.hcloud_certificate.id }}"
- state: absent
- register: result
-- name: verify absent certificate
- assert:
- that:
- - result is success
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/aliases
deleted file mode 100644
index 55ec821a4..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/hcloud
-shippable/hcloud/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/meta/main.yml
deleted file mode 100644
index 407c9018a..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/meta/main.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-collections:
- - community.general.ipfilter
- - hetzner.cloud
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/tasks/main.yml
deleted file mode 100644
index 3d144ae47..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/tasks/main.yml
+++ /dev/null
@@ -1,39 +0,0 @@
-# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
----
-- name: test gather hcloud datacenter infos
- hcloud_datacenter_info:
- register: hcloud_datacenters
-
-- name: verify test gather hcloud datacenter infos
- assert:
- that:
- - hcloud_datacenters.hcloud_datacenter_info| list | count >= 5
-
-- name: test gather hcloud datacenter infos in check mode
- hcloud_datacenter_info:
- register: hcloud_datacenters
- check_mode: yes
-
-- name: verify test gather hcloud datacenter infos in check mode
- assert:
- that:
- - hcloud_datacenters.hcloud_datacenter_info| list | count >= 5
-
-- name: test gather hcloud datacenter infos with correct name
- hcloud_datacenter_info:
- name: "{{hcloud_datacenter_name}}"
- register: hcloud_datacenter
-- name: verify test gather hcloud datacenter with correct name
- assert:
- that:
- - hcloud_datacenter.hcloud_datacenter_info|selectattr('name','equalto','{{ hcloud_datacenter_name }}') |selectattr('location','equalto','{{ hcloud_location_name }}') | list | count == 1
-
-- name: test gather hcloud datacenter infos with correct id
- hcloud_datacenter_info:
- id: "{{hcloud_datacenter_id}}"
- register: hcloud_datacenter
-- name: verify test gather hcloud datacenter with correct id
- assert:
- that:
- - hcloud_datacenter.hcloud_datacenter_info|selectattr('name','equalto','{{ hcloud_datacenter_name }}') | list | count == 1
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_firewall/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_firewall/aliases
deleted file mode 100644
index 55ec821a4..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_firewall/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/hcloud
-shippable/hcloud/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_firewall/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_firewall/meta/main.yml
deleted file mode 100644
index 407c9018a..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_firewall/meta/main.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-collections:
- - community.general.ipfilter
- - hetzner.cloud
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_firewall/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_firewall/tasks/main.yml
deleted file mode 100644
index f54d351b2..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_firewall/tasks/main.yml
+++ /dev/null
@@ -1,210 +0,0 @@
-# Copyright: (c) 2020, Hetzner Cloud GmbH <info@hetzner-cloud.de>
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
----
-- name: setup firewall to be absent
- hcloud_firewall:
- name: "{{ hcloud_firewall_name }}"
- state: absent
-
-- name: test missing required parameters on create firewall
- hcloud_firewall:
- register: result
- ignore_errors: yes
-- name: verify fail test missing required parameters on create firewall
- assert:
- that:
- - result is failed
- - 'result.msg == "one of the following is required: id, name"'
-
-- name: test create firewall with check mode
- hcloud_firewall:
- name: "{{ hcloud_firewall_name }}"
- register: result
- check_mode: yes
-- name: test create firewall with check mode
- assert:
- that:
- - result is changed
-
-- name: test create firewall
- hcloud_firewall:
- name: "{{ hcloud_firewall_name }}"
- rules:
- - direction: in
- protocol: icmp
- source_ips:
- - 0.0.0.0/0
- - ::/0
- description: "allow icmp in"
- labels:
- key: value
- my-label: label
- register: firewall
-- name: verify create firewall
- assert:
- that:
- - firewall is changed
- - firewall.hcloud_firewall.name == "{{ hcloud_firewall_name }}"
- - firewall.hcloud_firewall.rules | list | count == 1
- - firewall.hcloud_firewall.rules | selectattr('direction','equalto','in') | list | count == 1
- - firewall.hcloud_firewall.rules | selectattr('protocol','equalto','icmp') | list | count == 1
- - firewall.hcloud_firewall.rules | selectattr('description', 'equalto', 'allow icmp in') | list | count == 1
-
-- name: test create firewall idempotence
- hcloud_firewall:
- name: "{{ hcloud_firewall_name }}"
- rules:
- - direction: in
- protocol: icmp
- source_ips:
- - 0.0.0.0/0
- - ::/0
- description: "allow icmp in"
- labels:
- key: value
- my-label: label
- register: result
-- name: verify create firewall idempotence
- assert:
- that:
- - result is not changed
-
-- name: test update firewall rules
- hcloud_firewall:
- name: "{{ hcloud_firewall_name }}"
- rules:
- - direction: in
- protocol: icmp
- source_ips:
- - 0.0.0.0/0
- - ::/0
- - direction: in
- protocol: tcp
- port: 80
- source_ips:
- - 0.0.0.0/0
- - ::/0
- - direction: out
- protocol: tcp
- port: 80
- destination_ips:
- - 0.0.0.0/0
- - ::/0
- description: allow tcp out
- labels:
- key: value
- my-label: label
- register: firewall
-- name: verify update firewall rules
- assert:
- that:
- - firewall is changed
- - firewall.hcloud_firewall.name == "{{ hcloud_firewall_name }}"
- - firewall.hcloud_firewall.rules | list | count == 3
- - firewall.hcloud_firewall.rules | selectattr('direction','equalto','in') | list | count == 2
- - firewall.hcloud_firewall.rules | selectattr('direction','equalto','out') | list | count == 1
- - firewall.hcloud_firewall.rules | selectattr('protocol','equalto','icmp') | list | count == 1
- - firewall.hcloud_firewall.rules | selectattr('protocol','equalto','tcp') | list | count == 2
- - firewall.hcloud_firewall.rules | selectattr('port','equalto','80') | list | count == 2
- - firewall.hcloud_firewall.rules | selectattr('description', 'equalto', 'allow tcp out') | list | count == 1
-
-- name: test update firewall rules idempotence
- hcloud_firewall:
- name: "{{ hcloud_firewall_name }}"
- rules:
- - direction: in
- protocol: icmp
- source_ips:
- - 0.0.0.0/0
- - ::/0
- - direction: in
- protocol: tcp
- port: 80
- source_ips:
- - 0.0.0.0/0
- - ::/0
- - direction: out
- protocol: tcp
- port: 80
- destination_ips:
- - 0.0.0.0/0
- - ::/0
- description: allow tcp out
- labels:
- key: value
- my-label: label
- register: result
-- name: verify update firewall rules idempotence
- assert:
- that:
- - result is not changed
-
-- name: test update firewall with check mode
- hcloud_firewall:
- id: "{{ firewall.hcloud_firewall.id }}"
- name: "changed-{{ hcloud_firewall_name }}"
- register: result
- check_mode: yes
-- name: test create firewall with check mode
- assert:
- that:
- - result is changed
-
-- name: test update firewall
- hcloud_firewall:
- id: "{{ firewall.hcloud_firewall.id }}"
- name: "changed-{{ hcloud_firewall_name }}"
- labels:
- key: value
- register: result
-- name: test update firewall
- assert:
- that:
- - result is changed
- - result.hcloud_firewall.name == "changed-{{ hcloud_firewall_name }}"
-
-- name: test update firewall with same labels
- hcloud_firewall:
- id: "{{ firewall.hcloud_firewall.id }}"
- name: "changed-{{ hcloud_firewall_name }}"
- labels:
- key: value
- register: result
-- name: test update firewall with same labels
- assert:
- that:
- - result is not changed
-
-- name: test update firewall with other labels
- hcloud_firewall:
- id: "{{ firewall.hcloud_firewall.id }}"
- name: "changed-{{ hcloud_firewall_name }}"
- labels:
- key: value
- test: "val123"
- register: result
-- name: test update firewall with other labels
- assert:
- that:
- - result is changed
-
-- name: test rename firewall
- hcloud_firewall:
- id: "{{ firewall.hcloud_firewall.id }}"
- name: "{{ hcloud_firewall_name }}"
- register: result
-- name: test rename firewall
- assert:
- that:
- - result is changed
- - result.hcloud_firewall.name == "{{ hcloud_firewall_name }}"
-
-- name: absent firewall
- hcloud_firewall:
- id: "{{ firewall.hcloud_firewall.id }}"
- state: absent
- register: result
-- name: verify absent server
- assert:
- that:
- - result is success
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/aliases
deleted file mode 100644
index 55ec821a4..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/hcloud
-shippable/hcloud/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/defaults/main.yml
deleted file mode 100644
index ebd5ccc38..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/defaults/main.yml
+++ /dev/null
@@ -1,6 +0,0 @@
-# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
----
-hcloud_prefix: "tests"
-hcloud_floating_ip_name: "{{hcloud_prefix}}-i"
-hcloud_server_name: "{{ hcloud_prefix | truncate(45, True, '', 0) }}-fip-t"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/meta/main.yml
deleted file mode 100644
index 407c9018a..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/meta/main.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-collections:
- - community.general.ipfilter
- - hetzner.cloud
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/aliases
deleted file mode 100644
index 55ec821a4..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/hcloud
-shippable/hcloud/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/meta/main.yml
deleted file mode 100644
index 407c9018a..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/meta/main.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-collections:
- - community.general.ipfilter
- - hetzner.cloud
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/tasks/main.yml
deleted file mode 100644
index 9ca1c2a4a..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/tasks/main.yml
+++ /dev/null
@@ -1,87 +0,0 @@
-# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
----
-- name: setup ensure floating ip is absent
- hcloud_floating_ip:
- name: "{{ hcloud_floating_ip_name }}"
- state: absent
-
-- name: setup floating ip
- hcloud_floating_ip:
- name: "{{ hcloud_floating_ip_name }}"
- home_location: "fsn1"
- type: ipv4
- labels:
- key: value
- register: test_floating_ip
-
-- name: verify setup floating ip
- assert:
- that:
- - test_floating_ip is changed
-
-- name: test gather hcloud floating ip infos
- hcloud_floating_ip_info:
- register: hcloud_floating_ips
-- name: verify test gather hcloud floating ip infos
- assert:
- that:
- - hcloud_floating_ips.hcloud_floating_ip_info| list | count >= 1
-
-- name: test gather hcloud floating ip infos in check mode
- hcloud_floating_ip_info:
- check_mode: yes
- register: hcloud_floating_ips
-
-- name: verify test gather hcloud floating ip infos in check mode
- assert:
- that:
- - hcloud_floating_ips.hcloud_floating_ip_info| list | count >= 1
-
-
-- name: test gather hcloud floating ip infos with correct label selector
- hcloud_floating_ip_info:
- label_selector: "key=value"
- register: hcloud_floating_ips
-- name: verify test gather hcloud floating ip with correct label selector
- assert:
- that:
- - hcloud_floating_ips.hcloud_floating_ip_info|selectattr('name','equalto','{{ test_floating_ip.hcloud_floating_ip.name }}') | list | count == 1
-
-- name: test gather hcloud floating ip infos with wrong label selector
- hcloud_floating_ip_info:
- label_selector: "key!=value"
- register: hcloud_floating_ips
-- name: verify test gather hcloud floating ip with wrong label selector
- assert:
- that:
- - hcloud_floating_ips.hcloud_floating_ip_info | list | count == 0
-
-- name: test gather hcloud floating ip infos with correct id
- hcloud_floating_ip_info:
- id: "{{test_floating_ip.hcloud_floating_ip.id}}"
- register: hcloud_floating_ips
-- name: verify test gather hcloud floating ip with correct id
- assert:
- that:
- - hcloud_floating_ips.hcloud_floating_ip_info|selectattr('name','equalto','{{ test_floating_ip.hcloud_floating_ip.name }}') | list | count == 1
-
-- name: test gather hcloud floating ip infos with wrong id
- hcloud_floating_ip_info:
- id: "{{test_floating_ip.hcloud_floating_ip.id}}1"
- register: result
- ignore_errors: yes
-- name: verify test gather hcloud floating ip with wrong id
- assert:
- that:
- - result is failed
-
-- name: cleanup
- hcloud_floating_ip:
- id: "{{ test_floating_ip.hcloud_floating_ip.id }}"
- state: absent
- register: result
-- name: verify cleanup
- assert:
- that:
- - result is success
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/aliases
deleted file mode 100644
index 55ec821a4..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/hcloud
-shippable/hcloud/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/defaults/main.yml
deleted file mode 100644
index 7c25d171d..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/defaults/main.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
----
-hcloud_prefix: "tests"
-hcloud_test_image_name: "always-there-snapshot"
-hcloud_test_image_id: 10164049
-hcloud_test_image_name_os: "ubuntu-22.04"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/meta/main.yml
deleted file mode 100644
index 407c9018a..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/meta/main.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-collections:
- - community.general.ipfilter
- - hetzner.cloud
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/tasks/main.yml
deleted file mode 100644
index 16ed44a28..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/tasks/main.yml
+++ /dev/null
@@ -1,93 +0,0 @@
-# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
----
-- name: test gather hcloud image infos with type system
- hcloud_image_info:
- register: hcloud_images
-- name: verify test gather hcloud image infos in check mode
- assert:
- that:
- - hcloud_images.hcloud_image_info| list | count > 2
-
-- name: test gather hcloud image infos in check mode
- hcloud_image_info:
- check_mode: yes
- register: hcloud_images
-
-- name: verify test gather hcloud image infos in check mode
- assert:
- that:
- - hcloud_images.hcloud_image_info| list | count > 2
-
-
-- name: test gather hcloud image infos with correct label selector
- hcloud_image_info:
- label_selector: "key=value"
- type: snapshot
- register: hcloud_images
-- name: verify test gather hcloud image with correct label selector
- assert:
- that:
- - hcloud_images.hcloud_image_info|selectattr('description','equalto','{{ hcloud_test_image_name }}') | list | count == 1
-
-- name: test gather hcloud image infos with wrong label selector
- hcloud_image_info:
- label_selector: "key!=value"
- type: snapshot
- register: hcloud_images
-- name: verify test gather hcloud image with wrong label selector
- assert:
- that:
- - hcloud_images.hcloud_image_info | list | count == 0
-
-- name: test gather hcloud image infos with correct id
- hcloud_image_info:
- id: "{{hcloud_test_image_id}}"
- type: snapshot
- register: hcloud_images
-- name: verify test gather hcloud image with correct id
- assert:
- that:
- - hcloud_images.hcloud_image_info|selectattr('description','equalto','{{ hcloud_test_image_name }}') | list | count == 1
-
-- name: test gather hcloud image infos with wrong id
- hcloud_image_info:
- id: "{{hcloud_test_image_id}}1"
- type: snapshot
- ignore_errors: yes
- register: result
-- name: verify test gather hcloud image with wrong id
- assert:
- that:
- - result is failed
-
-- name: test gather hcloud image infos with name
- hcloud_image_info:
- name: "{{ hcloud_test_image_name_os }}"
- register: hcloud_images
-- name: verify test gather hcloud image infos with name
- assert:
- that:
- - hcloud_images.hcloud_image_info | list | count == 1
- - hcloud_images.hcloud_image_info[0].architecture == "x86"
-
-- name: test gather hcloud image infos with name and architecture
- hcloud_image_info:
- name: "{{ hcloud_test_image_name_os }}"
- architecture: arm
- register: hcloud_images
-- name: verify test gather hcloud image infos with name
- assert:
- that:
- - hcloud_images.hcloud_image_info | list | count == 1
- - hcloud_images.hcloud_image_info[0].architecture == "arm"
-
-- name: test gather hcloud image infos with architecture
- hcloud_image_info:
- architecture: arm
- register: hcloud_images
-- name: verify test gather hcloud image infos with name
- assert:
- that:
- - hcloud_images.hcloud_image_info | selectattr('architecture','equalto','x86') | list | count == 0
- - hcloud_images.hcloud_image_info | selectattr('architecture','equalto','arm') | list | count > 2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/aliases
deleted file mode 100644
index 18dc30b6c..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/hcloud
-shippable/hcloud/group1
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/meta/main.yml
deleted file mode 100644
index 407c9018a..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/meta/main.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-collections:
- - community.general.ipfilter
- - hetzner.cloud
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/tasks/main.yml
deleted file mode 100644
index a25e550d0..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/tasks/main.yml
+++ /dev/null
@@ -1,247 +0,0 @@
-# Copyright: (c) 2020, Hetzner Cloud GmbH <info@hetzner-cloud.de>
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
----
-- name: setup
- hcloud_load_balancer:
- name: "{{ hcloud_load_balancer_name }}"
- state: absent
- register: result
-- name: verify setup
- assert:
- that:
- - result is success
-- name: test missing required parameters on create Load Balancer
- hcloud_load_balancer:
- name: "{{ hcloud_load_balancer_name }}"
- register: result
- ignore_errors: yes
-- name: verify fail test missing required parameters on create Load Balancer
- assert:
- that:
- - result is failed
- - 'result.msg == "missing required arguments: load_balancer_type"'
-
-- name: test create Load Balancer with check mode
- hcloud_load_balancer:
- name: "{{ hcloud_load_balancer_name }}"
- load_balancer_type: lb11
- network_zone: eu-central
- state: present
- register: result
- check_mode: yes
-- name: test create Load Balancer with check mode
- assert:
- that:
- - result is changed
-
-- name: test create Load Balancer
- hcloud_load_balancer:
- name: "{{ hcloud_load_balancer_name}}"
- load_balancer_type: lb11
- network_zone: eu-central
- state: present
- register: main_load_balancer
-- name: verify create Load Balancer
- assert:
- that:
- - main_load_balancer is changed
- - main_load_balancer.hcloud_load_balancer.name == "{{ hcloud_load_balancer_name }}"
- - main_load_balancer.hcloud_load_balancer.load_balancer_type == "lb11"
-
-- name: test create Load Balancer idempotence
- hcloud_load_balancer:
- name: "{{ hcloud_load_balancer_name }}"
- load_balancer_type: lb11
- network_zone: eu-central
- state: present
- register: result
-- name: verify create Load Balancer idempotence
- assert:
- that:
- - result is not changed
-
-- name: test change Load Balancer type
- hcloud_load_balancer:
- name: "{{ hcloud_load_balancer_name }}"
- load_balancer_type: lb21
- state: present
- register: result_after_test
- ignore_errors: true
-- name: verify change Load Balancer type
- assert:
- that:
- - result_after_test is changed
- - result_after_test.hcloud_load_balancer.load_balancer_type == "lb21"
-
-- name: test Load Balancer without type set to be idempotent
- hcloud_load_balancer:
- name: "{{hcloud_load_balancer_name}}"
- register: result_after_test
-- name: verify test Load Balancer without type set to be idempotent
- assert:
- that:
- - result_after_test is not changed
- - result_after_test.hcloud_load_balancer.load_balancer_type == "lb21"
-
-- name: test update Load Balancer protection
- hcloud_load_balancer:
- name: "{{ hcloud_load_balancer_name }}"
- delete_protection: true
- state: present
- register: result_after_test
- ignore_errors: true
-- name: verify update Load Balancer protection
- assert:
- that:
- - result_after_test is changed
- - result_after_test.hcloud_load_balancer.delete_protection is sameas true
-
-- name: test Load Balancer without protection set to be idempotent
- hcloud_load_balancer:
- name: "{{hcloud_load_balancer_name}}"
- register: result_after_test
-- name: verify test Load Balancer without protection set to be idempotent
- assert:
- that:
- - result_after_test is not changed
- - result_after_test.hcloud_load_balancer.delete_protection is sameas true
-
-- name: test delete Load Balancer fails if it is protected
- hcloud_load_balancer:
- name: "{{hcloud_load_balancer_name}}"
- state: absent
- ignore_errors: yes
- register: result
-- name: verify delete Load Balancer fails if it is protected
- assert:
- that:
- - result is failed
- - 'result.msg == "load balancer deletion is protected"'
-
-- name: test remove Load Balancer protection
- hcloud_load_balancer:
- name: "{{ hcloud_load_balancer_name }}"
- delete_protection: false
- state: present
- register: result_after_test
- ignore_errors: true
-- name: verify remove Load Balancer protection
- assert:
- that:
- - result_after_test is changed
- - result_after_test.hcloud_load_balancer.delete_protection is sameas false
-
-- name: absent Load Balancer
- hcloud_load_balancer:
- name: "{{ hcloud_load_balancer_name }}"
- state: absent
- register: result
-- name: verify absent Load Balancer
- assert:
- that:
- - result is success
-
-- name: test create Load Balancer with labels
- hcloud_load_balancer:
- name: "{{ hcloud_load_balancer_name}}"
- load_balancer_type: lb11
- network_zone: eu-central
- labels:
- key: value
- mylabel: "val123"
- state: present
- register: main_load_balancer
-- name: verify create Load Balancer with labels
- assert:
- that:
- - main_load_balancer is changed
- - main_load_balancer.hcloud_load_balancer.labels.key == "value"
- - main_load_balancer.hcloud_load_balancer.labels.mylabel == "val123"
-
-- name: test update Load Balancer with labels
- hcloud_load_balancer:
- name: "{{ hcloud_load_balancer_name}}"
- load_balancer_type: lb11
- network_zone: eu-central
- labels:
- key: other
- mylabel: "val123"
- state: present
- register: main_load_balancer
-- name: verify update Load Balancer with labels
- assert:
- that:
- - main_load_balancer is changed
- - main_load_balancer.hcloud_load_balancer.labels.key == "other"
- - main_load_balancer.hcloud_load_balancer.labels.mylabel == "val123"
-
-- name: test update Load Balancer with labels in other order
- hcloud_load_balancer:
- name: "{{ hcloud_load_balancer_name}}"
- load_balancer_type: lb11
- network_zone: eu-central
- labels:
- mylabel: "val123"
- key: other
- state: present
- register: main_load_balancer
-- name: verify update Load Balancer with labels in other order
- assert:
- that:
- - main_load_balancer is not changed
-
-- name: cleanup with labels
- hcloud_load_balancer:
- name: "{{ hcloud_load_balancer_name }}"
- state: absent
- register: result
-- name: verify cleanup
- assert:
- that:
- - result is success
-
-- name: test create Load Balancer with delete protection
- hcloud_load_balancer:
- name: "{{ hcloud_load_balancer_name }}"
- load_balancer_type: lb11
- network_zone: eu-central
- delete_protection: true
- register: main_load_balancer
-- name: verify create Load Balancer with delete protection
- assert:
- that:
- - main_load_balancer is changed
- - main_load_balancer.hcloud_load_balancer.delete_protection is sameas true
-
-- name: test delete Load Balancer fails if it is protected
- hcloud_load_balancer:
- name: "{{ hcloud_load_balancer_name }}"
- state: "absent"
- register: result
- ignore_errors: yes
-- name: verify test delete Load Balancer
- assert:
- that:
- - result is failed
- - 'result.msg == "load balancer deletion is protected"'
-
-- name: test update Load Balancer delete protection
- hcloud_load_balancer:
- name: "{{ hcloud_load_balancer_name }}"
- delete_protection: false
- register: main_load_balancer
-- name: verify update Load Balancer delete protection
- assert:
- that:
- - main_load_balancer is changed
- - main_load_balancer.hcloud_load_balancer.delete_protection is sameas false
-
-- name: test delete Load Balancer
- hcloud_load_balancer:
- name: "{{ hcloud_load_balancer_name }}"
- state: "absent"
- register: result
-- name: verify test delete Load Balancer
- assert:
- that:
- - result is changed
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/aliases
deleted file mode 100644
index 18dc30b6c..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/hcloud
-shippable/hcloud/group1
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/defaults/main.yml
deleted file mode 100644
index 326973a78..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/defaults/main.yml
+++ /dev/null
@@ -1,6 +0,0 @@
-# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
----
-hcloud_prefix: "tests"
-hcloud_load_balancer_name: "{{hcloud_prefix}}-i"
-hcloud_server_name: "{{ hcloud_prefix | truncate(45, True, '', 0) }}-lb-i"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/meta/main.yml
deleted file mode 100644
index 407c9018a..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/meta/main.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-collections:
- - community.general.ipfilter
- - hetzner.cloud
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/tasks/main.yml
deleted file mode 100644
index 9e6528858..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/tasks/main.yml
+++ /dev/null
@@ -1,128 +0,0 @@
-# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
----
-- name: setup ensure Load Balancer is absent
- hcloud_load_balancer:
- name: "{{ hcloud_load_balancer_name }}"
- state: absent
-- name: setup server
- hcloud_server:
- name: "{{hcloud_server_name}}"
- server_type: cx11
- image: ubuntu-20.04
- state: started
- register: server
-- name: verify setup server
- assert:
- that:
- - server is success
-- name: setup Load Balancer
- hcloud_load_balancer:
- name: "{{ hcloud_load_balancer_name }}"
- load_balancer_type: lb11
- network_zone: eu-central
- labels:
- key: value
- register: test_load_balancer
-
-- name: verify setup Load Balancer
- assert:
- that:
- - test_load_balancer is changed
-
-- name: test create load_balancer target
- hcloud_load_balancer_target:
- type: "server"
- load_balancer: "{{hcloud_load_balancer_name}}"
- server: "{{hcloud_server_name}}"
- state: present
- register: load_balancer_target
-- name: verify create load_balancer target
- assert:
- that:
- - load_balancer_target is success
-- name: test create load_balancer service
- hcloud_load_balancer_service:
- load_balancer: "{{hcloud_load_balancer_name}}"
- protocol: "http"
- listen_port: 80
- state: present
- register: load_balancer_service
-- name: verify create load_balancer service
- assert:
- that:
- - load_balancer_service is success
-
-- name: test gather hcloud Load Balancer infos
- hcloud_load_balancer_info:
- id: "{{test_load_balancer.hcloud_load_balancer.id}}"
- register: hcloud_load_balancers
-- name: verify test gather hcloud Load Balancer infos
- assert:
- that:
- - hcloud_load_balancers.hcloud_load_balancer_info| list | count >= 1
- - hcloud_load_balancers.hcloud_load_balancer_info[0].targets | list | count == 1
- - hcloud_load_balancers.hcloud_load_balancer_info[0].targets | selectattr('type','equalto','server') | list | count == 1
- - hcloud_load_balancers.hcloud_load_balancer_info[0].targets | selectattr('server','equalto','{{ hcloud_server_name }}') | list | count == 1
- - hcloud_load_balancers.hcloud_load_balancer_info[0].services | list | count == 1
- - hcloud_load_balancers.hcloud_load_balancer_info[0].services | selectattr('protocol','equalto','http') | list | count == 1
- - hcloud_load_balancers.hcloud_load_balancer_info[0].services | selectattr('listen_port','equalto',80) | list | count == 1
- - hcloud_load_balancers.hcloud_load_balancer_info[0].services | selectattr('destination_port','equalto',80) | list | count == 1
-
-- name: test gather hcloud Load Balancer infos in check mode
- hcloud_load_balancer_info:
- check_mode: yes
- register: hcloud_load_balancers
-
-- name: verify test gather hcloud Load Balancer infos in check mode
- assert:
- that:
- - hcloud_load_balancers.hcloud_load_balancer_info| list | count >= 1
-
-
-- name: test gather hcloud Load Balancer infos with correct label selector
- hcloud_load_balancer_info:
- label_selector: "key=value"
- register: hcloud_load_balancers
-- name: verify test gather hcloud Load Balancer with correct label selector
- assert:
- that:
- - hcloud_load_balancers.hcloud_load_balancer_info|selectattr('name','equalto','{{ test_load_balancer.hcloud_load_balancer.name }}') | list | count == 1
-
-- name: test gather hcloud Load Balancer infos with wrong label selector
- hcloud_load_balancer_info:
- label_selector: "key!=value"
- register: hcloud_load_balancers
-- name: verify test gather hcloud Load Balancer with wrong label selector
- assert:
- that:
- - hcloud_load_balancers.hcloud_load_balancer_info | list | count == 0
-
-- name: test gather hcloud Load Balancer infos with correct id
- hcloud_load_balancer_info:
- id: "{{test_load_balancer.hcloud_load_balancer.id}}"
- register: hcloud_load_balancers
-- name: verify test gather hcloud Load Balancer with correct id
- assert:
- that:
- - hcloud_load_balancers.hcloud_load_balancer_info|selectattr('name','equalto','{{ test_load_balancer.hcloud_load_balancer.name }}') | list | count == 1
-
-- name: test gather hcloud Load Balancer infos with wrong id
- hcloud_load_balancer_info:
- id: "{{test_load_balancer.hcloud_load_balancer.id}}1"
- register: result
- ignore_errors: yes
-- name: verify test gather hcloud Load Balancer with wrong id
- assert:
- that:
- - result is failed
-
-- name: cleanup
- hcloud_load_balancer:
- id: "{{ test_load_balancer.hcloud_load_balancer.id }}"
- state: absent
- register: result
-- name: verify cleanup
- assert:
- that:
- - result is success
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/aliases
deleted file mode 100644
index 18dc30b6c..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/hcloud
-shippable/hcloud/group1
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/defaults/main.yml
deleted file mode 100644
index 6abf9ceec..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/defaults/main.yml
+++ /dev/null
@@ -1,6 +0,0 @@
-# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
----
-hcloud_prefix: "tests"
-hcloud_network_name: "{{hcloud_prefix}}-lb-n"
-hcloud_load_balancer_name: "{{hcloud_prefix}}-lb-n"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/meta/main.yml
deleted file mode 100644
index 407c9018a..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/meta/main.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-collections:
- - community.general.ipfilter
- - hetzner.cloud
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/aliases
deleted file mode 100644
index 18dc30b6c..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/hcloud
-shippable/hcloud/group1
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/meta/main.yml
deleted file mode 100644
index 407c9018a..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/meta/main.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-collections:
- - community.general.ipfilter
- - hetzner.cloud
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/aliases
deleted file mode 100644
index 18dc30b6c..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/hcloud
-shippable/hcloud/group1
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/defaults/main.yml
deleted file mode 100644
index 180133fde..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/defaults/main.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
----
-hcloud_prefix: "tests"
-hcloud_server_name: "{{ hcloud_prefix | truncate(45, True, '', 0) }}-lb-t"
-hcloud_load_balancer_name: "{{hcloud_prefix}}-lb-target"
-hcloud_testing_ip: "176.9.59.39"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/meta/main.yml
deleted file mode 100644
index 407c9018a..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/meta/main.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-collections:
- - community.general.ipfilter
- - hetzner.cloud
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_type_info/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_type_info/aliases
deleted file mode 100644
index 55ec821a4..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_type_info/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/hcloud
-shippable/hcloud/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_type_info/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_type_info/meta/main.yml
deleted file mode 100644
index 407c9018a..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_type_info/meta/main.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-collections:
- - community.general.ipfilter
- - hetzner.cloud
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_type_info/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_type_info/tasks/main.yml
deleted file mode 100644
index bcd805a83..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_type_info/tasks/main.yml
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright: (c) 2020, Hetzner Cloud GmbH <info@hetzner-cloud.de>
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
----
-- name: test gather hcloud Load Balancer type infos
- hcloud_load_balancer_type_info:
- register: hcloud_load_balancer_types
-- name: verify test gather hcloud Load Balancer type infos
- assert:
- that:
- - hcloud_load_balancer_types.hcloud_load_balancer_type_info| list | count >= 1
-
-- name: test gather hcloud Load Balancer type infos in check mode
- hcloud_load_balancer_type_info:
- check_mode: yes
- register: hcloud_load_balancer_types
-
-- name: verify test gather hcloud Load Balancer type infos in check mode
- assert:
- that:
- - hcloud_load_balancer_types.hcloud_load_balancer_type_info| list | count >= 1
-
-- name: test gather hcloud Load Balancer type infos with name
- hcloud_load_balancer_type_info:
- name: "{{hcloud_load_balancer_type_name}}"
- register: hcloud_load_balancer_types
-- name: verify test gather hcloud Load Balancer type with name
- assert:
- that:
- - hcloud_load_balancer_types.hcloud_load_balancer_type_info|selectattr('name','equalto','{{ hcloud_load_balancer_type_name }}') | list | count == 1
-
-- name: test gather hcloud Load Balancer type infos with correct id
- hcloud_load_balancer_type_info:
- id: "{{hcloud_load_balancer_type_id}}"
- register: hcloud_load_balancer_types
-- name: verify test gather hcloud Load Balancer type with correct id
- assert:
- that:
- - hcloud_load_balancer_types.hcloud_load_balancer_type_info|selectattr('name','equalto','{{ hcloud_load_balancer_type_name }}') | list | count == 1
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/aliases
deleted file mode 100644
index 55ec821a4..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/hcloud
-shippable/hcloud/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/meta/main.yml
deleted file mode 100644
index 407c9018a..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/meta/main.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-collections:
- - community.general.ipfilter
- - hetzner.cloud
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/tasks/main.yml
deleted file mode 100644
index 99d5880ab..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/tasks/main.yml
+++ /dev/null
@@ -1,57 +0,0 @@
-# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
----
-- name: test gather hcloud location infos
- hcloud_location_info:
- register: hcloud_location
-
-- name: verify test gather hcloud location infos
- assert:
- that:
- - hcloud_location.hcloud_location_info | list | count >= 5
-
-- name: test gather hcloud location infos in check mode
- hcloud_location_info:
- check_mode: yes
- register: hcloud_location
-
-- name: verify test gather hcloud location infos in check mode
- assert:
- that:
- - hcloud_location.hcloud_location_info | list | count >= 5
-
-- name: test gather hcloud location infos with correct name
- hcloud_location_info:
- name: "{{hcloud_location_name}}"
- register: hcloud_location
-- name: verify test gather hcloud location with correct name
- assert:
- that:
- - hcloud_location.hcloud_location_info|selectattr('name','equalto','{{ hcloud_location_name }}') | list | count == 1
-
-- name: test gather hcloud location infos with wrong name
- hcloud_location_info:
- name: "{{hcloud_location_name}}1"
- register: hcloud_location
-- name: verify test gather hcloud location with wrong name
- assert:
- that:
- - hcloud_location.hcloud_location_info | list | count == 0
-
-- name: test gather hcloud location infos with correct id
- hcloud_location_info:
- id: "{{hcloud_location_id}}"
- register: hcloud_location
-- name: verify test gather hcloud location with correct id
- assert:
- that:
- - hcloud_location.hcloud_location_info|selectattr('name','equalto','{{ hcloud_location_name }}') | list | count == 1
-
-- name: test gather hcloud location infos with wrong id
- hcloud_location_info:
- name: "4711"
- register: hcloud_location
-- name: verify test gather hcloud location with wrong id
- assert:
- that:
- - hcloud_location.hcloud_location_info | list | count == 0
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/aliases
deleted file mode 100644
index 4b3a9b36f..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/aliases
+++ /dev/null
@@ -1,3 +0,0 @@
-cloud/hcloud
-shippable/hcloud/group1
-disabled
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/meta/main.yml
deleted file mode 100644
index 407c9018a..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/meta/main.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-collections:
- - community.general.ipfilter
- - hetzner.cloud
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/aliases
deleted file mode 100644
index 18dc30b6c..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/hcloud
-shippable/hcloud/group1
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/defaults/main.yml
deleted file mode 100644
index f8a5279fb..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/defaults/main.yml
+++ /dev/null
@@ -1,5 +0,0 @@
-# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
----
-hcloud_prefix: "tests"
-hcloud_network_name: "{{hcloud_prefix}}-integration"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/meta/main.yml
deleted file mode 100644
index 407c9018a..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/meta/main.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-collections:
- - community.general.ipfilter
- - hetzner.cloud
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/tasks/main.yml
deleted file mode 100644
index e7924a8d0..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/tasks/main.yml
+++ /dev/null
@@ -1,117 +0,0 @@
-# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
----
-
-- name: setup ensure network is absent
- hcloud_network:
- name: "{{ hcloud_network_name }}"
- state: absent
- register: result
-
-- name: create network
- hcloud_network:
- name: "{{ hcloud_network_name }}"
- ip_range: "10.0.0.0/16"
- labels:
- key: value
- register: main_network
-- name: verify create network
- assert:
- that:
- - main_network is changed
- - main_network.hcloud_network.name == "{{ hcloud_network_name }}"
- - main_network.hcloud_network.ip_range == "10.0.0.0/16"
-- name: create subnetwork
- hcloud_subnetwork:
- network: "{{ hcloud_network_name }}"
- type: server
- network_zone: eu-central
- ip_range: "10.0.1.0/24"
- register: main_subnetwork
-- name: verify create subnetwork
- assert:
- that:
- - main_subnetwork is changed
- - main_subnetwork.hcloud_subnetwork.network == "{{ hcloud_network_name }}"
-- name: create route
- hcloud_route:
- network: "{{ hcloud_network_name }}"
- destination: "10.0.3.0/24"
- gateway: "10.0.2.1"
- register: main_route
-- name: verify create route
- assert:
- that:
- - main_route is changed
- - main_route.hcloud_route.network == "{{ hcloud_network_name }}"
-
-- name: test gather hcloud network info in check mode
- hcloud_network_info:
- check_mode: yes
- register: hcloud_network
-- name: verify test gather hcloud network info in check mode
- assert:
- that:
- - hcloud_network.hcloud_network_info | selectattr('name','equalto','{{ hcloud_network_name }}') | list | count >= 1
-
-
-- name: test gather hcloud network info with correct label selector
- hcloud_network_info:
- label_selector: "key=value"
- register: hcloud_network
-- name: verify test gather hcloud network with correct label selector
- assert:
- that:
- - hcloud_network.hcloud_network_info | selectattr('name','equalto','{{ hcloud_network_name }}') | list | count >= 1
-
-- name: test gather hcloud network info with wrong label selector
- hcloud_network_info:
- label_selector: "key!=value"
- register: hcloud_network
-- name: verify test gather hcloud network with wrong label selector
- assert:
- that:
- - hcloud_network.hcloud_network_info | list | count == 0
-
-- name: test gather hcloud network info with correct name
- hcloud_network_info:
- name: "{{hcloud_network_name}}"
- register: hcloud_network
-- name: verify test gather hcloud network with correct name
- assert:
- that:
- - hcloud_network.hcloud_network_info | selectattr('name','equalto','{{ hcloud_network_name }}') | list | count == 1
- - hcloud_network.hcloud_network_info[0].subnetworks | list | count >= 1
- - hcloud_network.hcloud_network_info[0].routes | list | count >= 1
-
-- name: test gather hcloud network info with wrong name
- hcloud_network_info:
- name: "{{hcloud_network_name}}1"
- register: hcloud_network
-- name: verify test gather hcloud network with wrong name
- assert:
- that:
- - hcloud_network.hcloud_network_info | list | count == 0
-
-- name: test gather hcloud network info with correct id
- hcloud_network_info:
- id: "{{main_network.hcloud_network.id}}"
- register: hcloud_network
-- name: verify test gather hcloud network with correct id
- assert:
- that:
- - hcloud_network.hcloud_network_info | selectattr('name','equalto','{{ hcloud_network_name }}') | list | count == 1
-
-- name: test gather hcloud network info with wrong id
- hcloud_network_info:
- name: "4711"
- register: hcloud_network
-- name: verify test gather hcloud network with wrong id
- assert:
- that:
- - hcloud_network.hcloud_network_info | list | count == 0
-
-- name: cleanup
- hcloud_network:
- name: "{{ hcloud_network_name }}"
- state: absent
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_placement_group/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_placement_group/aliases
deleted file mode 100644
index 55ec821a4..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_placement_group/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/hcloud
-shippable/hcloud/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_placement_group/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_placement_group/defaults/main.yml
deleted file mode 100644
index 21ce3429a..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_placement_group/defaults/main.yml
+++ /dev/null
@@ -1,6 +0,0 @@
-# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
----
-hcloud_prefix: "tests"
-hcloud_placement_group_name: "{{hcloud_prefix}}-i"
-hcloud_server_name: "{{ hcloud_prefix | truncate(45, True, '', 0) }}-i"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_placement_group/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_placement_group/meta/main.yml
deleted file mode 100644
index 407c9018a..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_placement_group/meta/main.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-collections:
- - community.general.ipfilter
- - hetzner.cloud
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_primary_ip/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_primary_ip/aliases
deleted file mode 100644
index 55ec821a4..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_primary_ip/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/hcloud
-shippable/hcloud/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_primary_ip/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_primary_ip/defaults/main.yml
deleted file mode 100644
index 98aa28eea..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_primary_ip/defaults/main.yml
+++ /dev/null
@@ -1,6 +0,0 @@
-# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
----
-hcloud_prefix: "tests"
-hcloud_primary_ip_name: "{{hcloud_prefix}}-i"
-hcloud_server_name: "{{ hcloud_prefix | truncate(45, True, '', 0) }}-fip-t"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_primary_ip/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_primary_ip/meta/main.yml
deleted file mode 100644
index 407c9018a..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_primary_ip/meta/main.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-collections:
- - community.general.ipfilter
- - hetzner.cloud
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/aliases
deleted file mode 100644
index 18dc30b6c..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/hcloud
-shippable/hcloud/group1
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/defaults/main.yml
deleted file mode 100644
index 50117a8a5..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/defaults/main.yml
+++ /dev/null
@@ -1,8 +0,0 @@
-# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
----
-hcloud_prefix: "tests"
-hcloud_server_name: "{{ hcloud_prefix | truncate(45, True, '', 0) }}"
-hcloud_floating_ip_name: "{{hcloud_prefix}}"
-hcloud_primary_ip_name: "{{hcloud_prefix}}"
-hcloud_load_balancer_name: "{{hcloud_prefix}}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/meta/main.yml
deleted file mode 100644
index 67d54d732..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/meta/main.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-collections:
- - ansible.netcommon
- - hetzner.cloud
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/tasks/main.yml
deleted file mode 100644
index dddbac0d0..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/tasks/main.yml
+++ /dev/null
@@ -1,224 +0,0 @@
-# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
----
-- name: setup
- hcloud_server:
- name: "{{ hcloud_server_name }}"
- server_type: cx11
- image: "ubuntu-22.04"
- ssh_keys:
- - ci@ansible.hetzner.cloud
- state: present
- register: setup
-- name: verify setup
- assert:
- that:
- - setup is success
-
-- name: setup Floating IP
- hcloud_floating_ip:
- name: "{{ hcloud_floating_ip_name }}"
- type: ipv4
- home_location: "fsn1"
- register: floatingIP
-- name: verify setup Floating IP
- assert:
- that:
- - floatingIP is success
-
-- name: setup Load Balancer
- hcloud_load_balancer:
- name: "{{ hcloud_load_balancer_name}}"
- load_balancer_type: lb11
- network_zone: eu-central
- state: present
- register: load_balancer
-- name: verify setup
- assert:
- that:
- - load_balancer is success
-
-- name: setup Primary IP
- hcloud_primary_ip:
- name: "{{ hcloud_primary_ip_name }}"
- type: ipv4
- datacenter: "fsn1-dc14"
- register: primaryIP
-- name: verify setup Primary IP
- assert:
- that:
- - primaryIP is success
-
-- name: test missing required parameter
- hcloud_rdns:
- state: present
- register: result
- ignore_errors: yes
-- name: verify fail test missing required parameters
- assert:
- that:
- - result is failed
- - 'result.msg == "missing required arguments: ip_address"'
-- name: test fail on not existing resource
- hcloud_rdns:
- server: "not-existing"
- ip_address: "127.0.0.1"
- state: present
- register: result
- ignore_errors: yes
-- name: verify fail on not existing resou
- assert:
- that:
- - result is failed
- - 'result.msg == "The selected server does not exist"'
-- name: test create rdns
- hcloud_rdns:
- server: "{{ hcloud_server_name }}"
- ip_address: "{{ setup.hcloud_server.ipv6 | ansible.netcommon.ipaddr('next_usable') }}"
- dns_ptr: "example.com"
- state: present
- register: rdns
-- name: verify create rdns
- assert:
- that:
- - rdns is changed
- - rdns.hcloud_rdns.server == "{{ hcloud_server_name }}"
- - rdns.hcloud_rdns.ip_address == "{{ setup.hcloud_server.ipv6 | ansible.netcommon.ipaddr('next_usable') }}"
- - rdns.hcloud_rdns.dns_ptr == "example.com"
-
-- name: test create rdns idempotency
- hcloud_rdns:
- server: "{{ hcloud_server_name }}"
- ip_address: "{{ setup.hcloud_server.ipv6 | ansible.netcommon.ipaddr('next_usable') }}"
- dns_ptr: "example.com"
- state: present
- register: result
-- name: verify create rdns idempotency
- assert:
- that:
- - result is not changed
-
-- name: test absent rdns
- hcloud_rdns:
- server: "{{ hcloud_server_name }}"
- ip_address: "{{ setup.hcloud_server.ipv6 | ansible.netcommon.ipaddr('next_usable') }}"
- state: absent
- register: result
-- name: verify test absent rdns
- assert:
- that:
- - result is changed
-
-- name: test update rdns
- hcloud_rdns:
- server: "{{ hcloud_server_name }}"
- ip_address: "{{ setup.hcloud_server.ipv4_address }}"
- dns_ptr: "example.com"
- state: present
- register: rdns
-- name: verify update rdns
- assert:
- that:
- - rdns is changed
- - rdns.hcloud_rdns.server == "{{ hcloud_server_name }}"
- - rdns.hcloud_rdns.ip_address == "{{ setup.hcloud_server.ipv4_address }}"
- - rdns.hcloud_rdns.dns_ptr == "example.com"
-
-- name: test reset rdns
- hcloud_rdns:
- server: "{{ hcloud_server_name }}"
- ip_address: "{{ setup.hcloud_server.ipv4_address }}"
- state: present
- register: rdns
-- name: verify reset rdns
- assert:
- that:
- - rdns is changed
- - rdns.hcloud_rdns.server == "{{ hcloud_server_name }}"
- - rdns.hcloud_rdns.ip_address == "{{ setup.hcloud_server.ipv4_address }}"
- - rdns.hcloud_rdns.dns_ptr != "example.com"
-
-- name: test create rdns with floating IP
- hcloud_rdns:
- floating_ip: "{{ hcloud_floating_ip_name }}"
- ip_address: "{{ floatingIP.hcloud_floating_ip.ip}}"
- dns_ptr: "example.com"
- state: present
- register: rdns
-- name: verify create rdns
- assert:
- that:
- - rdns is changed
- - rdns.hcloud_rdns.floating_ip == "{{ hcloud_floating_ip_name }}"
- - rdns.hcloud_rdns.ip_address == "{{ floatingIP.hcloud_floating_ip.ip}}"
- - rdns.hcloud_rdns.dns_ptr == "example.com"
-
-- name: test create rdns with primary IP
- hcloud_rdns:
- primary_ip: "{{ hcloud_primary_ip_name }}"
- ip_address: "{{ primaryIP.hcloud_primary_ip.ip}}"
- dns_ptr: "example.com"
- state: present
- register: rdns
-- name: verify create rdns
- assert:
- that:
- - rdns is changed
- - rdns.hcloud_rdns.primary_ip == "{{ hcloud_primary_ip_name }}"
- - rdns.hcloud_rdns.ip_address == "{{ primaryIP.hcloud_primary_ip.ip}}"
- - rdns.hcloud_rdns.dns_ptr == "example.com"
-
-- name: test create rdns with load balancer
- hcloud_rdns:
- load_balancer: "{{ hcloud_load_balancer_name }}"
- ip_address: "{{ load_balancer.hcloud_load_balancer.ipv4_address }}"
- dns_ptr: "example.com"
- state: present
- register: rdns
-- name: verify create rdns with load balancer
- assert:
- that:
- - rdns is changed
- - rdns.hcloud_rdns.load_balancer == "{{ hcloud_load_balancer_name }}"
- - rdns.hcloud_rdns.ip_address == "{{ load_balancer.hcloud_load_balancer.ipv4_address }}"
- - rdns.hcloud_rdns.dns_ptr == "example.com"
-
-- name: cleanup
- hcloud_server:
- name: "{{ hcloud_server_name }}"
- state: absent
- register: result
-- name: verify cleanup
- assert:
- that:
- - result is success
-
-- name: cleanup
- hcloud_floating_ip:
- name: "{{ hcloud_floating_ip_name }}"
- state: absent
- register: result
-- name: verify cleanup
- assert:
- that:
- - result is success
-
-- name: cleanup
- hcloud_primary_ip:
- name: "{{ hcloud_primary_ip_name }}"
- state: absent
- register: result
-- name: verify cleanup
- assert:
- that:
- - result is success
-
-- name: cleanup
- hcloud_load_balancer:
- name: "{{ hcloud_load_balancer_name }}"
- state: absent
- register: result
-- name: verify cleanup
- assert:
- that:
- - result is success
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/aliases
deleted file mode 100644
index 18dc30b6c..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/hcloud
-shippable/hcloud/group1
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/defaults/main.yml
deleted file mode 100644
index c93c7495e..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/defaults/main.yml
+++ /dev/null
@@ -1,5 +0,0 @@
-# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
----
-hcloud_prefix: "tests"
-hcloud_network_name: "{{hcloud_prefix}}-ro"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/meta/main.yml
deleted file mode 100644
index 67d54d732..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/meta/main.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-collections:
- - ansible.netcommon
- - hetzner.cloud
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/aliases
deleted file mode 100644
index 18dc30b6c..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/hcloud
-shippable/hcloud/group1
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/defaults/main.yml
deleted file mode 100644
index 4e1c4dc45..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/defaults/main.yml
+++ /dev/null
@@ -1,8 +0,0 @@
-# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
----
-hcloud_prefix: "tests"
-hcloud_server_name: "{{ hcloud_prefix | truncate(45, True, '', 0) }}-i"
-hcloud_firewall_name: "{{hcloud_prefix}}-i"
-hcloud_primary_ip_name: "{{hcloud_prefix}}-i"
-hcloud_network_name: "{{hcloud_prefix}}-i"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/meta/main.yml
deleted file mode 100644
index 407c9018a..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/meta/main.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-collections:
- - community.general.ipfilter
- - hetzner.cloud
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/main.yml
deleted file mode 100644
index 209d9bd48..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/main.yml
+++ /dev/null
@@ -1,8 +0,0 @@
-# Copyright: (c) 2022, Hetzner Cloud GmbH <info@hetzner-cloud.de>
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
----
-#- ansible.builtin.include_tasks: validation.yml
-- ansible.builtin.include_tasks: basic.yml
-#- ansible.builtin.include_tasks: firewalls.yml
-- ansible.builtin.include_tasks: primary_ips.yml
-- ansible.builtin.include_tasks: private_network_only.yml
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/aliases
deleted file mode 100644
index 55ec821a4..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/hcloud
-shippable/hcloud/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/defaults/main.yml
deleted file mode 100644
index aa27d6452..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/defaults/main.yml
+++ /dev/null
@@ -1,5 +0,0 @@
-# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
----
-hcloud_prefix: "tests"
-hcloud_server_name: "{{ hcloud_prefix | truncate(45, True, '', 0) }}-ii"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/meta/main.yml
deleted file mode 100644
index 407c9018a..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/meta/main.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-collections:
- - community.general.ipfilter
- - hetzner.cloud
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/tasks/main.yml
deleted file mode 100644
index b425b4127..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/tasks/main.yml
+++ /dev/null
@@ -1,128 +0,0 @@
-# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
----
-- name: setup ensure server is absent
- hcloud_server:
- name: "{{ hcloud_server_name }}"
- state: absent
- register: result
-
-- name: create server
- hcloud_server:
- name: "{{ hcloud_server_name }}"
- server_type: cx11
- image: ubuntu-22.04
- state: started
- labels:
- key: value
- register: main_server
-- name: verify create server
- assert:
- that:
- - main_server is changed
- - main_server.hcloud_server.name == "{{ hcloud_server_name }}"
- - main_server.hcloud_server.server_type == "cx11"
- - main_server.hcloud_server.status == "running"
- - main_server.root_password != ""
-
-
-- name: test gather hcloud server infos in check mode
- hcloud_server_info:
- register: server
- check_mode: yes
-
-- name: verify test gather hcloud server infos in check mode
- assert:
- that:
- - server.hcloud_server_info|selectattr('name','equalto','{{ hcloud_server_name }}') | list | count == 1
-
-
-- name: test gather hcloud server infos with correct label selector
- hcloud_server_info:
- label_selector: "key=value"
- register: server
-- name: verify test gather hcloud server infos with correct label selector
- assert:
- that:
- - server.hcloud_server_info|selectattr('name','equalto','{{ hcloud_server_name }}') | list | count == 1
-
-- name: test gather hcloud server infos with wrong label selector
- hcloud_server_info:
- label_selector: "key!=value"
- register: server
-- name: verify test gather hcloud server infos with wrong label selector
- assert:
- that:
- - server.hcloud_server_info | list | count == 0
-
-- name: test gather hcloud server infos with correct name
- hcloud_server_info:
- name: "{{hcloud_server_name}}"
- register: server
-- name: verify test gather hcloud server infos with correct name
- assert:
- that:
- - server.hcloud_server_info|selectattr('name','equalto','{{ hcloud_server_name }}') | list | count == 1
-
-- name: test gather hcloud server infos with wrong name
- hcloud_server_info:
- name: "{{hcloud_server_name}}1"
- register: server
-- name: verify test gather hcloud server infos with wrong name
- assert:
- that:
- - server.hcloud_server_info | list | count == 0
-
-- name: test gather hcloud server infos with correct id
- hcloud_server_info:
- id: "{{main_server.hcloud_server.id}}"
- register: server
-- name: verify test gather hcloud server infos with correct id
- assert:
- that:
- - server.hcloud_server_info|selectattr('name','equalto','{{ hcloud_server_name }}') | list | count == 1
-
-- name: test gather hcloud server infos with wrong id
- hcloud_server_info:
- name: "4711"
- register: server
-- name: verify test gather hcloud server infos with wrong id
- assert:
- that:
- - server.hcloud_server_info | list | count == 0
-
-- name: cleanup
- hcloud_server:
- name: "{{ hcloud_server_name }}"
- state: absent
-
-- name: create server without ips
- hcloud_server:
- name: "{{ hcloud_server_name }}"
- server_type: cx11
- image: ubuntu-22.04
- state: stopped
- labels:
- key: value
- enable_ipv4: no
- enable_ipv6: no
- register: main_server
-- name: verify create server
- assert:
- that:
- - main_server is changed
- - main_server.hcloud_server.name == "{{ hcloud_server_name }}"
- - main_server.hcloud_server.server_type == "cx11"
- - main_server.root_password != ""
-- name: test gather hcloud server infos with correct id
- hcloud_server_info:
- id: "{{main_server.hcloud_server.id}}"
- register: server
-- name: verify test gather hcloud server infos with correct id
- assert:
- that:
- - server.hcloud_server_info|selectattr('name','equalto','{{ hcloud_server_name }}') | list | count == 1
-- name: cleanup
- hcloud_server:
- name: "{{ hcloud_server_name }}"
- state: absent
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/aliases
deleted file mode 100644
index 7f17468b0..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/aliases
+++ /dev/null
@@ -1,3 +0,0 @@
-cloud/hcloud
-shippable/hcloud/group2
-disabled
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/defaults/main.yml
deleted file mode 100644
index 2e020c495..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/defaults/main.yml
+++ /dev/null
@@ -1,6 +0,0 @@
-# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
----
-hcloud_prefix: "tests"
-hcloud_network_name: "{{hcloud_prefix}}-sn"
-hcloud_server_name: "{{ hcloud_prefix | truncate(45, True, '', 0) }}-sn"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/meta/main.yml
deleted file mode 100644
index 407c9018a..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/meta/main.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-collections:
- - community.general.ipfilter
- - hetzner.cloud
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/aliases
deleted file mode 100644
index 55ec821a4..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/hcloud
-shippable/hcloud/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/meta/main.yml
deleted file mode 100644
index 407c9018a..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/meta/main.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-collections:
- - community.general.ipfilter
- - hetzner.cloud
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/tasks/main.yml
deleted file mode 100644
index 3c1fce8c0..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/tasks/main.yml
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
----
-- name: test gather hcloud server type infos
- hcloud_server_type_info:
- register: hcloud_server_types
-- name: verify test gather hcloud server type infos
- assert:
- that:
- - hcloud_server_types.hcloud_server_type_info| list | count > 2
-
-- name: test gather hcloud server type infos in check mode
- hcloud_server_type_info:
- check_mode: yes
- register: hcloud_server_types
-
-- name: verify test gather hcloud server type infos in check mode
- assert:
- that:
- - hcloud_server_types.hcloud_server_type_info| list | count > 2
-
-- name: test gather hcloud server type infos with name
- hcloud_server_type_info:
- name: "{{hcloud_server_type_name}}"
- register: hcloud_server_types
-- name: verify test gather hcloud server type with name
- assert:
- that:
- - hcloud_server_types.hcloud_server_type_info|selectattr('name','equalto','{{ hcloud_server_type_name }}') | list | count == 1
-
-- name: test gather hcloud server type infos with correct id
- hcloud_server_type_info:
- id: "{{hcloud_server_type_id}}"
- register: hcloud_server_types
-- name: verify test gather hcloud server type with correct id
- assert:
- that:
- - hcloud_server_types.hcloud_server_type_info|selectattr('name','equalto','{{ hcloud_server_type_name }}') | list | count == 1
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/aliases
deleted file mode 100644
index 55ec821a4..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/hcloud
-shippable/hcloud/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/defaults/main.yml
deleted file mode 100644
index cee1d4691..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/defaults/main.yml
+++ /dev/null
@@ -1,11 +0,0 @@
-# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
----
-hcloud_prefix: "tests"
-hcloud_server_name: "{{ hcloud_prefix | truncate(45, True, '', 0) }}"
-hcloud_ssh_key_name: "{{hcloud_prefix}}"
-hcloud_ssh_key_public_key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDnaTPfKaX1QKcRLOfr34buVLh5FhJAThI9NYB0xNdXsMd4Y0zLyyCQzHbx4eWCVZxym/s6csWSeLaAhO1GOHeAw3hQFMqf1oTBx6Y8g0pKpeotKPa/PDSUzdZF9Lc+DadtpQd8kFVHAu1Kd3zoEUnk1u6kP7I4qu4Z/6F9qBDF+M3aobiPVxdS7GwaVRW3nZu+FcQDLiBiNOjuRDyjHcDfEUkoh2SOu25RrFtGPzFu5mGmBJwotKpWAocLGfHzyn/fAHxgw3jKZVH/t+XWQFnl82Ie8yE3Z1EZ7oDkNRqFQT9AdXEQOLycTTYTQMJZpgeFTv3sAo6lPRCusiFmmLcf ci@ansible.hetzner.cloud"
-hcloud_ssh_key_fingerprint: "56:89:c4:d6:a7:4a:79:82:f4:c2:58:9c:e1:d2:2d:4e"
-
-hcloud_doubled_ssh_key_public_key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC1AiuN3UMQKzOs4tNudmlDSkSebC+savc6CivoHGflUKeli7nKb5pKgGiqH+zeWZc+8+flUa2BxsJWmi7d1nGJ++W4BnzmqW78ApelpJnGtuX8IKNcq/trhVTQyaShPiLluoBs7bXyyZpAKNGkk3jHrgwwYD/QQDN0CJnQUM18fjH5CUes2vmaG/kkhn7ctuVHDOvDcEy8KdBX3fYyrtXw5GgWDC5borG6yT1f3E9AXfRPL9OQjMTeC+G4FHscJAZjNnYav+jLrQLdV1xJ0JgbjRyBgTAfBszx9oKIjzCUPvpj4npju0WFGu10pIh0w7bluMoVn1tS6Y3gxE/Cepwt ci@ansible.hetzner.cloud"
-hcloud_doubled_ssh_key_fingerprint: "f9:33:40:ff:77:f3:3e:85:f2:9e:8f:98:71:fd:a0:58"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/meta/main.yml
deleted file mode 100644
index 5dcc0725d..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/meta/main.yml
+++ /dev/null
@@ -1,5 +0,0 @@
-dependencies:
- - setup_sshkey
-collections:
- - community.general.ipfilter
- - hetzner.cloud
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/aliases
deleted file mode 100644
index 55ec821a4..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/hcloud
-shippable/hcloud/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/meta/main.yml
deleted file mode 100644
index 5dcc0725d..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/meta/main.yml
+++ /dev/null
@@ -1,5 +0,0 @@
-dependencies:
- - setup_sshkey
-collections:
- - community.general.ipfilter
- - hetzner.cloud
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/tasks/main.yml
deleted file mode 100644
index 87cbd2626..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/tasks/main.yml
+++ /dev/null
@@ -1,68 +0,0 @@
-# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
----
-
-- name: setup ensure ssh key is absent
- hcloud_ssh_key:
- name: "{{ hcloud_ssh_key_name }}"
- state: absent
- register: result
-
-- name: setup test ssh_key
- hcloud_ssh_key:
- name: "{{hcloud_ssh_key_name}}"
- public_key: "{{ key_material }}"
- labels:
- key: value
- register: result
-- name: verify create test ssh_key
- assert:
- that:
- - result is changed
- - result.hcloud_ssh_key.public_key == "{{ key_material }}"
-
-- name: test gather hcloud ssh key infos in check mode
- hcloud_ssh_key_info:
- register: hcloud_ssh_key
- check_mode: yes
-- name: verify test gather hcloud ssh key infos in check mode
- assert:
- that:
- - hcloud_ssh_key.hcloud_ssh_key_info| list | count >= 1
-
-- name: test gather hcloud ssh key infos
- hcloud_ssh_key_info:
- register: hcloud_ssh_key
- check_mode: yes
-- name: verify test gather hcloud ssh key infos
- assert:
- that:
- - hcloud_ssh_key.hcloud_ssh_key_info| list | count >= 1
-
-- name: test gather hcloud ssh key infos with correct label selector
- hcloud_ssh_key_info:
- label_selector: "key=value"
- register: hcloud_ssh_key
-- name: verify test gather hcloud ssh key infos with correct label selector
- assert:
- that:
- - hcloud_ssh_key.hcloud_ssh_key_info|selectattr('name','equalto','{{ hcloud_ssh_key_name }}') | list | count == 1
-
-- name: test gather hcloud ssh key infos with wrong label selector
- hcloud_ssh_key_info:
- label_selector: "key!=value"
- register: hcloud_ssh_key
-- name: verify test gather hcloud ssh key infos with wrong label selector
- assert:
- that:
- - hcloud_ssh_key.hcloud_ssh_key_info | list | count == 0
-
-- name: cleanup
- hcloud_ssh_key:
- name: "{{hcloud_ssh_key_name}}"
- state: absent
- register: result
-- name: verify cleanup
- assert:
- that:
- - result is success
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/aliases
deleted file mode 100644
index af1d98c3d..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/hcloud
-shippable/hcloud/group3
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/defaults/main.yml
deleted file mode 100644
index 79f0d8783..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/defaults/main.yml
+++ /dev/null
@@ -1,6 +0,0 @@
-# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
----
-hcloud_prefix: "tests"
-hcloud_network_name: "{{hcloud_prefix}}-s"
-hetzner_vswitch_id: 15311
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/meta/main.yml
deleted file mode 100644
index 407c9018a..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/meta/main.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-collections:
- - community.general.ipfilter
- - hetzner.cloud
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/tasks/main.yml
deleted file mode 100644
index 0453f9d13..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/tasks/main.yml
+++ /dev/null
@@ -1,125 +0,0 @@
-# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
----
-- name: setup
- hcloud_network:
- name: "{{ hcloud_network_name }}"
- ip_range: "10.0.0.0/8"
- state: present
- register: network
-- name: verify setup
- assert:
- that:
- - network is success
-
-- name: test missing required parameters on create route
- hcloud_subnetwork:
- network: "{{ hcloud_network_name }}"
- state: present
- register: result
- ignore_errors: yes
-- name: verify fail test missing required parameters on create route
- assert:
- that:
- - result is failed
- - 'result.msg == "missing required arguments: ip_range, network_zone, type"'
-
-- name: test create subnetwork with checkmode
- hcloud_subnetwork:
- network: "{{ hcloud_network_name }}"
- ip_range: "10.0.0.0/16"
- type: "server"
- network_zone: "eu-central"
- state: present
- register: result
- check_mode: yes
-- name: verify test create subnetwork with checkmode
- assert:
- that:
- - result is changed
-
-- name: test create subnetwork
- hcloud_subnetwork:
- network: "{{ hcloud_network_name }}"
- ip_range: "10.0.0.0/16"
- type: "cloud"
- network_zone: "eu-central"
- state: present
- register: subnet
-- name: verify create subnetwork
- assert:
- that:
- - subnet is changed
- - subnet.hcloud_subnetwork.network == "{{ hcloud_network_name }}"
- - subnet.hcloud_subnetwork.ip_range == "10.0.0.0/16"
- - subnet.hcloud_subnetwork.type == "cloud"
- - subnet.hcloud_subnetwork.network_zone == "eu-central"
-
-- name: test create subnetwork idempotency
- hcloud_subnetwork:
- network: "{{ hcloud_network_name }}"
- ip_range: "10.0.0.0/16"
- type: "cloud"
- network_zone: "eu-central"
- state: present
- register: result
-- name: verify create subnetwork idempotency
- assert:
- that:
- - result is not changed
-
-- name: test absent subnetwork
- hcloud_subnetwork:
- network: "{{ hcloud_network_name }}"
- ip_range: "10.0.0.0/16"
- type: "cloud"
- network_zone: "eu-central"
- state: absent
- register: result
-- name: verify test absent subnetwork
- assert:
- that:
- - result is changed
-
-- name: test vswitch subnetwork
- hcloud_subnetwork:
- network: "{{ hcloud_network_name }}"
- ip_range: "10.0.0.0/16"
- type: "vswitch"
- network_zone: "eu-central"
- vswitch_id: "{{ hetzner_vswitch_id }}"
- state: present
- register: subnet
-- name: verify test vswitch subnetwork
- assert:
- that:
- - subnet is changed
- - subnet.hcloud_subnetwork.network == "{{ hcloud_network_name }}"
- - subnet.hcloud_subnetwork.ip_range == "10.0.0.0/16"
- - subnet.hcloud_subnetwork.type == "vswitch"
- - subnet.hcloud_subnetwork.network_zone == "eu-central"
- - subnet.hcloud_subnetwork.vswitch_id == hetzner_vswitch_id
-
-- name: test absent subnetwork
- hcloud_subnetwork:
- network: "{{ hcloud_network_name }}"
- ip_range: "10.0.0.0/16"
- type: "vswitch"
- network_zone: "eu-central"
- vswitch_id: "{{ hetzner_vswitch_id }}"
- state: absent
- register: subnet
-- name: verify test absent subnetwork
- assert:
- that:
- - result is changed
-
-- name: cleanup
- hcloud_network:
- name: "{{hcloud_network_name}}"
- state: absent
- register: result
-- name: verify cleanup
- assert:
- that:
- - result is success
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/aliases
deleted file mode 100644
index 55ec821a4..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/hcloud
-shippable/hcloud/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/defaults/main.yml
deleted file mode 100644
index ff16ce28f..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/defaults/main.yml
+++ /dev/null
@@ -1,6 +0,0 @@
-# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
----
-hcloud_prefix: "tests"
-hcloud_volume_name: "{{ hcloud_prefix | truncate(60, True, '', 0) }}-i"
-hcloud_server_name: "{{ hcloud_prefix | truncate(45, True, '', 0) }}-vs"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/meta/main.yml
deleted file mode 100644
index 407c9018a..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/meta/main.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-collections:
- - community.general.ipfilter
- - hetzner.cloud
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/aliases
deleted file mode 100644
index 55ec821a4..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/hcloud
-shippable/hcloud/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/defaults/main.yml
deleted file mode 100644
index 52c468eeb..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/defaults/main.yml
+++ /dev/null
@@ -1,5 +0,0 @@
-# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
----
-hcloud_prefix: "tests"
-hcloud_volume_name: "{{ hcloud_prefix | truncate(60, True, '', 0) }}-i"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/meta/main.yml
deleted file mode 100644
index 407c9018a..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/meta/main.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-collections:
- - community.general.ipfilter
- - hetzner.cloud
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/tasks/main.yml
deleted file mode 100644
index ecea7ad31..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/tasks/main.yml
+++ /dev/null
@@ -1,101 +0,0 @@
-# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
----
-- name: setup ensure volume is absent
- hcloud_volume:
- name: "{{ hcloud_volume_name }}"
- state: absent
- register: result
-
-- name: setup volume
- hcloud_volume:
- name: "{{hcloud_volume_name}}"
- size: 10
- location: "fsn1"
- labels:
- key: value
- register: main_volume
-- name: verify setup volume
- assert:
- that:
- - main_volume is changed
-
-- name: test gather hcloud volume infos in check mode
- hcloud_volume_info:
- register: hcloud_volume
- check_mode: yes
-
-- name: verify test gather hcloud volume infos in check mode
- vars:
- volume: "{{ hcloud_volume.hcloud_volume_info|selectattr('name','equalto',hcloud_volume_name) | first }}"
- assert:
- that:
- - hcloud_volume.hcloud_volume_info|selectattr('name','equalto','{{ hcloud_volume_name }}') | list | count == 1
- - volume.name == "{{hcloud_volume_name}}"
- - volume.location == "fsn1"
- - volume.size == 10
- - volume.linux_device is defined
-
-- name: test gather hcloud volume infos with correct label selector
- hcloud_volume_info:
- label_selector: "key=value"
- register: hcloud_volume
-- name: verify test gather hcloud volume infos with correct label selector
- assert:
- that:
- - hcloud_volume.hcloud_volume_info|selectattr('name','equalto','{{ hcloud_volume_name }}') | list | count == 1
-
-- name: test gather hcloud volume infos with wrong label selector
- hcloud_volume_info:
- label_selector: "key!=value"
- register: hcloud_volume
-- name: verify test gather hcloud volume infos with wrong label selector
- assert:
- that:
- - hcloud_volume.hcloud_volume_info | list | count == 0
-
-- name: test gather hcloud volume infos with correct name
- hcloud_volume_info:
- name: "{{hcloud_volume_name}}"
- register: hcloud_volume
-- name: verify test gather hcloud volume infos with correct name
- assert:
- that:
- - hcloud_volume.hcloud_volume_info|selectattr('name','equalto','{{ hcloud_volume_name }}') | list | count == 1
-
-- name: test gather hcloud volume infos with wrong name
- hcloud_volume_info:
- name: "{{hcloud_volume_name}}1"
- register: hcloud_volume
-- name: verify test gather hcloud volume infos with wrong name
- assert:
- that:
- - hcloud_volume.hcloud_volume_info | list | count == 0
-
-- name: test gather hcloud volume facts with correct id
- hcloud_volume_info:
- id: "{{main_volume.hcloud_volume.id}}"
- register: hcloud_volume
-- name: verify test gather hcloud volume with correct id
- assert:
- that:
- - hcloud_volume.hcloud_volume_info|selectattr('name','equalto','{{ hcloud_volume_name }}') | list | count == 1
-
-- name: test gather hcloud volume infos with wrong id
- hcloud_volume_info:
- name: "4711"
- register: hcloud_volume
-- name: verify test gather hcloud volume infos with wrong id
- assert:
- that:
- - hcloud_volume.hcloud_volume_info | list | count == 0
-
-- name: cleanup
- hcloud_volume:
- name: "{{ hcloud_volume_name }}"
- state: absent
- register: result
-- name: verify cleanup
- assert:
- that:
- - result is success
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/image_info/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/image_info/aliases
new file mode 100644
index 000000000..0e887600e
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/image_info/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+azp/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/image_info/defaults/main/common.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/image_info/defaults/main/common.yml
new file mode 100644
index 000000000..e316b233c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/image_info/defaults/main/common.yml
@@ -0,0 +1,12 @@
+#
+# 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('first') | join() }}"
+hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/image_info/defaults/main/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/image_info/defaults/main/main.yml
new file mode 100644
index 000000000..d7a350577
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/image_info/defaults/main/main.yml
@@ -0,0 +1,6 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_server_name: "{{ hcloud_ns }}"
+hcloud_snapshot_name: "{{ hcloud_ns }}"
+hcloud_image_name: ubuntu-22.04
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/image_info/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/image_info/meta/main.yml
new file mode 100644
index 000000000..49f5c0c4b
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/image_info/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_hcloud_cli
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/image_info/tasks/cleanup.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/image_info/tasks/cleanup.yml
new file mode 100644
index 000000000..a99c36549
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/image_info/tasks/cleanup.yml
@@ -0,0 +1,5 @@
+---
+- name: Cleanup test_server
+ hetzner.hcloud.server:
+ name: "{{ hcloud_server_name }}"
+ state: absent
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/image_info/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/image_info/tasks/main.yml
new file mode 100644
index 000000000..767fc465b
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/image_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/ansible_collections/hetzner/hcloud/tests/integration/targets/image_info/tasks/prepare.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/image_info/tasks/prepare.yml
new file mode 100644
index 000000000..9c65ae86d
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/image_info/tasks/prepare.yml
@@ -0,0 +1,23 @@
+---
+- name: Create test_server
+ hetzner.hcloud.server:
+ name: "{{ hcloud_server_name }}"
+ server_type: cx11
+ image: ubuntu-22.04
+ state: stopped
+ register: test_server
+
+- name: Create test_snapshot
+ ansible.builtin.script:
+ cmd: >
+ {{ hcloud_cli_path }} server create-image
+ --type snapshot
+ --description "{{ hcloud_snapshot_name }}"
+ --label key=value
+ "{{ test_server.hcloud_server.id }}"
+ | awk '{print $2}'
+ register: test_snapshot
+
+- name: Set test_snapshot_id
+ ansible.builtin.set_fact:
+ test_snapshot_id: "{{ test_snapshot.stdout_lines[0] }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/image_info/tasks/test.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/image_info/tasks/test.yml
new file mode 100644
index 000000000..270285e9c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/image_info/tasks/test.yml
@@ -0,0 +1,104 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: Gather hcloud_image_info
+ hetzner.hcloud.image_info:
+ register: result
+- name: Verify hcloud_image_info
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_image_info | list | count >= 3
+
+- name: Gather hcloud_image_info with architecture
+ hetzner.hcloud.image_info:
+ architecture: arm
+ register: result
+- name: Verify hcloud_image_info with architecture
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_image_info | selectattr('architecture', 'equalto', 'x86') | list | count == 0
+ - result.hcloud_image_info | selectattr('architecture', 'equalto', 'arm') | list | count > 2
+
+- name: Gather hcloud_image_info in check mode
+ hetzner.hcloud.image_info:
+ check_mode: true
+ register: result
+- name: Verify hcloud_image_info in check mode
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_image_info | list | count >= 3
+
+- name: Gather hcloud_image_info with correct id
+ hetzner.hcloud.image_info:
+ id: "{{ test_snapshot_id }}"
+ type: snapshot
+ register: result
+- name: Verify hcloud_image_info with correct id
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_image_info | list | count == 1
+
+- name: Gather hcloud_image_info with wrong id
+ hetzner.hcloud.image_info:
+ id: "{{ test_snapshot_id }}4321"
+ type: snapshot
+ ignore_errors: true
+ register: result
+- name: Verify hcloud_image_info with wrong id
+ ansible.builtin.assert:
+ that:
+ - result is failed
+
+- name: Gather hcloud_image_info with correct name
+ hetzner.hcloud.image_info:
+ name: "{{ hcloud_image_name }}"
+ register: result
+- name: Verify hcloud_image_info with correct name
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_image_info | list | count == 1
+ - result.hcloud_image_info[0].architecture == "x86"
+
+- name: Gather hcloud_image_info with wrong name
+ hetzner.hcloud.image_info:
+ name: "{{ hcloud_image_name }}-invalid"
+ register: result
+- name: Verify hcloud_image_info with wrong name
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_image_info | list | count == 0
+
+- name: Gather hcloud_image_info with correct name and architecture
+ hetzner.hcloud.image_info:
+ name: "{{ hcloud_image_name }}"
+ architecture: arm
+ register: result
+- name: Verify hcloud_image_info with correct name
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_image_info | list | count == 1
+ - result.hcloud_image_info[0].architecture == "arm"
+
+- name: Gather hcloud_image_info with correct label selector
+ hetzner.hcloud.image_info:
+ label_selector: "key=value"
+ type: snapshot
+ register: result
+- name: Verify hcloud_image_info with correct label selector
+ ansible.builtin.assert:
+ that:
+ # Snapshot names are stored in the description field
+ - >
+ result.hcloud_image_info
+ | selectattr('description', 'equalto', hcloud_snapshot_name)
+ | list | count == 1
+
+- name: Gather hcloud_image_info with wrong label selector
+ hetzner.hcloud.image_info:
+ label_selector: "key!=value"
+ type: snapshot
+ register: result
+- name: Verify hcloud_image_info with wrong label selector
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_image_info | list | count == 0
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/iso_info/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/iso_info/aliases
new file mode 100644
index 000000000..a6a90a6bf
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/iso_info/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+azp/group3
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/iso_info/defaults/main/common.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/iso_info/defaults/main/common.yml
new file mode 100644
index 000000000..e316b233c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/iso_info/defaults/main/common.yml
@@ -0,0 +1,12 @@
+#
+# 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('first') | join() }}"
+hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/iso_info/defaults/main/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/iso_info/defaults/main/main.yml
new file mode 100644
index 000000000..9e3c30d01
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/iso_info/defaults/main/main.yml
@@ -0,0 +1,7 @@
+# Copyright: (c) 2023, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_iso_id: 551
+hcloud_iso_name: systemrescuecd-x86-5.2.2.iso
+hcloud_iso_type: public
+hcloud_iso_architecture: x86
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/iso_info/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/iso_info/tasks/main.yml
new file mode 100644
index 000000000..767fc465b
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/iso_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/ansible_collections/hetzner/hcloud/tests/integration/targets/iso_info/tasks/test.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/iso_info/tasks/test.yml
new file mode 100644
index 000000000..5a4a42da1
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/iso_info/tasks/test.yml
@@ -0,0 +1,73 @@
+# Copyright: (c) 2023, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: Gather hcloud_iso_info
+ hetzner.hcloud.iso_info:
+ register: result
+- name: Verify hcloud_iso_info
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_iso_info | list | count >= 1
+
+- name: Gather hcloud_iso_info in check mode
+ hetzner.hcloud.iso_info:
+ check_mode: true
+ register: result
+- name: Verify hcloud_iso_info in check mode
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_iso_info | list | count >= 1
+
+- name: Gather hcloud_iso_info with correct id
+ hetzner.hcloud.iso_info:
+ id: "{{ hcloud_iso_id }}"
+ register: result
+- name: Verify hcloud_iso_info with correct id
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_iso_info | list | count == 1
+ - result.hcloud_iso_info[0].id == hcloud_iso_id | string
+ - result.hcloud_iso_info[0].name == hcloud_iso_name
+ - result.hcloud_iso_info[0].architecture == hcloud_iso_architecture
+ - result.hcloud_iso_info[0].type == hcloud_iso_type
+ - result.hcloud_iso_info[0].deprecated is none
+ - result.hcloud_iso_info[0].deprecation is none
+
+- name: Gather hcloud_iso_info with wrong id
+ hetzner.hcloud.iso_info:
+ id: "{{ hcloud_iso_id }}4321"
+ ignore_errors: true
+ register: result
+- name: Verify hcloud_iso_info with wrong id
+ ansible.builtin.assert:
+ that:
+ - result is failed
+
+- name: Gather hcloud_iso_info with correct name
+ hetzner.hcloud.iso_info:
+ name: "{{ hcloud_iso_name }}"
+ register: result
+- name: Verify hcloud_iso_info with correct name
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_iso_info | list | count == 1
+
+- name: Gather hcloud_iso_info with wrong name
+ hetzner.hcloud.iso_info:
+ name: "{{ hcloud_iso_name }}-invalid"
+ register: result
+- name: Verify hcloud_iso_info with wrong name
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_iso_info | list | count == 0
+
+- name: Gather hcloud_iso_info with architecture
+ hetzner.hcloud.iso_info:
+ architecture: arm
+ register: result
+- name: Verify hcloud_iso_info with architecture
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_iso_info | list | count > 2
+ - result.hcloud_iso_info | selectattr('architecture', 'equalto', 'x86') | list | count == 0
+ - result.hcloud_iso_info | selectattr('architecture', 'equalto', 'arm') | list | count > 2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer/aliases
new file mode 100644
index 000000000..62828d1e9
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+azp/group1
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer/defaults/main/common.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer/defaults/main/common.yml
new file mode 100644
index 000000000..e316b233c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer/defaults/main/common.yml
@@ -0,0 +1,12 @@
+#
+# 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('first') | join() }}"
+hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer/defaults/main/main.yml
index 7f431cd8d..458094e95 100644
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/defaults/main.yml
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer/defaults/main/main.yml
@@ -1,5 +1,4 @@
# Copyright: (c) 2020, Hetzner Cloud GmbH <info@hetzner-cloud.de>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
-hcloud_prefix: "tests"
-hcloud_load_balancer_name: "{{hcloud_prefix}}-i"
+hcloud_load_balancer_name: "{{ hcloud_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer/tasks/cleanup.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer/tasks/cleanup.yml
new file mode 100644
index 000000000..b9ad6d254
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer/tasks/cleanup.yml
@@ -0,0 +1,5 @@
+---
+- name: Cleanup test_load_balancer
+ hetzner.hcloud.load_balancer:
+ name: "{{ hcloud_load_balancer_name }}"
+ state: absent
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer/tasks/main.yml
new file mode 100644
index 000000000..767fc465b
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer/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/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer/tasks/test.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer/tasks/test.yml
new file mode 100644
index 000000000..343f15672
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer/tasks/test.yml
@@ -0,0 +1,145 @@
+# Copyright: (c) 2020, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: Test missing required parameters
+ hetzner.hcloud.load_balancer:
+ name: "{{ hcloud_load_balancer_name }}"
+ state: present
+ ignore_errors: true
+ register: result
+- name: Verify missing required parameters
+ ansible.builtin.assert:
+ that:
+ - result is failed
+ - 'result.msg == "missing required arguments: load_balancer_type"'
+
+- name: Test create with check mode
+ hetzner.hcloud.load_balancer:
+ name: "{{ hcloud_load_balancer_name }}"
+ load_balancer_type: lb11
+ network_zone: eu-central
+ state: present
+ check_mode: true
+ register: result
+- name: Verify create with check mode
+ ansible.builtin.assert:
+ that:
+ - result is changed
+
+- name: Test create
+ hetzner.hcloud.load_balancer:
+ name: "{{ hcloud_load_balancer_name }}"
+ load_balancer_type: lb11
+ network_zone: eu-central
+ labels:
+ key: value
+ label: value123
+ state: present
+ register: result
+- name: Verify create
+ ansible.builtin.assert:
+ that:
+ - result is changed
+ - result.hcloud_load_balancer.name == hcloud_load_balancer_name
+ - result.hcloud_load_balancer.load_balancer_type == "lb11"
+ - result.hcloud_load_balancer.algorithm == "round_robin"
+ - result.hcloud_load_balancer.labels.key == "value"
+ - result.hcloud_load_balancer.labels.label == "value123"
+ - result.hcloud_load_balancer.delete_protection == false
+
+- name: Test create idempotency
+ hetzner.hcloud.load_balancer:
+ name: "{{ hcloud_load_balancer_name }}"
+ load_balancer_type: lb11
+ network_zone: eu-central
+ state: present
+ register: result
+- name: Verify create idempotency
+ ansible.builtin.assert:
+ that:
+ - result is not changed
+
+- name: Test update algorithm
+ hetzner.hcloud.load_balancer:
+ name: "{{ hcloud_load_balancer_name }}"
+ algorithm: least_connections
+ state: present
+ register: result
+- name: Verify update algorithm
+ ansible.builtin.assert:
+ that:
+ - result is changed
+ - result.hcloud_load_balancer.algorithm == "least_connections"
+
+- name: Test update load_balancer_type
+ hetzner.hcloud.load_balancer:
+ name: "{{ hcloud_load_balancer_name }}"
+ load_balancer_type: lb21
+ state: present
+ register: result
+- name: Verify update load_balancer_type
+ ansible.builtin.assert:
+ that:
+ - result is changed
+ - result.hcloud_load_balancer.load_balancer_type == "lb21"
+
+- name: Test update labels
+ hetzner.hcloud.load_balancer:
+ name: "{{ hcloud_load_balancer_name }}"
+ labels:
+ key: changed
+ label: changed123
+ state: present
+ register: result
+- name: Verify update load_balancer_type
+ ansible.builtin.assert:
+ that:
+ - result is changed
+ - result.hcloud_load_balancer.labels.key == "changed"
+ - result.hcloud_load_balancer.labels.label == "changed123"
+
+- name: Test update delete_protection
+ hetzner.hcloud.load_balancer:
+ name: "{{ hcloud_load_balancer_name }}"
+ delete_protection: true
+ state: present
+ register: result
+- name: Verify update load_balancer_type
+ ansible.builtin.assert:
+ that:
+ - result is changed
+ - result.hcloud_load_balancer.delete_protection == true
+
+- name: Test delete with protection
+ hetzner.hcloud.load_balancer:
+ name: "{{ hcloud_load_balancer_name }}"
+ state: absent
+ register: result
+ ignore_errors: true
+- name: Verify delete with protection
+ ansible.builtin.assert:
+ that:
+ - result is failed
+ - 'result.msg == "load balancer deletion is protected"'
+
+- name: Test update delete_protection
+ hetzner.hcloud.load_balancer:
+ name: "{{ hcloud_load_balancer_name }}"
+ delete_protection: false
+ state: present
+ register: result
+- name: Verify update delete_protection
+ ansible.builtin.assert:
+ that:
+ - result is changed
+ - result.hcloud_load_balancer.delete_protection == false
+
+- name: Test delete
+ hetzner.hcloud.load_balancer:
+ name: "{{ hcloud_load_balancer_name }}"
+ state: absent
+ register: result
+- name: Verify delete
+ ansible.builtin.assert:
+ that:
+ - result is changed
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_info/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_info/aliases
new file mode 100644
index 000000000..62828d1e9
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_info/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+azp/group1
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_info/defaults/main/common.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_info/defaults/main/common.yml
new file mode 100644
index 000000000..e316b233c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_info/defaults/main/common.yml
@@ -0,0 +1,12 @@
+#
+# 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('first') | join() }}"
+hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_info/defaults/main/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_info/defaults/main/main.yml
new file mode 100644
index 000000000..63c342baf
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_info/defaults/main/main.yml
@@ -0,0 +1,5 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_load_balancer_name: "{{ hcloud_ns }}"
+hcloud_server_name: "{{ hcloud_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_info/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_info/meta/main.yml
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_info/meta/main.yml
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_info/tasks/cleanup.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_info/tasks/cleanup.yml
new file mode 100644
index 000000000..b99d2cd58
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_info/tasks/cleanup.yml
@@ -0,0 +1,10 @@
+---
+- name: Cleanup test_load_balancer
+ hetzner.hcloud.load_balancer:
+ name: "{{ hcloud_load_balancer_name }}"
+ state: absent
+
+- name: Cleanup test_server
+ hetzner.hcloud.server:
+ name: "{{ hcloud_server_name }}"
+ state: absent
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_info/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_info/tasks/main.yml
new file mode 100644
index 000000000..767fc465b
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_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/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_info/tasks/prepare.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_info/tasks/prepare.yml
new file mode 100644
index 000000000..bfad755df
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_info/tasks/prepare.yml
@@ -0,0 +1,33 @@
+---
+- name: Create test_server
+ hetzner.hcloud.server:
+ name: "{{ hcloud_server_name }}"
+ server_type: cx11
+ image: ubuntu-22.04
+ state: started
+ register: test_server
+
+- name: Create test_load_balancer
+ hetzner.hcloud.load_balancer:
+ name: "{{ hcloud_load_balancer_name }}"
+ load_balancer_type: lb11
+ network_zone: eu-central
+ labels:
+ key: value
+ register: test_load_balancer
+
+- name: Create test_load_balancer_target
+ hetzner.hcloud.load_balancer_target:
+ type: "server"
+ load_balancer: "{{ hcloud_load_balancer_name }}"
+ server: "{{ hcloud_server_name }}"
+ state: present
+ register: test_load_balancer_target
+
+- name: Create test_load_balancer_service
+ hetzner.hcloud.load_balancer_service:
+ load_balancer: "{{ hcloud_load_balancer_name }}"
+ protocol: "http"
+ listen_port: 80
+ state: present
+ register: test_load_balancer_service
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_info/tasks/test.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_info/tasks/test.yml
new file mode 100644
index 000000000..36ad43b40
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_info/tasks/test.yml
@@ -0,0 +1,86 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: Gather hcloud_load_balancer_info
+ hetzner.hcloud.load_balancer_info:
+ register: result
+- name: Verify hcloud_load_balancer_info
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_load_balancer_info | list | count >= 1
+
+- name: Gather hcloud_load_balancer_info in check mode
+ hetzner.hcloud.load_balancer_info:
+ check_mode: true
+ register: result
+- name: Verify hcloud_load_balancer_info in check mode
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_load_balancer_info | list | count >= 1
+
+- name: Gather hcloud_load_balancer_info with correct id
+ hetzner.hcloud.load_balancer_info:
+ id: "{{ test_load_balancer.hcloud_load_balancer.id }}"
+ register: result
+- name: Verify hcloud_load_balancer_info with correct id
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_load_balancer_info | list | count == 1
+ - result.hcloud_load_balancer_info[0].targets | list | count == 1
+ - result.hcloud_load_balancer_info[0].targets | selectattr('type', 'equalto', 'server') | list | count == 1
+ - result.hcloud_load_balancer_info[0].targets | selectattr('server', 'equalto', hcloud_server_name) | list | count == 1
+ - result.hcloud_load_balancer_info[0].targets[0].health_status[0].listen_port == 80
+ - result.hcloud_load_balancer_info[0].targets[0].health_status[0].status in ['healthy', 'unhealthy', 'unknown']
+ - result.hcloud_load_balancer_info[0].services | list | count == 1
+ - result.hcloud_load_balancer_info[0].services | selectattr('protocol', 'equalto', 'http') | list | count == 1
+ - result.hcloud_load_balancer_info[0].services | selectattr('listen_port', 'equalto', 80) | list | count == 1
+ - result.hcloud_load_balancer_info[0].services | selectattr('destination_port', 'equalto', 80) | list | count == 1
+
+- name: Gather hcloud_load_balancer_info with wrong id
+ hetzner.hcloud.load_balancer_info:
+ id: "{{ test_load_balancer.hcloud_load_balancer.id }}4321"
+ ignore_errors: true
+ register: result
+- name: Verify hcloud_load_balancer_info with wrong id
+ ansible.builtin.assert:
+ that:
+ - result is failed
+
+- name: Gather hcloud_load_balancer_info with correct name
+ hetzner.hcloud.load_balancer_info:
+ name: "{{ hcloud_load_balancer_name }}"
+ register: result
+- name: Verify hcloud_load_balancer_info with correct name
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_load_balancer_info | list | count == 1
+
+- name: Gather hcloud_load_balancer_info with wrong name
+ hetzner.hcloud.load_balancer_info:
+ name: "{{ hcloud_load_balancer_name }}-invalid"
+ register: result
+- name: Verify hcloud_load_balancer_info with wrong name
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_load_balancer_info | list | count == 0
+
+- name: Gather hcloud_load_balancer_info with correct label selector
+ hetzner.hcloud.load_balancer_info:
+ label_selector: "key=value"
+ register: result
+- name: Verify hcloud_load_balancer_info with correct label selector
+ ansible.builtin.assert:
+ that:
+ - >
+ result.hcloud_load_balancer_info
+ | selectattr('name', 'equalto', hcloud_load_balancer_name)
+ | list | count == 1
+
+- name: Gather hcloud_load_balancer_info with wrong label selector
+ hetzner.hcloud.load_balancer_info:
+ label_selector: "key!=value"
+ register: result
+- name: Verify hcloud_load_balancer_info with wrong label selector
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_load_balancer_info | list | count == 0
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_network/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_network/aliases
new file mode 100644
index 000000000..62828d1e9
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_network/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+azp/group1
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_network/defaults/main/common.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_network/defaults/main/common.yml
new file mode 100644
index 000000000..e316b233c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_network/defaults/main/common.yml
@@ -0,0 +1,12 @@
+#
+# 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('first') | join() }}"
+hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_network/defaults/main/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_network/defaults/main/main.yml
new file mode 100644
index 000000000..d7a9d233c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_network/defaults/main/main.yml
@@ -0,0 +1,5 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_network_name: "{{ hcloud_ns }}"
+hcloud_load_balancer_name: "{{ hcloud_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_network/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_network/tasks/main.yml
new file mode 100644
index 000000000..767fc465b
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_network/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/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_network/tasks/test.yml
index 9a1bf5175..06e469619 100644
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/tasks/main.yml
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_network/tasks/test.yml
@@ -2,7 +2,7 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
- name: setup network
- hcloud_network:
+ hetzner.hcloud.network:
name: "{{ hcloud_network_name }}"
ip_range: "10.0.0.0/8"
state: present
@@ -10,10 +10,10 @@
- name: verify setup network
assert:
that:
- - network is success
+ - network is success
- name: setup subnetwork
- hcloud_subnetwork:
+ hetzner.hcloud.subnetwork:
network: "{{ hcloud_network_name }}"
ip_range: "10.0.0.0/16"
type: "cloud"
@@ -23,10 +23,10 @@
- name: verify subnetwork
assert:
that:
- - subnetwork is success
+ - subnetwork is success
- name: setup load_balancer
- hcloud_load_balancer:
+ hetzner.hcloud.load_balancer:
name: "{{hcloud_load_balancer_name}}"
load_balancer_type: lb11
state: present
@@ -38,10 +38,10 @@
- load_balancer is success
- name: test missing required parameters on create load_balancer network
- hcloud_load_balancer_network:
+ hetzner.hcloud.load_balancer_network:
state: present
register: result
- ignore_errors: yes
+ ignore_errors: true
- name: verify fail test missing required parameters on create load_balancer network
assert:
that:
@@ -49,7 +49,7 @@
- '"missing required arguments:" in result.msg'
- name: test fail load balancer does not exist
- hetzner.hcloud.hcloud_load_balancer_network:
+ hetzner.hcloud.load_balancer_network:
network: "{{ hcloud_network_name }}"
load_balancer: does-not-exist
state: present
@@ -59,10 +59,10 @@
assert:
that:
- result is failed
- - "result.msg == 'Load balancer does not exist: does-not-exist'"
+ - "result.msg == 'resource (load_balancer) does not exist: does-not-exist'"
- name: test fail network does not exist
- hetzner.hcloud.hcloud_load_balancer_network:
+ hetzner.hcloud.load_balancer_network:
network: does-not-exist
load_balancer: "{{ hcloud_load_balancer_name }}"
state: present
@@ -72,22 +72,22 @@
assert:
that:
- result is failed
- - "result.msg == 'Network does not exist: does-not-exist'"
+ - "result.msg == 'resource (network) does not exist: does-not-exist'"
- name: test create load_balancer network with checkmode
- hcloud_load_balancer_network:
+ hetzner.hcloud.load_balancer_network:
network: "{{ hcloud_network_name }}"
load_balancer: "{{hcloud_load_balancer_name}}"
state: present
register: result
- check_mode: yes
+ check_mode: true
- name: verify test create load_balancer network with checkmode
assert:
that:
- - result is changed
+ - result is changed
- name: test create load_balancer network
- hcloud_load_balancer_network:
+ hetzner.hcloud.load_balancer_network:
network: "{{ hcloud_network_name }}"
load_balancer: "{{hcloud_load_balancer_name}}"
state: present
@@ -95,12 +95,12 @@
- name: verify create load_balancer network
assert:
that:
- - load_balancerNetwork is changed
- - load_balancerNetwork.hcloud_load_balancer_network.network == hcloud_network_name
- - load_balancerNetwork.hcloud_load_balancer_network.load_balancer == hcloud_load_balancer_name
+ - load_balancerNetwork is changed
+ - load_balancerNetwork.hcloud_load_balancer_network.network == hcloud_network_name
+ - load_balancerNetwork.hcloud_load_balancer_network.load_balancer == hcloud_load_balancer_name
- name: test create load_balancer network idempotency
- hcloud_load_balancer_network:
+ hetzner.hcloud.load_balancer_network:
network: "{{ hcloud_network_name }}"
load_balancer: "{{hcloud_load_balancer_name}}"
state: present
@@ -108,10 +108,10 @@
- name: verify create load_balancer network idempotency
assert:
that:
- - load_balancerNetwork is not changed
+ - load_balancerNetwork is not changed
- name: test absent load_balancer network
- hcloud_load_balancer_network:
+ hetzner.hcloud.load_balancer_network:
network: "{{ hcloud_network_name }}"
load_balancer: "{{hcloud_load_balancer_name}}"
state: absent
@@ -119,10 +119,10 @@
- name: verify test absent load_balancer network
assert:
that:
- - result is changed
+ - result is changed
- name: test create load_balancer network with specified ip
- hcloud_load_balancer_network:
+ hetzner.hcloud.load_balancer_network:
network: "{{ hcloud_network_name }}"
load_balancer: "{{hcloud_load_balancer_name}}"
ip: "10.0.0.2"
@@ -131,13 +131,13 @@
- name: verify create load_balancer network with specified ip
assert:
that:
- - load_balancerNetwork is changed
- - load_balancerNetwork.hcloud_load_balancer_network.network == hcloud_network_name
- - load_balancerNetwork.hcloud_load_balancer_network.load_balancer == hcloud_load_balancer_name
- - load_balancerNetwork.hcloud_load_balancer_network.ip == "10.0.0.2"
+ - load_balancerNetwork is changed
+ - load_balancerNetwork.hcloud_load_balancer_network.network == hcloud_network_name
+ - load_balancerNetwork.hcloud_load_balancer_network.load_balancer == hcloud_load_balancer_name
+ - load_balancerNetwork.hcloud_load_balancer_network.ip == "10.0.0.2"
- name: cleanup create load_balancer network with specified ip
- hcloud_load_balancer_network:
+ hetzner.hcloud.load_balancer_network:
network: "{{ hcloud_network_name }}"
load_balancer: "{{hcloud_load_balancer_name}}"
state: absent
@@ -145,20 +145,20 @@
- name: verify cleanup create load_balancer network with specified ip
assert:
that:
- - result is changed
+ - result is changed
- name: cleanup load_balancer
- hcloud_load_balancer:
+ hetzner.hcloud.load_balancer:
name: "{{ hcloud_load_balancer_name }}"
state: absent
register: result
- name: verify cleanup load_balancer
assert:
that:
- - result is success
+ - result is success
- name: cleanup subnetwork
- hcloud_subnetwork:
+ hetzner.hcloud.subnetwork:
network: "{{ hcloud_network_name }}"
ip_range: "10.0.0.0/16"
type: "cloud"
@@ -168,10 +168,10 @@
- name: verify cleanup subnetwork
assert:
that:
- - result is changed
+ - result is changed
- name: cleanup
- hcloud_network:
+ hetzner.hcloud.network:
name: "{{hcloud_network_name}}"
state: absent
register: result
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_service/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_service/aliases
new file mode 100644
index 000000000..62828d1e9
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_service/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+azp/group1
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_service/defaults/main/common.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_service/defaults/main/common.yml
new file mode 100644
index 000000000..e316b233c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_service/defaults/main/common.yml
@@ -0,0 +1,12 @@
+#
+# 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('first') | join() }}"
+hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_service/defaults/main/main.yml
index 081eb1472..f6a05e8d1 100644
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/defaults/main.yml
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_service/defaults/main/main.yml
@@ -1,5 +1,4 @@
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
-hcloud_prefix: "tests"
-hcloud_network_name: "{{hcloud_prefix}}-i"
+hcloud_load_balancer_name: "{{ hcloud_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_service/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_service/tasks/main.yml
new file mode 100644
index 000000000..767fc465b
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_service/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/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_service/tasks/test.yml
index b0db6bb63..173709a67 100644
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/tasks/main.yml
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_service/tasks/test.yml
@@ -2,7 +2,7 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
- name: setup load_balancer
- hcloud_load_balancer:
+ hetzner.hcloud.load_balancer:
name: "{{hcloud_load_balancer_name}}"
load_balancer_type: lb11
state: present
@@ -14,7 +14,7 @@
- load_balancer is success
- name: test fail load balancer does not exist
- hetzner.hcloud.hcloud_load_balancer_service:
+ hetzner.hcloud.load_balancer_service:
load_balancer: does-not-exist
protocol: http
listen_port: 80
@@ -25,23 +25,23 @@
assert:
that:
- result is failed
- - "result.msg == 'Load balancer does not exist: does-not-exist'"
+ - "result.msg == 'resource (load_balancer) does not exist: does-not-exist'"
- name: test create load_balancer service with checkmode
- hcloud_load_balancer_service:
+ hetzner.hcloud.load_balancer_service:
load_balancer: "{{hcloud_load_balancer_name}}"
protocol: "http"
listen_port: 80
state: present
register: result
- check_mode: yes
+ check_mode: true
- name: verify test create load_balancer service with checkmode
assert:
that:
- - result is changed
+ - result is changed
- name: test create load_balancer service
- hcloud_load_balancer_service:
+ hetzner.hcloud.load_balancer_service:
load_balancer: "{{hcloud_load_balancer_name}}"
protocol: "http"
listen_port: 80
@@ -50,14 +50,14 @@
- name: verify create load_balancer service
assert:
that:
- - load_balancer_service is changed
- - load_balancer_service.hcloud_load_balancer_service.protocol == "http"
- - load_balancer_service.hcloud_load_balancer_service.listen_port == 80
- - load_balancer_service.hcloud_load_balancer_service.destination_port == 80
- - load_balancer_service.hcloud_load_balancer_service.proxyprotocol is sameas false
+ - load_balancer_service is changed
+ - load_balancer_service.hcloud_load_balancer_service.protocol == "http"
+ - load_balancer_service.hcloud_load_balancer_service.listen_port == 80
+ - load_balancer_service.hcloud_load_balancer_service.destination_port == 80
+ - load_balancer_service.hcloud_load_balancer_service.proxyprotocol is sameas false
- name: test create load_balancer service idempotency
- hcloud_load_balancer_service:
+ hetzner.hcloud.load_balancer_service:
load_balancer: "{{hcloud_load_balancer_name}}"
protocol: "http"
listen_port: 80
@@ -66,10 +66,10 @@
- name: verify create load_balancer service idempotency
assert:
that:
- - load_balancer_service is not changed
+ - load_balancer_service is not changed
- name: test update load_balancer service
- hcloud_load_balancer_service:
+ hetzner.hcloud.load_balancer_service:
load_balancer: "{{hcloud_load_balancer_name}}"
protocol: "tcp"
listen_port: 80
@@ -78,14 +78,14 @@
- name: verify create load_balancer service
assert:
that:
- - load_balancer_service is changed
- - load_balancer_service.hcloud_load_balancer_service.protocol == "tcp"
- - load_balancer_service.hcloud_load_balancer_service.listen_port == 80
- - load_balancer_service.hcloud_load_balancer_service.destination_port == 80
- - load_balancer_service.hcloud_load_balancer_service.proxyprotocol is sameas false
+ - load_balancer_service is changed
+ - load_balancer_service.hcloud_load_balancer_service.protocol == "tcp"
+ - load_balancer_service.hcloud_load_balancer_service.listen_port == 80
+ - load_balancer_service.hcloud_load_balancer_service.destination_port == 80
+ - load_balancer_service.hcloud_load_balancer_service.proxyprotocol is sameas false
- name: test absent load_balancer service
- hcloud_load_balancer_service:
+ hetzner.hcloud.load_balancer_service:
load_balancer: "{{hcloud_load_balancer_name}}"
protocol: "http"
listen_port: 80
@@ -94,33 +94,33 @@
- name: verify test absent load_balancer service
assert:
that:
- - result is changed
+ - result is changed
- name: test create load_balancer service with http
- hcloud_load_balancer_service:
+ hetzner.hcloud.load_balancer_service:
load_balancer: "{{hcloud_load_balancer_name}}"
protocol: "http"
listen_port: 80
http:
cookie_name: "Test"
- sticky_sessions: yes
+ sticky_sessions: true
state: present
register: load_balancer_service
- name: verify create load_balancer service
assert:
that:
- - load_balancer_service is changed
- - load_balancer_service.hcloud_load_balancer_service.protocol == "http"
- - load_balancer_service.hcloud_load_balancer_service.listen_port == 80
- - load_balancer_service.hcloud_load_balancer_service.destination_port == 80
- - load_balancer_service.hcloud_load_balancer_service.proxyprotocol is sameas false
+ - load_balancer_service is changed
+ - load_balancer_service.hcloud_load_balancer_service.protocol == "http"
+ - load_balancer_service.hcloud_load_balancer_service.listen_port == 80
+ - load_balancer_service.hcloud_load_balancer_service.destination_port == 80
+ - load_balancer_service.hcloud_load_balancer_service.proxyprotocol is sameas false
- name: cleanup load_balancer
- hcloud_load_balancer:
+ hetzner.hcloud.load_balancer:
name: "{{ hcloud_load_balancer_name }}"
state: absent
register: result
- name: verify cleanup load_balancer
assert:
that:
- - result is success
+ - result is success
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_target/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_target/aliases
new file mode 100644
index 000000000..62828d1e9
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_target/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+azp/group1
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_target/defaults/main/common.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_target/defaults/main/common.yml
new file mode 100644
index 000000000..e316b233c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_target/defaults/main/common.yml
@@ -0,0 +1,12 @@
+#
+# 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('first') | join() }}"
+hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_target/defaults/main/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_target/defaults/main/main.yml
new file mode 100644
index 000000000..2d60910e9
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_target/defaults/main/main.yml
@@ -0,0 +1,7 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_server_name: "{{ hcloud_ns }}"
+hcloud_load_balancer_name: "{{ hcloud_ns }}"
+
+hetzner_server_ip: 142.132.203.104
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_target/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_target/tasks/main.yml
new file mode 100644
index 000000000..767fc465b
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_target/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/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_target/tasks/test.yml
index bd96c1a54..19fd0e9af 100644
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/tasks/main.yml
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_target/tasks/test.yml
@@ -2,10 +2,10 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
- name: setup server
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{hcloud_server_name}}"
server_type: cx11
- image: ubuntu-20.04
+ image: ubuntu-22.04
state: started
location: "fsn1"
register: server
@@ -15,7 +15,7 @@
- server is success
- name: setup load_balancer
- hcloud_load_balancer:
+ hetzner.hcloud.load_balancer:
name: "{{hcloud_load_balancer_name}}"
load_balancer_type: lb11
state: present
@@ -27,7 +27,7 @@
- load_balancer is success
- name: test fail load balancer does not exist
- hetzner.hcloud.hcloud_load_balancer_target:
+ hetzner.hcloud.load_balancer_target:
type: server
load_balancer: does-not-exist
server: "{{ hcloud_server_name }}"
@@ -37,10 +37,10 @@
assert:
that:
- result is failed
- - "result.msg == 'Load balancer does not exist: does-not-exist'"
+ - "result.msg == 'resource (load_balancer) does not exist: does-not-exist'"
- name: test fail server does not exist
- hetzner.hcloud.hcloud_load_balancer_target:
+ hetzner.hcloud.load_balancer_target:
type: server
load_balancer: "{{ hcloud_load_balancer_name }}"
server: does-not-exist
@@ -50,23 +50,23 @@
assert:
that:
- result is failed
- - "result.msg == 'Server not found: does-not-exist'"
+ - "result.msg == 'resource (server) does not exist: does-not-exist'"
- name: test create load_balancer target with checkmode
- hcloud_load_balancer_target:
+ hetzner.hcloud.load_balancer_target:
type: "server"
load_balancer: "{{hcloud_load_balancer_name}}"
server: "{{hcloud_server_name}}"
state: present
register: result
- check_mode: yes
+ check_mode: true
- name: verify test create load_balancer target with checkmode
assert:
that:
- - result is changed
+ - result is changed
- name: test create load_balancer target
- hcloud_load_balancer_target:
+ hetzner.hcloud.load_balancer_target:
type: "server"
load_balancer: "{{hcloud_load_balancer_name}}"
server: "{{hcloud_server_name}}"
@@ -75,13 +75,13 @@
- name: verify create load_balancer target
assert:
that:
- - load_balancer_target is changed
- - load_balancer_target.hcloud_load_balancer_target.type == "server"
- - load_balancer_target.hcloud_load_balancer_target.server == hcloud_server_name
- - load_balancer_target.hcloud_load_balancer_target.load_balancer == hcloud_load_balancer_name
+ - load_balancer_target is changed
+ - load_balancer_target.hcloud_load_balancer_target.type == "server"
+ - load_balancer_target.hcloud_load_balancer_target.server == hcloud_server_name
+ - load_balancer_target.hcloud_load_balancer_target.load_balancer == hcloud_load_balancer_name
- name: test create load_balancer target idempotency
- hcloud_load_balancer_target:
+ hetzner.hcloud.load_balancer_target:
type: "server"
load_balancer: "{{hcloud_load_balancer_name}}"
server: "{{hcloud_server_name}}"
@@ -90,10 +90,10 @@
- name: verify create load_balancer target idempotency
assert:
that:
- - load_balancer_target is not changed
+ - load_balancer_target is not changed
- name: test absent load_balancer target
- hcloud_load_balancer_target:
+ hetzner.hcloud.load_balancer_target:
type: "server"
load_balancer: "{{hcloud_load_balancer_name}}"
server: "{{hcloud_server_name}}"
@@ -102,10 +102,10 @@
- name: verify test absent load_balancer target
assert:
that:
- - result is changed
+ - result is changed
- name: test create label_selector target
- hcloud_load_balancer_target:
+ hetzner.hcloud.load_balancer_target:
type: "label_selector"
load_balancer: "{{hcloud_load_balancer_name}}"
label_selector: "application=backend"
@@ -114,28 +114,28 @@
- name: verify create label_selector target
assert:
that:
- - load_balancer_target is changed
- - load_balancer_target.hcloud_load_balancer_target.type == "label_selector"
- - load_balancer_target.hcloud_load_balancer_target.label_selector == "application=backend"
- - load_balancer_target.hcloud_load_balancer_target.load_balancer == hcloud_load_balancer_name
+ - load_balancer_target is changed
+ - load_balancer_target.hcloud_load_balancer_target.type == "label_selector"
+ - load_balancer_target.hcloud_load_balancer_target.label_selector == "application=backend"
+ - load_balancer_target.hcloud_load_balancer_target.load_balancer == hcloud_load_balancer_name
- name: test create ip target
- hcloud_load_balancer_target:
+ hetzner.hcloud.load_balancer_target:
type: "ip"
- load_balancer: "{{hcloud_load_balancer_name}}"
- ip: "{{hcloud_testing_ip}}"
+ load_balancer: "{{ hcloud_load_balancer_name }}"
+ ip: "{{ hetzner_server_ip }}"
state: present
register: load_balancer_target
- name: verify create ip target
assert:
that:
- - load_balancer_target is changed
- - load_balancer_target.hcloud_load_balancer_target.type == "ip"
- - load_balancer_target.hcloud_load_balancer_target.ip == hcloud_testing_ip
- - load_balancer_target.hcloud_load_balancer_target.load_balancer == hcloud_load_balancer_name
+ - load_balancer_target is changed
+ - load_balancer_target.hcloud_load_balancer_target.type == "ip"
+ - load_balancer_target.hcloud_load_balancer_target.ip == hetzner_server_ip
+ - load_balancer_target.hcloud_load_balancer_target.load_balancer == hcloud_load_balancer_name
- name: cleanup load_balancer
- hcloud_load_balancer:
+ hetzner.hcloud.load_balancer:
name: "{{ hcloud_load_balancer_name }}"
state: absent
register: result
@@ -144,7 +144,7 @@
delay: 2
- name: cleanup
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{hcloud_server_name}}"
state: absent
register: result
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_type_info/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_type_info/aliases
new file mode 100644
index 000000000..0e887600e
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_type_info/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+azp/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_type_info/defaults/main/common.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_type_info/defaults/main/common.yml
new file mode 100644
index 000000000..e316b233c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_type_info/defaults/main/common.yml
@@ -0,0 +1,12 @@
+#
+# 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('first') | join() }}"
+hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_type_info/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_type_info/defaults/main/main.yml
index b7fd86316..473035974 100644
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_type_info/defaults/main.yml
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_type_info/defaults/main/main.yml
@@ -1,5 +1,5 @@
# Copyright: (c) 2020, Hetzner Cloud GmbH <info@hetzner-cloud.de>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
-hcloud_load_balancer_type_name: "lb11"
hcloud_load_balancer_type_id: 1
+hcloud_load_balancer_type_name: lb11
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_type_info/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_type_info/tasks/main.yml
new file mode 100644
index 000000000..767fc465b
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_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/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_type_info/tasks/test.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_type_info/tasks/test.yml
new file mode 100644
index 000000000..980b8a274
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/load_balancer_type_info/tasks/test.yml
@@ -0,0 +1,56 @@
+# Copyright: (c) 2020, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: Gather hcloud_load_balancer_type_info
+ hetzner.hcloud.load_balancer_type_info:
+ register: result
+- name: Verify hcloud_load_balancer_type_info
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_load_balancer_type_info | list | count >= 1
+
+- name: Gather hcloud_load_balancer_type_info in check mode
+ hetzner.hcloud.load_balancer_type_info:
+ check_mode: true
+ register: result
+- name: Verify hcloud_load_balancer_type_info in check mode
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_load_balancer_type_info | list | count >= 1
+
+- name: Gather hcloud_load_balancer_type_info with correct id
+ hetzner.hcloud.load_balancer_type_info:
+ id: "{{ hcloud_load_balancer_type_id }}"
+ register: result
+- name: Verify hcloud_load_balancer_type_info with correct id
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_load_balancer_type_info | list | count == 1
+
+- name: Gather hcloud_load_balancer_type_info with wrong id
+ hetzner.hcloud.load_balancer_type_info:
+ id: "{{ hcloud_load_balancer_type_id }}4321"
+ ignore_errors: true
+ register: result
+- name: Verify hcloud_load_balancer_type_info with wrong id
+ ansible.builtin.assert:
+ that:
+ - result is failed
+
+- name: Gather hcloud_load_balancer_type_info with correct name
+ hetzner.hcloud.load_balancer_type_info:
+ name: "{{ hcloud_load_balancer_type_name }}"
+ register: result
+- name: Verify hcloud_load_balancer_type_info with correct name
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_load_balancer_type_info | list | count == 1
+
+- name: Gather hcloud_load_balancer_type_info with wrong name
+ hetzner.hcloud.load_balancer_type_info:
+ name: "{{ hcloud_load_balancer_type_name }}-invalid"
+ register: result
+- name: Verify hcloud_load_balancer_type_info with wrong name
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_load_balancer_type_info | list | count == 0
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/location_info/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/location_info/aliases
new file mode 100644
index 000000000..a6a90a6bf
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/location_info/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+azp/group3
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/location_info/defaults/main/common.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/location_info/defaults/main/common.yml
new file mode 100644
index 000000000..e316b233c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/location_info/defaults/main/common.yml
@@ -0,0 +1,12 @@
+#
+# 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('first') | join() }}"
+hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/location_info/defaults/main/main.yml
index 0d72a75c2..72f0db5bc 100644
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/defaults/main.yml
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/location_info/defaults/main/main.yml
@@ -1,5 +1,5 @@
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
-hcloud_location_name: "fsn1"
hcloud_location_id: 1
+hcloud_location_name: fsn1
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/location_info/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/location_info/tasks/main.yml
new file mode 100644
index 000000000..767fc465b
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/location_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/ansible_collections/hetzner/hcloud/tests/integration/targets/location_info/tasks/test.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/location_info/tasks/test.yml
new file mode 100644
index 000000000..12ad679b8
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/location_info/tasks/test.yml
@@ -0,0 +1,56 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: Gather hcloud_location_info
+ hetzner.hcloud.location_info:
+ register: result
+- name: Verify hcloud_location_info
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_location_info | list | count >= 5
+
+- name: Gather hcloud_location_info in check mode
+ hetzner.hcloud.location_info:
+ check_mode: true
+ register: result
+- name: Verify hcloud_location_info in check mode
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_location_info | list | count >= 5
+
+- name: Gather hcloud_location_info with correct id
+ hetzner.hcloud.location_info:
+ id: "{{ hcloud_location_id }}"
+ register: result
+- name: Verify hcloud_location_info with correct id
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_location_info | list | count == 1
+
+- name: Gather hcloud_location_info with wrong id
+ hetzner.hcloud.location_info:
+ id: "{{ hcloud_location_id }}4321"
+ ignore_errors: true
+ register: result
+- name: Verify hcloud_location_info with wrong id
+ ansible.builtin.assert:
+ that:
+ - result is failed
+
+- name: Gather hcloud_location_info with correct name
+ hetzner.hcloud.location_info:
+ name: "{{ hcloud_location_name }}"
+ register: result
+- name: Verify hcloud_location_info with correct name
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_location_info | list | count == 1
+
+- name: Gather hcloud_location_info with wrong name
+ hetzner.hcloud.location_info:
+ name: "{{ hcloud_location_name }}-invalid"
+ register: result
+- name: Verify hcloud_location_info with wrong name
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_location_info | list | count == 0
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/network/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/network/aliases
new file mode 100644
index 000000000..f150235ee
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/network/aliases
@@ -0,0 +1,3 @@
+cloud/hcloud
+azp/group1
+disabled
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/network/defaults/main/common.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/network/defaults/main/common.yml
new file mode 100644
index 000000000..e316b233c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/network/defaults/main/common.yml
@@ -0,0 +1,12 @@
+#
+# 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('first') | join() }}"
+hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/network/defaults/main/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/network/defaults/main/main.yml
new file mode 100644
index 000000000..a8320602c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/network/defaults/main/main.yml
@@ -0,0 +1,5 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_network_name: "{{ hcloud_ns }}"
+hcloud_network_name_with_vswitch: "{{ hcloud_ns }}-vswitch"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/network/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/network/tasks/main.yml
new file mode 100644
index 000000000..767fc465b
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/network/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/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/network/tasks/test.yml
index 6c40e4e01..b4f3de284 100644
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/tasks/main.yml
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/network/tasks/test.yml
@@ -1,21 +1,19 @@
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
-- name: setup
- hcloud_network:
- name: "{{ hcloud_network_name }}"
+- name: setup ensure network is absent
+ hetzner.hcloud.network:
+ name: "{{ item }}"
state: absent
- register: result
-- name: verify setup
- assert:
- that:
- - result is success
+ with_items:
+ - "{{ hcloud_network_name }}"
+ - "{{ hcloud_network_name_with_vswitch }}"
- name: test missing ip_range parameter on create Network
- hcloud_network:
+ hetzner.hcloud.network:
name: "{{hcloud_network_name}}"
register: result
- ignore_errors: yes
+ ignore_errors: true
- name: verify fail missing ip_range parameter on create Network result
assert:
that:
@@ -23,18 +21,18 @@
- 'result.msg == "missing required arguments: ip_range"'
- name: test create Network with check mode
- hcloud_network:
+ hetzner.hcloud.network:
name: "{{hcloud_network_name}}"
ip_range: "10.0.0.0/16"
register: result
- check_mode: yes
+ check_mode: true
- name: verify create Network with check mode result
assert:
that:
- result is changed
- name: test create Network
- hcloud_network:
+ hetzner.hcloud.network:
name: "{{hcloud_network_name}}"
ip_range: "10.0.0.0/16"
register: network
@@ -42,11 +40,11 @@
assert:
that:
- network is changed
- - network.hcloud_network.name == "{{hcloud_network_name}}"
+ - network.hcloud_network.name == hcloud_network_name
- network.hcloud_network.ip_range == "10.0.0.0/16"
- name: test create Network idempotence
- hcloud_network:
+ hetzner.hcloud.network:
name: "{{hcloud_network_name}}"
ip_range: "10.0.0.0/16"
register: network
@@ -55,8 +53,33 @@
that:
- network is not changed
+- name: test create Network with expose_routes_to_vswitch
+ hetzner.hcloud.network:
+ name: "{{hcloud_network_name_with_vswitch}}"
+ ip_range: "10.0.0.0/16"
+ expose_routes_to_vswitch: true
+ register: network
+- name: verify test create Network with vSwitch result
+ assert:
+ that:
+ - network is changed
+ - network.hcloud_network.name == hcloud_network_name_with_vswitch
+ - network.hcloud_network.ip_range == "10.0.0.0/16"
+ - network.hcloud_network.expose_routes_to_vswitch is true
+
+- name: test create Network with expose_routes_to_vswitch idempotence
+ hetzner.hcloud.network:
+ name: "{{hcloud_network_name_with_vswitch}}"
+ ip_range: "10.0.0.0/16"
+ expose_routes_to_vswitch: true
+ register: network
+- name: verify test create network idempotency
+ assert:
+ that:
+ - network is not changed
+
- name: test update Network label
- hcloud_network:
+ hetzner.hcloud.network:
name: "{{hcloud_network_name}}"
labels:
key: value
@@ -68,7 +91,7 @@
- network.hcloud_network.labels.key == "value"
- name: test update Network label idempotency
- hcloud_network:
+ hetzner.hcloud.network:
name: "{{hcloud_network_name}}"
labels:
key: value
@@ -79,7 +102,7 @@
- network is not changed
- name: test update Network ip range
- hcloud_network:
+ hetzner.hcloud.network:
name: "{{hcloud_network_name}}"
ip_range: "10.0.0.0/8"
register: network
@@ -90,7 +113,7 @@
- network.hcloud_network.ip_range == "10.0.0.0/8"
- name: test update Network ip range idempotency
- hcloud_network:
+ hetzner.hcloud.network:
name: "{{hcloud_network_name}}"
ip_range: "10.0.0.0/8"
register: network
@@ -99,8 +122,29 @@
that:
- network is not changed
+- name: test update Network expose_routes_to_vswitch
+ hetzner.hcloud.network:
+ name: "{{hcloud_network_name_with_vswitch}}"
+ expose_routes_to_vswitch: false
+ register: network
+- name: verify test update Network expose_routes_to_vswitch
+ assert:
+ that:
+ - network is changed
+ - network.hcloud_network.expose_routes_to_vswitch is false
+
+- name: test update Network expose_routes_to_vswitch idempotency
+ hetzner.hcloud.network:
+ name: "{{hcloud_network_name_with_vswitch}}"
+ expose_routes_to_vswitch: false
+ register: network
+- name: verify test update Network expose_routes_to_vswitch idempotency
+ assert:
+ that:
+ - network is not changed
+
- name: test update Network delete protection
- hcloud_network:
+ hetzner.hcloud.network:
name: "{{hcloud_network_name}}"
ip_range: "10.0.0.0/8"
delete_protection: true
@@ -112,7 +156,7 @@
- network.hcloud_network.delete_protection is sameas true
- name: test update Network delete protection idempotency
- hcloud_network:
+ hetzner.hcloud.network:
name: "{{hcloud_network_name}}"
ip_range: "10.0.0.0/8"
delete_protection: true
@@ -124,7 +168,7 @@
- network.hcloud_network.delete_protection is sameas true
- name: test Network without delete protection set to be idempotent
- hcloud_network:
+ hetzner.hcloud.network:
name: "{{hcloud_network_name}}"
ip_range: "10.0.0.0/8"
register: network
@@ -135,10 +179,10 @@
- network.hcloud_network.delete_protection is sameas true
- name: test delete Network fails if it is protected
- hcloud_network:
+ hetzner.hcloud.network:
name: "{{hcloud_network_name}}"
state: absent
- ignore_errors: yes
+ ignore_errors: true
register: result
- name: verify delete Network
assert:
@@ -147,7 +191,7 @@
- 'result.msg == "network deletion is protected"'
- name: test update Network delete protection
- hcloud_network:
+ hetzner.hcloud.network:
name: "{{hcloud_network_name}}"
ip_range: "10.0.0.0/8"
delete_protection: false
@@ -159,7 +203,7 @@
- network.hcloud_network.delete_protection is sameas false
- name: test delete Network
- hcloud_network:
+ hetzner.hcloud.network:
name: "{{hcloud_network_name}}"
state: absent
register: result
@@ -168,9 +212,8 @@
that:
- result is success
-
- name: test create Network with delete protection
- hcloud_network:
+ hetzner.hcloud.network:
name: "{{hcloud_network_name}}"
ip_range: "10.0.0.0/8"
delete_protection: true
@@ -182,10 +225,10 @@
- network.hcloud_network.delete_protection is sameas true
- name: test delete Network fails if it is protected
- hcloud_network:
+ hetzner.hcloud.network:
name: "{{hcloud_network_name}}"
state: absent
- ignore_errors: yes
+ ignore_errors: true
register: result
- name: verify delete Network
assert:
@@ -194,7 +237,7 @@
- 'result.msg == "network deletion is protected"'
- name: test update Network delete protection
- hcloud_network:
+ hetzner.hcloud.network:
name: "{{hcloud_network_name}}"
delete_protection: false
register: network
@@ -205,7 +248,7 @@
- network.hcloud_network.delete_protection is sameas false
- name: test delete Network
- hcloud_network:
+ hetzner.hcloud.network:
name: "{{hcloud_network_name}}"
state: absent
register: result
@@ -213,3 +256,13 @@
assert:
that:
- result is success
+
+- name: test delete Network with expose_routes_to_vswitch
+ hetzner.hcloud.network:
+ name: "{{hcloud_network_name_with_vswitch}}"
+ state: absent
+ register: result
+- name: verify delete Network with expose_routes_to_vswitch
+ assert:
+ that:
+ - result is success
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/network_info/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/network_info/aliases
new file mode 100644
index 000000000..62828d1e9
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/network_info/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+azp/group1
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/network_info/defaults/main/common.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/network_info/defaults/main/common.yml
new file mode 100644
index 000000000..e316b233c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/network_info/defaults/main/common.yml
@@ -0,0 +1,12 @@
+#
+# 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('first') | join() }}"
+hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/network_info/defaults/main/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/network_info/defaults/main/main.yml
new file mode 100644
index 000000000..a01c6d60c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/network_info/defaults/main/main.yml
@@ -0,0 +1,4 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_network_name: "{{ hcloud_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/network_info/tasks/cleanup.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/network_info/tasks/cleanup.yml
new file mode 100644
index 000000000..989d01b80
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/network_info/tasks/cleanup.yml
@@ -0,0 +1,5 @@
+---
+- name: Cleanup test_network
+ hetzner.hcloud.network:
+ name: "{{ hcloud_network_name }}"
+ state: absent
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/network_info/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/network_info/tasks/main.yml
new file mode 100644
index 000000000..767fc465b
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/network_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/ansible_collections/hetzner/hcloud/tests/integration/targets/network_info/tasks/prepare.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/network_info/tasks/prepare.yml
new file mode 100644
index 000000000..9a6e61862
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/network_info/tasks/prepare.yml
@@ -0,0 +1,23 @@
+---
+- name: Create test_network
+ hetzner.hcloud.network:
+ name: "{{ hcloud_network_name }}"
+ ip_range: 10.0.0.0/16
+ labels:
+ key: value
+ register: test_network
+
+- name: Create test_subnetwork
+ hetzner.hcloud.subnetwork:
+ network: "{{ hcloud_network_name }}"
+ type: server
+ network_zone: eu-central
+ ip_range: 10.0.1.0/24
+ register: test_subnetwork
+
+- name: Create test_route
+ hetzner.hcloud.route:
+ network: "{{ hcloud_network_name }}"
+ destination: 10.0.3.0/24
+ gateway: 10.0.2.1
+ register: test_route
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/network_info/tasks/test.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/network_info/tasks/test.yml
new file mode 100644
index 000000000..cf7367d5f
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/network_info/tasks/test.yml
@@ -0,0 +1,79 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: Gather hcloud_network_info
+ hetzner.hcloud.network_info:
+ register: result
+- name: Verify hcloud_network_info
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_network_info | list | count >= 1
+
+- name: Gather hcloud_network_info in check mode
+ hetzner.hcloud.network_info:
+ check_mode: true
+ register: result
+- name: Verify hcloud_network_info in check mode
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_network_info | list | count >= 1
+
+- name: Gather hcloud_network_info with correct id
+ hetzner.hcloud.network_info:
+ id: "{{ test_network.hcloud_network.id }}"
+ register: result
+- name: Verify hcloud_network_info with correct id
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_network_info | list | count == 1
+ - result.hcloud_network_info[0].subnetworks | list | count >= 1
+ - result.hcloud_network_info[0].routes | list | count >= 1
+
+- name: Gather hcloud_network_info with wrong id
+ hetzner.hcloud.network_info:
+ id: "{{ test_network.hcloud_network.id }}4321"
+ ignore_errors: true
+ register: result
+- name: Verify hcloud_network_info with wrong id
+ ansible.builtin.assert:
+ that:
+ - result is failed
+
+- name: Gather hcloud_network_info with correct name
+ hetzner.hcloud.network_info:
+ name: "{{ hcloud_network_name }}"
+ register: result
+- name: Verify hcloud_network_info with correct name
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_network_info | list | count == 1
+
+- name: Gather hcloud_network_info with wrong name
+ hetzner.hcloud.network_info:
+ name: "{{ hcloud_network_name }}-invalid"
+ register: result
+- name: Verify hcloud_network_info with wrong name
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_network_info | list | count == 0
+
+- name: Gather hcloud_network_info with correct label selector
+ hetzner.hcloud.network_info:
+ label_selector: "key=value"
+ register: result
+- name: Verify hcloud_network_info with correct label selector
+ ansible.builtin.assert:
+ that:
+ - >
+ result.hcloud_network_info
+ | selectattr('name', 'equalto', hcloud_network_name)
+ | list | count == 1
+
+- name: Gather hcloud_network_info with wrong label selector
+ hetzner.hcloud.network_info:
+ label_selector: "key!=value"
+ register: result
+- name: Verify hcloud_network_info with wrong label selector
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_network_info | list | count == 0
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/placement_group/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/placement_group/aliases
new file mode 100644
index 000000000..0e887600e
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/placement_group/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+azp/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/placement_group/defaults/main/common.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/placement_group/defaults/main/common.yml
new file mode 100644
index 000000000..e316b233c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/placement_group/defaults/main/common.yml
@@ -0,0 +1,12 @@
+#
+# 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('first') | join() }}"
+hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/placement_group/defaults/main/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/placement_group/defaults/main/main.yml
new file mode 100644
index 000000000..a4439afbd
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/placement_group/defaults/main/main.yml
@@ -0,0 +1,6 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_placement_group_name: "{{ hcloud_ns }}"
+hcloud_server_name: "{{ hcloud_ns }}"
+hcloud_ssh_key_name: "{{ hcloud_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/placement_group/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/placement_group/meta/main.yml
new file mode 100644
index 000000000..3a96ecb2d
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/placement_group/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_ssh_keypair
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/placement_group/tasks/cleanup.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/placement_group/tasks/cleanup.yml
new file mode 100644
index 000000000..8066c4115
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/placement_group/tasks/cleanup.yml
@@ -0,0 +1,5 @@
+---
+- name: Cleanup test_ssh_key
+ hetzner.hcloud.ssh_key:
+ name: "{{ hcloud_ssh_key_name }}"
+ state: absent
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/placement_group/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/placement_group/tasks/main.yml
new file mode 100644
index 000000000..767fc465b
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/placement_group/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/ansible_collections/hetzner/hcloud/tests/integration/targets/placement_group/tasks/prepare.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/placement_group/tasks/prepare.yml
new file mode 100644
index 000000000..4bdb95996
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/placement_group/tasks/prepare.yml
@@ -0,0 +1,6 @@
+---
+- name: Create test_ssh_key
+ hetzner.hcloud.ssh_key:
+ name: "{{ hcloud_ssh_key_name }}"
+ public_key: "{{ test_ssh_keypair.public_key }}"
+ register: test_ssh_key
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_placement_group/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/placement_group/tasks/test.yml
index d79aa0c35..3694c846f 100644
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_placement_group/tasks/main.yml
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/placement_group/tasks/test.yml
@@ -2,19 +2,19 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
- name: setup placement group to be absent
- hcloud_placement_group:
+ hetzner.hcloud.placement_group:
name: "{{ hcloud_placement_group_name }}"
state: absent
- name: setup server to be absent
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
state: absent
- name: test missing required parameters on create placement group
- hcloud_placement_group:
+ hetzner.hcloud.placement_group:
register: result
- ignore_errors: yes
+ ignore_errors: true
- name: verify fail test missing required parameters on create placement group
assert:
that:
@@ -22,18 +22,18 @@
- 'result.msg == "one of the following is required: id, name"'
- name: test create placement group with check mode
- hcloud_placement_group:
+ hetzner.hcloud.placement_group:
name: "{{ hcloud_placement_group_name }}"
type: spread
register: result
- check_mode: yes
+ check_mode: true
- name: test create placement group with check mode
assert:
that:
- result is changed
- name: test create placement group
- hcloud_placement_group:
+ hetzner.hcloud.placement_group:
name: "{{ hcloud_placement_group_name }}"
type: spread
labels:
@@ -44,12 +44,12 @@
assert:
that:
- placement_group is changed
- - placement_group.hcloud_placement_group.name == "{{ hcloud_placement_group_name }}"
+ - placement_group.hcloud_placement_group.name == hcloud_placement_group_name
- placement_group.hcloud_placement_group.type == "spread"
- placement_group.hcloud_placement_group.servers | list | count == 0
- name: test create placement group idempotence
- hcloud_placement_group:
+ hetzner.hcloud.placement_group:
name: "{{ hcloud_placement_group_name }}"
type: spread
labels:
@@ -62,23 +62,23 @@
- result is not changed
- name: test create server with placement group
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
server_type: cpx11
placement_group: "{{ hcloud_placement_group_name }}"
- image: "ubuntu-20.04"
+ image: "ubuntu-22.04"
ssh_keys:
- - ci@ansible.hetzner.cloud
+ - "{{ hcloud_ssh_key_name }}"
state: present
register: server
- name: verify create server with placement group
assert:
that:
- server is changed
- - server.hcloud_server.placement_group == "{{ hcloud_placement_group_name }}"
+ - server.hcloud_server.placement_group == hcloud_placement_group_name
- name: test remove server from placement group
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
placement_group: null
state: present
@@ -90,7 +90,7 @@
- result.hcloud_server.placement_group == None
- name: test add server to placement group
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
placement_group: "{{ hcloud_placement_group_name }}"
force: True
@@ -100,11 +100,11 @@
assert:
that:
- result is changed
- - result.hcloud_server.placement_group == "{{ hcloud_placement_group_name }}"
+ - result.hcloud_server.placement_group == hcloud_placement_group_name
- result.hcloud_server.status == "running"
- name: test add server to placement group idempotence
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
placement_group: "{{ hcloud_placement_group_name }}"
force: True
@@ -114,22 +114,22 @@
assert:
that:
- result is not changed
- - result.hcloud_server.placement_group == "{{ hcloud_placement_group_name }}"
+ - result.hcloud_server.placement_group == hcloud_placement_group_name
- result.hcloud_server.status == "running"
- name: test update placement group with check mode
- hcloud_placement_group:
+ hetzner.hcloud.placement_group:
id: "{{ placement_group.hcloud_placement_group.id }}"
name: "changed-{{ hcloud_placement_group_name }}"
register: result
- check_mode: yes
+ check_mode: true
- name: verify update placement group with check mode
assert:
that:
- result is changed
- name: test update placement group
- hcloud_placement_group:
+ hetzner.hcloud.placement_group:
id: "{{ placement_group.hcloud_placement_group.id }}"
name: "changed-{{ hcloud_placement_group_name }}"
labels:
@@ -142,7 +142,7 @@
- result.hcloud_placement_group.name == "changed-{{ hcloud_placement_group_name }}"
- name: test update placement group idempotence
- hcloud_placement_group:
+ hetzner.hcloud.placement_group:
id: "{{ placement_group.hcloud_placement_group.id }}"
name: "changed-{{ hcloud_placement_group_name }}"
labels:
@@ -154,12 +154,12 @@
- result is not changed
- name: absent server
- hcloud_server:
+ hetzner.hcloud.server:
id: "{{ server.hcloud_server.id }}"
state: absent
- name: absent placement group
- hcloud_placement_group:
+ hetzner.hcloud.placement_group:
id: "{{ placement_group.hcloud_placement_group.id }}"
state: absent
register: result
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip/aliases
new file mode 100644
index 000000000..a6a90a6bf
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+azp/group3
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip/defaults/main/common.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip/defaults/main/common.yml
new file mode 100644
index 000000000..e316b233c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip/defaults/main/common.yml
@@ -0,0 +1,12 @@
+#
+# 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('first') | join() }}"
+hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip/defaults/main/main.yml
index ebf456312..7944d5b25 100644
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/defaults/main.yml
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip/defaults/main/main.yml
@@ -1,5 +1,5 @@
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
-hcloud_prefix: "tests"
-hcloud_load_balancer_name: "{{hcloud_prefix}}-lb-target"
+hcloud_primary_ip_name: "{{ hcloud_ns }}"
+hcloud_server_name: "{{ hcloud_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip/tasks/main.yml
new file mode 100644
index 000000000..767fc465b
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip/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/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_primary_ip/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip/tasks/test.yml
index d4efc606b..4c0fd2e5f 100644
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_primary_ip/tasks/main.yml
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip/tasks/test.yml
@@ -1,20 +1,25 @@
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
+- name: setup ensure primary ip is absent
+ hetzner.hcloud.primary_ip:
+ name: "{{ hcloud_primary_ip_name }}"
+ state: absent
+
- name: test create Primary IP with check mode
- hcloud_primary_ip:
+ hetzner.hcloud.primary_ip:
name: "{{ hcloud_primary_ip_name }}"
type: ipv4
datacenter: "fsn1-dc14"
register: primaryIP
- check_mode: yes
+ check_mode: true
- name: verify test create Primary IP with check mode
assert:
that:
- primaryIP is changed
- name: test create Primary IP
- hcloud_primary_ip:
+ hetzner.hcloud.primary_ip:
name: "{{ hcloud_primary_ip_name }}"
type: ipv4
datacenter: "fsn1-dc14"
@@ -27,7 +32,7 @@
- primaryIP.hcloud_primary_ip.datacenter == "fsn1-dc14"
- name: test create Primary IP idempotency
- hcloud_primary_ip:
+ hetzner.hcloud.primary_ip:
name: "{{ hcloud_primary_ip_name }}"
type: ipv4
datacenter: "fsn1-dc14"
@@ -38,7 +43,7 @@
- primaryIP is not changed
- name: test update Primary IP
- hcloud_primary_ip:
+ hetzner.hcloud.primary_ip:
name: "{{ hcloud_primary_ip_name }}"
type: ipv4
datacenter: "fsn1-dc14"
@@ -51,7 +56,7 @@
- primaryIP is changed
- name: test update Primary IP idempotency
- hcloud_primary_ip:
+ hetzner.hcloud.primary_ip:
name: "{{ hcloud_primary_ip_name }}"
type: ipv4
datacenter: "fsn1-dc14"
@@ -64,7 +69,7 @@
- primaryIP is not changed
- name: test update Primary IP with same labels
- hcloud_primary_ip:
+ hetzner.hcloud.primary_ip:
name: "{{ hcloud_primary_ip_name }}"
type: ipv4
datacenter: "fsn1-dc14"
@@ -77,7 +82,7 @@
- primaryIP is not changed
- name: test update Primary IP with other labels
- hcloud_primary_ip:
+ hetzner.hcloud.primary_ip:
name: "{{ hcloud_primary_ip_name }}"
type: ipv4
datacenter: "fsn1-dc14"
@@ -91,7 +96,7 @@
- primaryIP is changed
- name: test update Primary IP with other labels in different order
- hcloud_primary_ip:
+ hetzner.hcloud.primary_ip:
name: "{{ hcloud_primary_ip_name }}"
type: ipv4
datacenter: "fsn1-dc14"
@@ -105,7 +110,7 @@
- primaryIP is not changed
- name: test update Primary IP delete protection
- hcloud_primary_ip:
+ hetzner.hcloud.primary_ip:
name: "{{ hcloud_primary_ip_name }}"
type: ipv4
delete_protection: true
@@ -117,7 +122,7 @@
- primaryIP.hcloud_primary_ip.delete_protection is sameas true
- name: test update Primary IP delete protection idempotency
- hcloud_primary_ip:
+ hetzner.hcloud.primary_ip:
name: "{{ hcloud_primary_ip_name }}"
type: ipv4
delete_protection: true
@@ -129,7 +134,7 @@
- primaryIP.hcloud_primary_ip.delete_protection is sameas true
- name: test Primary IP without delete protection set to be idempotent
- hcloud_primary_ip:
+ hetzner.hcloud.primary_ip:
name: "{{ hcloud_primary_ip_name }}"
type: ipv4
register: primaryIP
@@ -140,11 +145,11 @@
- primaryIP.hcloud_primary_ip.delete_protection is sameas true
- name: test delete Primary IP fails if it is protected
- hcloud_primary_ip:
+ hetzner.hcloud.primary_ip:
name: "{{ hcloud_primary_ip_name }}"
state: "absent"
register: result
- ignore_errors: yes
+ ignore_errors: true
- name: verify test delete primary ip
assert:
that:
@@ -152,7 +157,7 @@
- 'result.msg == "Primary IP deletion is protected"'
- name: test update Primary IP delete protection
- hcloud_primary_ip:
+ hetzner.hcloud.primary_ip:
name: "{{ hcloud_primary_ip_name }}"
type: ipv4
delete_protection: false
@@ -164,7 +169,7 @@
- primaryIP.hcloud_primary_ip.delete_protection is sameas false
- name: test delete primary ip
- hcloud_primary_ip:
+ hetzner.hcloud.primary_ip:
name: "{{ hcloud_primary_ip_name }}"
state: "absent"
register: result
@@ -174,7 +179,7 @@
- result is changed
- name: test create ipv6 primary ip
- hcloud_primary_ip:
+ hetzner.hcloud.primary_ip:
name: "{{ hcloud_primary_ip_name }}"
type: ipv6
datacenter: "fsn1-dc14"
@@ -186,7 +191,7 @@
- result is changed
- name: test delete ipv6 primary ip
- hcloud_primary_ip:
+ hetzner.hcloud.primary_ip:
name: "{{ hcloud_primary_ip_name }}"
state: "absent"
register: result
@@ -196,7 +201,7 @@
- result is changed
- name: test create Primary IP with delete protection
- hcloud_primary_ip:
+ hetzner.hcloud.primary_ip:
name: "{{ hcloud_primary_ip_name }}"
type: ipv4
datacenter: fsn1-dc14
@@ -209,11 +214,11 @@
- primaryIP.hcloud_primary_ip.delete_protection is sameas true
- name: test delete Primary IP fails if it is protected
- hcloud_primary_ip:
+ hetzner.hcloud.primary_ip:
name: "{{ hcloud_primary_ip_name }}"
state: "absent"
register: result
- ignore_errors: yes
+ ignore_errors: true
- name: verify test delete primary ip
assert:
that:
@@ -221,7 +226,7 @@
- 'result.msg == "Primary IP deletion is protected"'
- name: test update Primary IP delete protection
- hcloud_primary_ip:
+ hetzner.hcloud.primary_ip:
name: "{{ hcloud_primary_ip_name }}"
type: ipv4
delete_protection: false
@@ -233,7 +238,7 @@
- primaryIP.hcloud_primary_ip.delete_protection is sameas false
- name: test delete primary ip
- hcloud_primary_ip:
+ hetzner.hcloud.primary_ip:
name: "{{ hcloud_primary_ip_name }}"
state: "absent"
register: result
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip_info/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip_info/aliases
new file mode 100644
index 000000000..a6a90a6bf
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip_info/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+azp/group3
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip_info/defaults/main/common.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip_info/defaults/main/common.yml
new file mode 100644
index 000000000..e316b233c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip_info/defaults/main/common.yml
@@ -0,0 +1,12 @@
+#
+# 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('first') | join() }}"
+hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip_info/defaults/main/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip_info/defaults/main/main.yml
new file mode 100644
index 000000000..9527ca2cd
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip_info/defaults/main/main.yml
@@ -0,0 +1,4 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_primary_ip_name: "{{ hcloud_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip_info/tasks/cleanup.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip_info/tasks/cleanup.yml
new file mode 100644
index 000000000..8fc48059e
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip_info/tasks/cleanup.yml
@@ -0,0 +1,5 @@
+---
+- name: Cleanup test_primary_ip
+ hetzner.hcloud.primary_ip:
+ name: "{{ hcloud_primary_ip_name }}"
+ state: absent
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip_info/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip_info/tasks/main.yml
new file mode 100644
index 000000000..767fc465b
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip_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/ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip_info/tasks/prepare.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip_info/tasks/prepare.yml
new file mode 100644
index 000000000..4c96ee87d
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip_info/tasks/prepare.yml
@@ -0,0 +1,9 @@
+---
+- name: Create test_primary_ip
+ hetzner.hcloud.primary_ip:
+ name: "{{ hcloud_primary_ip_name }}"
+ datacenter: fsn1-dc14
+ type: ipv4
+ labels:
+ key: value
+ register: test_primary_ip
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip_info/tasks/test.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip_info/tasks/test.yml
new file mode 100644
index 000000000..902e34153
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/primary_ip_info/tasks/test.yml
@@ -0,0 +1,77 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: Gather hcloud_primary_ip_info
+ hetzner.hcloud.primary_ip_info:
+ register: result
+- name: Verify hcloud_primary_ip_info
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_primary_ip_info | list | count >= 1
+
+- name: Gather hcloud_primary_ip_info in check mode
+ hetzner.hcloud.primary_ip_info:
+ check_mode: true
+ register: result
+- name: Verify hcloud_primary_ip_info in check mode
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_primary_ip_info | list | count >= 1
+
+- name: Gather hcloud_primary_ip_info with correct id
+ hetzner.hcloud.primary_ip_info:
+ id: "{{ test_primary_ip.hcloud_primary_ip.id }}"
+ register: result
+- name: Verify hcloud_primary_ip_info with correct id
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_primary_ip_info | list | count == 1
+
+- name: Gather hcloud_primary_ip_info with wrong id
+ hetzner.hcloud.primary_ip_info:
+ id: "{{ test_primary_ip.hcloud_primary_ip.id }}4321"
+ ignore_errors: true
+ register: result
+- name: Verify hcloud_primary_ip_info with wrong id
+ ansible.builtin.assert:
+ that:
+ - result is failed
+
+- name: Gather hcloud_primary_ip_info with correct name
+ hetzner.hcloud.primary_ip_info:
+ name: "{{ hcloud_primary_ip_name }}"
+ register: result
+- name: Verify hcloud_primary_ip_info with correct name
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_primary_ip_info | list | count == 1
+
+- name: Gather hcloud_primary_ip_info with wrong name
+ hetzner.hcloud.primary_ip_info:
+ name: "{{ hcloud_primary_ip_name }}-invalid"
+ register: result
+- name: Verify hcloud_primary_ip_info with wrong name
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_primary_ip_info | list | count == 0
+
+- name: Gather hcloud_primary_ip_info with correct label selector
+ hetzner.hcloud.primary_ip_info:
+ label_selector: "key=value"
+ register: result
+- name: Verify hcloud_primary_ip_info with correct label selector
+ ansible.builtin.assert:
+ that:
+ - >
+ result.hcloud_primary_ip_info
+ | selectattr('name', 'equalto', hcloud_primary_ip_name)
+ | list | count == 1
+
+- name: Gather hcloud_primary_ip_info with wrong label selector
+ hetzner.hcloud.primary_ip_info:
+ label_selector: "key!=value"
+ register: result
+- name: Verify hcloud_primary_ip_info with wrong label selector
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_primary_ip_info | list | count == 0
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/rdns/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/rdns/aliases
new file mode 100644
index 000000000..62828d1e9
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/rdns/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+azp/group1
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/rdns/defaults/main/common.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/rdns/defaults/main/common.yml
new file mode 100644
index 000000000..e316b233c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/rdns/defaults/main/common.yml
@@ -0,0 +1,12 @@
+#
+# 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('first') | join() }}"
+hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/rdns/defaults/main/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/rdns/defaults/main/main.yml
new file mode 100644
index 000000000..6249a9bd6
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/rdns/defaults/main/main.yml
@@ -0,0 +1,8 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_server_name: "{{ hcloud_ns }}"
+hcloud_floating_ip_name: "{{ hcloud_ns }}"
+hcloud_primary_ip_name: "{{ hcloud_ns }}"
+hcloud_load_balancer_name: "{{ hcloud_ns }}"
+hcloud_ssh_key_name: "{{ hcloud_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/rdns/tasks/cleanup.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/rdns/tasks/cleanup.yml
new file mode 100644
index 000000000..0df360a33
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/rdns/tasks/cleanup.yml
@@ -0,0 +1,20 @@
+---
+- name: Cleanup test_server
+ hetzner.hcloud.server:
+ name: "{{ hcloud_server_name }}"
+ state: absent
+
+- name: Cleanup test_primary_ip
+ hetzner.hcloud.primary_ip:
+ name: "{{ hcloud_primary_ip_name }}"
+ state: absent
+
+- name: Cleanup test_floating_ip
+ hetzner.hcloud.floating_ip:
+ name: "{{ hcloud_floating_ip_name }}"
+ state: absent
+
+- name: Cleanup test_load_balancer
+ hetzner.hcloud.load_balancer:
+ name: "{{ hcloud_load_balancer_name }}"
+ state: absent
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/rdns/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/rdns/tasks/main.yml
new file mode 100644
index 000000000..767fc465b
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/rdns/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/ansible_collections/hetzner/hcloud/tests/integration/targets/rdns/tasks/prepare.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/rdns/tasks/prepare.yml
new file mode 100644
index 000000000..ea36b6dbc
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/rdns/tasks/prepare.yml
@@ -0,0 +1,32 @@
+---
+- name: Create test_server
+ hetzner.hcloud.server:
+ name: "{{ hcloud_server_name }}"
+ server_type: cx11
+ image: ubuntu-22.04
+ state: present
+ register: test_server
+
+- name: Create test_primary_ip
+ hetzner.hcloud.primary_ip:
+ name: "{{ hcloud_primary_ip_name }}"
+ type: ipv4
+ datacenter: fsn1-dc14
+ state: present
+ register: test_primary_ip
+
+- name: Create test_floating_ip
+ hetzner.hcloud.floating_ip:
+ name: "{{ hcloud_floating_ip_name }}"
+ type: ipv4
+ home_location: fsn1
+ state: present
+ register: test_floating_ip
+
+- name: Create test_load_balancer
+ hetzner.hcloud.load_balancer:
+ name: "{{ hcloud_load_balancer_name }}"
+ load_balancer_type: lb11
+ network_zone: eu-central
+ state: present
+ register: test_load_balancer
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/rdns/tasks/test.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/rdns/tasks/test.yml
new file mode 100644
index 000000000..342716897
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/rdns/tasks/test.yml
@@ -0,0 +1,148 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: Test missing required parameters
+ hetzner.hcloud.rdns:
+ state: present
+ ignore_errors: true
+ register: result
+- name: Verify missing required parameters
+ ansible.builtin.assert:
+ that:
+ - result is failed
+ - 'result.msg == "missing required arguments: ip_address"'
+
+- name: Test create with checkmode
+ hetzner.hcloud.rdns:
+ server: "{{ hcloud_server_name }}"
+ ip_address: "{{ test_server.hcloud_server.ipv6 | ansible.utils.ipaddr('next_usable') }}"
+ dns_ptr: example.com
+ state: present
+ check_mode: true
+ register: result
+- name: Verify create with checkmode
+ ansible.builtin.assert:
+ that:
+ - result is changed
+
+- name: Test create
+ hetzner.hcloud.rdns:
+ server: "{{ hcloud_server_name }}"
+ ip_address: "{{ test_server.hcloud_server.ipv6 | ansible.utils.ipaddr('next_usable') }}"
+ dns_ptr: example.com
+ state: present
+ register: result
+- name: Verify create
+ ansible.builtin.assert:
+ that:
+ - result is changed
+ - result.hcloud_rdns.server == hcloud_server_name
+ - result.hcloud_rdns.ip_address == test_server.hcloud_server.ipv6 | ansible.utils.ipaddr('next_usable')
+ - result.hcloud_rdns.dns_ptr == "example.com"
+
+- name: Test create idempotency
+ hetzner.hcloud.rdns:
+ server: "{{ hcloud_server_name }}"
+ ip_address: "{{ test_server.hcloud_server.ipv6 | ansible.utils.ipaddr('next_usable') }}"
+ dns_ptr: example.com
+ state: present
+ register: result
+- name: Verify create idempotency
+ ansible.builtin.assert:
+ that:
+ - result is not changed
+
+- name: Test create with not existing server
+ hetzner.hcloud.rdns:
+ server: not-existing
+ ip_address: "127.0.0.1"
+ dns_ptr: example.com
+ state: present
+ ignore_errors: true
+ register: result
+- name: Verify create with not existing server
+ ansible.builtin.assert:
+ that:
+ - result is failed
+ - 'result.msg == "resource (server) does not exist: not-existing"'
+
+- name: Test update
+ hetzner.hcloud.rdns:
+ server: "{{ hcloud_server_name }}"
+ ip_address: "{{ test_server.hcloud_server.ipv4_address }}"
+ dns_ptr: example.com
+ state: present
+ register: result
+- name: Verify update
+ ansible.builtin.assert:
+ that:
+ - result is changed
+ - result.hcloud_rdns.ip_address == test_server.hcloud_server.ipv4_address
+
+- name: Test update reset
+ hetzner.hcloud.rdns:
+ server: "{{ hcloud_server_name }}"
+ ip_address: "{{ test_server.hcloud_server.ipv4_address }}"
+ state: present
+ register: result
+- name: Verify update reset
+ ansible.builtin.assert:
+ that:
+ - result is changed
+ - result.hcloud_rdns.dns_ptr != "example.com"
+
+- name: Test delete
+ hetzner.hcloud.rdns:
+ server: "{{ hcloud_server_name }}"
+ ip_address: "{{ test_server.hcloud_server.ipv6 | ansible.utils.ipaddr('next_usable') }}"
+ state: absent
+ register: result
+- name: Verify delete
+ ansible.builtin.assert:
+ that:
+ - result is changed
+
+- name: Test create with primary ip
+ hetzner.hcloud.rdns:
+ primary_ip: "{{ hcloud_primary_ip_name }}"
+ ip_address: "{{ test_primary_ip.hcloud_primary_ip.ip }}"
+ dns_ptr: example.com
+ state: present
+ register: result
+- name: Verify create with primary ip
+ ansible.builtin.assert:
+ that:
+ - result is changed
+ - result.hcloud_rdns.primary_ip == hcloud_primary_ip_name
+ - result.hcloud_rdns.ip_address == test_primary_ip.hcloud_primary_ip.ip
+ - result.hcloud_rdns.dns_ptr == "example.com"
+
+- name: Test create with floating ip
+ hetzner.hcloud.rdns:
+ floating_ip: "{{ hcloud_floating_ip_name }}"
+ ip_address: "{{ test_floating_ip.hcloud_floating_ip.ip }}"
+ dns_ptr: example.com
+ state: present
+ register: result
+- name: Verify create with floating ip
+ ansible.builtin.assert:
+ that:
+ - result is changed
+ - result.hcloud_rdns.floating_ip == hcloud_floating_ip_name
+ - result.hcloud_rdns.ip_address == test_floating_ip.hcloud_floating_ip.ip
+ - result.hcloud_rdns.dns_ptr == "example.com"
+
+- name: Test create with load balancer
+ hetzner.hcloud.rdns:
+ load_balancer: "{{ hcloud_load_balancer_name }}"
+ ip_address: "{{ test_load_balancer.hcloud_load_balancer.ipv4_address }}"
+ dns_ptr: example.com
+ state: present
+ register: result
+- name: Verify create with load balancer
+ ansible.builtin.assert:
+ that:
+ - result is changed
+ - result.hcloud_rdns.load_balancer == hcloud_load_balancer_name
+ - result.hcloud_rdns.ip_address == test_load_balancer.hcloud_load_balancer.ipv4_address
+ - result.hcloud_rdns.dns_ptr == "example.com"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/route/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/route/aliases
new file mode 100644
index 000000000..62828d1e9
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/route/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+azp/group1
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/route/defaults/main/common.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/route/defaults/main/common.yml
new file mode 100644
index 000000000..e316b233c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/route/defaults/main/common.yml
@@ -0,0 +1,12 @@
+#
+# 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('first') | join() }}"
+hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/route/defaults/main/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/route/defaults/main/main.yml
new file mode 100644
index 000000000..a01c6d60c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/route/defaults/main/main.yml
@@ -0,0 +1,4 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_network_name: "{{ hcloud_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/route/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/route/tasks/main.yml
new file mode 100644
index 000000000..767fc465b
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/route/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/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/route/tasks/test.yml
index 7d816bf5c..571f29a86 100644
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/tasks/main.yml
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/route/tasks/test.yml
@@ -2,7 +2,7 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
- name: setup
- hcloud_network:
+ hetzner.hcloud.network:
name: "{{ hcloud_network_name }}"
ip_range: "10.0.0.0/8"
state: present
@@ -10,13 +10,13 @@
- name: verify setup
assert:
that:
- - network is success
+ - network is success
- name: test missing required parameters on create route
- hcloud_route:
+ hetzner.hcloud.route:
state: present
register: result
- ignore_errors: yes
+ ignore_errors: true
- name: verify fail test missing required parameters on create route
assert:
that:
@@ -24,20 +24,20 @@
- 'result.msg == "missing required arguments: destination, gateway, network"'
- name: test create route with checkmode
- hcloud_route:
+ hetzner.hcloud.route:
network: "{{ hcloud_network_name }}"
destination: "10.100.1.0/24"
gateway: "10.0.1.1"
state: present
register: result
- check_mode: yes
+ check_mode: true
- name: verify test create route with checkmode
assert:
that:
- - result is changed
+ - result is changed
- name: test create route
- hcloud_route:
+ hetzner.hcloud.route:
network: "{{ hcloud_network_name }}"
destination: "10.100.1.0/24"
gateway: "10.0.1.1"
@@ -46,13 +46,13 @@
- name: verify create route
assert:
that:
- - route is changed
- - route.hcloud_route.network == "{{ hcloud_network_name }}"
- - route.hcloud_route.destination == "10.100.1.0/24"
- - route.hcloud_route.gateway == "10.0.1.1"
+ - route is changed
+ - route.hcloud_route.network == hcloud_network_name
+ - route.hcloud_route.destination == "10.100.1.0/24"
+ - route.hcloud_route.gateway == "10.0.1.1"
- name: test create route idempotency
- hcloud_route:
+ hetzner.hcloud.route:
network: "{{ hcloud_network_name }}"
destination: "10.100.1.0/24"
gateway: "10.0.1.1"
@@ -61,23 +61,23 @@
- name: verify create route idempotency
assert:
that:
- - result is not changed
+ - result is not changed
- name: test fail create route with wrong gateway
- hcloud_route:
+ hetzner.hcloud.route:
network: "{{ hcloud_network_name }}"
destination: "10.100.1.0/24"
gateway: "10.0.1.2"
state: present
register: route
- ignore_errors: yes
+ ignore_errors: true
- name: verfiy fail create route with wrong gateway
assert:
that:
- - route is failed
+ - route is failed
- name: test absent route
- hcloud_route:
+ hetzner.hcloud.route:
network: "{{ hcloud_network_name }}"
destination: "10.100.1.0/24"
gateway: "10.0.1.1"
@@ -86,10 +86,10 @@
- name: verify test absent route
assert:
that:
- - result is changed
+ - result is changed
- name: cleanup
- hcloud_network:
+ hetzner.hcloud.network:
name: "{{hcloud_network_name}}"
state: absent
register: result
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/server/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/server/aliases
new file mode 100644
index 000000000..a6a90a6bf
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/server/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+azp/group3
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/server/defaults/main/common.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/server/defaults/main/common.yml
new file mode 100644
index 000000000..e316b233c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/server/defaults/main/common.yml
@@ -0,0 +1,12 @@
+#
+# 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('first') | join() }}"
+hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/server/defaults/main/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/server/defaults/main/main.yml
new file mode 100644
index 000000000..d9b84598a
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/server/defaults/main/main.yml
@@ -0,0 +1,8 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_ssh_key_name: "{{ hcloud_ns }}"
+hcloud_server_name: "{{ hcloud_ns }}"
+hcloud_firewall_name: "{{ hcloud_ns }}"
+hcloud_primary_ip_name: "{{ hcloud_ns }}"
+hcloud_network_name: "{{ hcloud_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/server/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/server/meta/main.yml
new file mode 100644
index 000000000..3a96ecb2d
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/server/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_ssh_keypair
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/server/tasks/cleanup.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/server/tasks/cleanup.yml
new file mode 100644
index 000000000..8066c4115
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/server/tasks/cleanup.yml
@@ -0,0 +1,5 @@
+---
+- name: Cleanup test_ssh_key
+ hetzner.hcloud.ssh_key:
+ name: "{{ hcloud_ssh_key_name }}"
+ state: absent
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/server/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/server/tasks/main.yml
new file mode 100644
index 000000000..767fc465b
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/server/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/ansible_collections/hetzner/hcloud/tests/integration/targets/server/tasks/prepare.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/server/tasks/prepare.yml
new file mode 100644
index 000000000..4bdb95996
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/server/tasks/prepare.yml
@@ -0,0 +1,6 @@
+---
+- name: Create test_ssh_key
+ hetzner.hcloud.ssh_key:
+ name: "{{ hcloud_ssh_key_name }}"
+ public_key: "{{ test_ssh_keypair.public_key }}"
+ register: test_ssh_key
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/server/tasks/test.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/server/tasks/test.yml
new file mode 100644
index 000000000..e00bcce50
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/server/tasks/test.yml
@@ -0,0 +1,8 @@
+# Copyright: (c) 2022, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+#- ansible.builtin.include_tasks: test_validation.yml
+- ansible.builtin.include_tasks: test_basic.yml
+#- ansible.builtin.include_tasks: test_firewalls.yml
+- ansible.builtin.include_tasks: test_primary_ips.yml
+- ansible.builtin.include_tasks: test_private_network_only.yml
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/basic.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/server/tasks/test_basic.yml
index ac609fc6c..1e94d67af 100644
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/basic.yml
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/server/tasks/test_basic.yml
@@ -1,21 +1,21 @@
- name: test create server with check mode
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
server_type: cx11
- image: ubuntu-20.04
+ image: ubuntu-22.04
state: present
register: result
- check_mode: yes
+ check_mode: true
- name: test create server server
assert:
that:
- result is changed
- name: test create server
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name}}"
server_type: cx11
- image: ubuntu-20.04
+ image: ubuntu-22.04
enable_ipv6: False
state: started
register: main_server
@@ -23,13 +23,13 @@
assert:
that:
- main_server is changed
- - main_server.hcloud_server.name == "{{ hcloud_server_name }}"
+ - main_server.hcloud_server.name == hcloud_server_name
- main_server.hcloud_server.server_type == "cx11"
- main_server.hcloud_server.status == "running"
- main_server.root_password != ""
- name: test create server idempotence
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
state: started
register: result
@@ -39,11 +39,11 @@
- result is not changed
- name: test stop server with check mode
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
state: stopped
register: result
- check_mode: yes
+ check_mode: true
- name: verify stop server with check mode
assert:
that:
@@ -51,7 +51,7 @@
- result.hcloud_server.status == "running"
- name: test stop server
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
state: stopped
register: result
@@ -62,7 +62,7 @@
- result.hcloud_server.status == "off"
- name: test start server with check mode
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
state: started
register: result
@@ -73,7 +73,7 @@
- result is changed
- name: test start server
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
state: started
register: result
@@ -84,7 +84,7 @@
- result.hcloud_server.status == "running"
- name: test start server idempotence
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
state: started
register: result
@@ -95,7 +95,7 @@
- result.hcloud_server.status == "running"
- name: test stop server by its id
- hcloud_server:
+ hetzner.hcloud.server:
id: "{{ main_server.hcloud_server.id }}"
state: stopped
register: result
@@ -106,7 +106,7 @@
- result.hcloud_server.status == "off"
- name: test resize server running without force
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
server_type: "cx21"
state: present
@@ -119,7 +119,7 @@
- result.hcloud_server.server_type == "cx11"
- name: test resize server with check mode
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
server_type: "cx21"
state: stopped
@@ -131,7 +131,7 @@
- result is changed
- name: test resize server without disk
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
server_type: "cx21"
state: stopped
@@ -143,7 +143,7 @@
- result.hcloud_server.server_type == "cx21"
- name: test resize server idempotence
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
server_type: "cx21"
state: stopped
@@ -154,7 +154,7 @@
- result is not changed
- name: test resize server to smaller plan
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
server_type: "cx11"
state: stopped
@@ -166,7 +166,7 @@
- result.hcloud_server.server_type == "cx11"
- name: test resize server with disk
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
server_type: "cx21"
upgrade_disk: true
@@ -179,7 +179,7 @@
- result.hcloud_server.server_type == "cx21"
- name: test enable backups with check mode
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
backups: true
state: stopped
@@ -191,7 +191,7 @@
- result is changed
- name: test enable backups
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
backups: true
state: stopped
@@ -203,7 +203,7 @@
- result.hcloud_server.backup_window != ""
- name: test enable backups idempotence
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
backups: true
state: stopped
@@ -215,7 +215,7 @@
- result.hcloud_server.backup_window != ""
- name: test backups are not accidentally disabled
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
# Make sure that backups are not disabled because a partial server object without "backups" was supplied somewhere
# to update some unrelated properties.
@@ -230,9 +230,9 @@
- result.hcloud_server.backup_window != ""
- name: test rebuild server
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
- image: ubuntu-20.04
+ image: ubuntu-22.04
state: rebuild
register: result_after_test
- name: verify rebuild server
@@ -242,9 +242,9 @@
- result.hcloud_server.id == result_after_test.hcloud_server.id
- name: test rebuild server with check mode
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
- image: ubuntu-20.04
+ image: ubuntu-22.04
state: rebuild
register: result_after_test
check_mode: true
@@ -254,7 +254,7 @@
- result_after_test is changed
- name: test update server protection booth protection arguments are required
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
delete_protection: true
state: present
@@ -267,7 +267,7 @@
- 'result_after_test.msg == "parameters are required together: delete_protection, rebuild_protection"'
- name: test update server protection fails if they are not the same
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
delete_protection: true
rebuild_protection: false
@@ -280,7 +280,7 @@
- result_after_test is failed
- name: test update server protection
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
delete_protection: true
rebuild_protection: true
@@ -295,7 +295,7 @@
- result_after_test.hcloud_server.rebuild_protection is sameas true
- name: test server without protection set to be idempotent
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{hcloud_server_name}}"
register: result_after_test
- name: verify test server without protection set to be idempotent
@@ -306,10 +306,10 @@
- result_after_test.hcloud_server.rebuild_protection is sameas true
- name: test delete server fails if it is protected
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{hcloud_server_name}}"
state: absent
- ignore_errors: yes
+ ignore_errors: true
register: result
- name: verify delete server fails if it is protected
assert:
@@ -318,11 +318,11 @@
- 'result.msg == "server deletion is protected"'
- name: test rebuild server fails if it is protected
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{hcloud_server_name}}"
- image: ubuntu-20.04
+ image: ubuntu-22.04
state: rebuild
- ignore_errors: yes
+ ignore_errors: true
register: result
- name: verify rebuild server fails if it is protected
assert:
@@ -331,7 +331,7 @@
- 'result.msg == "server rebuild is protected"'
- name: test remove server protection
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
delete_protection: false
rebuild_protection: false
@@ -346,40 +346,39 @@
- result_after_test.hcloud_server.rebuild_protection is sameas false
- name: absent server
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
state: absent
register: result
- name: verify absent server
assert:
that:
- - result is success
+ - result is success
- name: test create server with ssh key
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name}}"
server_type: cx11
- image: "ubuntu-20.04"
+ image: "ubuntu-22.04"
ssh_keys:
- - ci@ansible.hetzner.cloud
+ - "{{ hcloud_ssh_key_name }}"
state: started
register: main_server
- name: verify create server with ssh key
assert:
that:
- main_server is changed
- - main_server.hcloud_server.name == "{{ hcloud_server_name }}"
+ - main_server.hcloud_server.name == hcloud_server_name
- main_server.hcloud_server.server_type == "cx11"
- main_server.hcloud_server.status == "running"
- main_server.root_password != ""
-
- name: test activate rescue mode with check_mode
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
rescue_mode: "linux64"
ssh_keys:
- - ci@ansible.hetzner.cloud
+ - "{{ hcloud_ssh_key_name }}"
state: present
register: main_server
check_mode: true
@@ -389,11 +388,11 @@
- main_server is changed
- name: test activate rescue mode
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
rescue_mode: "linux64"
ssh_keys:
- - ci@ansible.hetzner.cloud
+ - "{{ hcloud_ssh_key_name }}"
state: present
register: main_server
- name: verify activate rescue mode
@@ -403,10 +402,10 @@
- main_server.hcloud_server.rescue_enabled is sameas true
- name: test disable rescue mode
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
ssh_keys:
- - ci@ansible.hetzner.cloud
+ - "{{ hcloud_ssh_key_name }}"
state: present
register: main_server
- name: verify activate rescue mode
@@ -416,7 +415,7 @@
- main_server.hcloud_server.rescue_enabled is sameas false
- name: test activate rescue mode without ssh keys
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
rescue_mode: "linux64"
state: present
@@ -428,22 +427,22 @@
- main_server.hcloud_server.rescue_enabled is sameas true
- name: absent server
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
state: absent
register: result
- name: verify absent server
assert:
that:
- - result is success
+ - result is success
- name: test create server with rescue_mode
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name}}"
server_type: cx11
- image: "ubuntu-20.04"
+ image: "ubuntu-22.04"
ssh_keys:
- - ci@ansible.hetzner.cloud
+ - "{{ hcloud_ssh_key_name }}"
rescue_mode: "linux64"
state: started
register: main_server
@@ -451,29 +450,28 @@
assert:
that:
- main_server is changed
- - main_server.hcloud_server.name == "{{ hcloud_server_name }}"
+ - main_server.hcloud_server.name == hcloud_server_name
- main_server.hcloud_server.server_type == "cx11"
- main_server.hcloud_server.status == "running"
- main_server.root_password != ""
- main_server.hcloud_server.rescue_enabled is sameas true
-
- name: absent server
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
state: absent
register: result
- name: verify absent server
assert:
that:
- - result is success
+ - result is success
- name: test create server with labels
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name}}"
server_type: cx11
- image: "ubuntu-20.04"
+ image: "ubuntu-22.04"
ssh_keys:
- - ci@ansible.hetzner.cloud
+ - "{{ hcloud_ssh_key_name }}"
labels:
key: value
mylabel: "val123"
@@ -487,12 +485,12 @@
- main_server.hcloud_server.labels.mylabel == "val123"
- name: test update server with labels
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name}}"
server_type: cx11
- image: "ubuntu-20.04"
+ image: "ubuntu-22.04"
ssh_keys:
- - ci@ansible.hetzner.cloud
+ - "{{ hcloud_ssh_key_name }}"
labels:
key: other
mylabel: "val123"
@@ -506,12 +504,12 @@
- main_server.hcloud_server.labels.mylabel == "val123"
- name: test update server with labels in other order
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name}}"
server_type: cx11
- image: "ubuntu-20.04"
+ image: "ubuntu-22.04"
ssh_keys:
- - ci@ansible.hetzner.cloud
+ - "{{ hcloud_ssh_key_name }}"
labels:
mylabel: "val123"
key: other
@@ -523,23 +521,23 @@
- main_server is not changed
- name: cleanup with labels
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
state: absent
register: result
- name: verify cleanup
assert:
that:
- - result is success
+ - result is success
- name: test create server with enabled backups
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
server_type: cpx11
backups: true
- image: "ubuntu-20.04"
+ image: "ubuntu-22.04"
ssh_keys:
- - ci@ansible.hetzner.cloud
+ - "{{ hcloud_ssh_key_name }}"
state: present
register: result
- name: verify enable backups
@@ -549,24 +547,24 @@
- result.hcloud_server.backup_window != ""
- name: cleanup test create server with enabled backups
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
state: absent
register: result
- name: verify cleanup
assert:
that:
- - result is success
+ - result is success
- name: test create server with protection
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
delete_protection: true
rebuild_protection: true
server_type: cpx11
- image: "ubuntu-20.04"
+ image: "ubuntu-22.04"
ssh_keys:
- - ci@ansible.hetzner.cloud
+ - "{{ hcloud_ssh_key_name }}"
state: present
register: result_after_test
ignore_errors: true
@@ -578,10 +576,10 @@
- result_after_test.hcloud_server.rebuild_protection is sameas true
- name: test delete server fails if it is protected
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{hcloud_server_name}}"
state: absent
- ignore_errors: yes
+ ignore_errors: true
register: result
- name: verify delete server fails if it is protected
assert:
@@ -590,7 +588,7 @@
- 'result.msg == "server deletion is protected"'
- name: remove protection from server
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
delete_protection: false
rebuild_protection: false
@@ -605,11 +603,11 @@
- result_after_test.hcloud_server.rebuild_protection is sameas false
- name: cleanup
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
state: absent
register: result
- name: verify cleanup
assert:
that:
- - result is success
+ - result is success
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/firewalls.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/server/tasks/test_firewalls.yml
index 18fa89e25..896a6c5cf 100644
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/firewalls.yml
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/server/tasks/test_firewalls.yml
@@ -2,12 +2,12 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
- name: test add not existing firewall should fail
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
firewalls:
- not-existing
state: present
- ignore_errors: yes
+ ignore_errors: true
register: result
- name: verify add not existing firewall should fail
assert:
@@ -15,7 +15,7 @@
- result is failed
- 'result.msg == "firewall not-existing was not found"'
- name: setup create firewalls
- hcloud_firewall:
+ hetzner.hcloud.firewall:
name: "{{ item }}"
rules:
- direction: in
@@ -28,14 +28,14 @@
- "{{ hcloud_firewall_name }}2"
- name: test create server with firewalls
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
server_type: cpx11
firewalls:
- "{{ hcloud_firewall_name }}"
- image: "ubuntu-20.04"
+ image: "ubuntu-22.04"
ssh_keys:
- - ci@ansible.hetzner.cloud
+ - "{{ hcloud_ssh_key_name }}"
state: present
register: result
- name: verify test create server with firewalls
@@ -44,14 +44,14 @@
- result is changed
- name: test create server with firewalls idempotence
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
server_type: cpx11
firewalls:
- "{{ hcloud_firewall_name }}"
- image: "ubuntu-20.04"
+ image: "ubuntu-22.04"
ssh_keys:
- - ci@ansible.hetzner.cloud
+ - "{{ hcloud_ssh_key_name }}"
state: present
register: result
- name: verify test create server with firewalls idempotence
@@ -60,14 +60,14 @@
- result is not changed
- name: test update server with firewalls
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
server_type: cpx11
firewalls:
- "{{ hcloud_firewall_name }}2"
- image: "ubuntu-20.04"
+ image: "ubuntu-22.04"
ssh_keys:
- - ci@ansible.hetzner.cloud
+ - "{{ hcloud_ssh_key_name }}"
state: present
register: result
- name: verify test update server with firewalls
@@ -76,14 +76,14 @@
- result is changed
- name: test update server with firewalls idempotence
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
server_type: cpx11
firewalls:
- "{{ hcloud_firewall_name }}2"
- image: "ubuntu-20.04"
+ image: "ubuntu-22.04"
ssh_keys:
- - ci@ansible.hetzner.cloud
+ - "{{ hcloud_ssh_key_name }}"
state: present
register: result
- name: verify test update server with firewalls idempotence
@@ -92,12 +92,12 @@
- result is not changed
- name: cleanup server with firewalls
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
state: absent
- name: cleanup test create firewall
- hcloud_firewall:
+ hetzner.hcloud.firewall:
name: "{{ item }}"
state: absent
with_items:
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/primary_ips.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/server/tasks/test_primary_ips.yml
index 000c294de..034da9f74 100644
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/primary_ips.yml
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/server/tasks/test_primary_ips.yml
@@ -2,36 +2,36 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
- name: setup create primary ipv4
- hcloud_primary_ip:
+ hetzner.hcloud.primary_ip:
name: "{{ hcloud_primary_ip_name }}v4"
type: ipv4
datacenter: "fsn1-dc14"
register: primaryIPv4
- name: setup create second primary ipv4
- hcloud_primary_ip:
+ hetzner.hcloud.primary_ip:
name: "{{ hcloud_primary_ip_name }}v42"
type: ipv4
datacenter: "fsn1-dc14"
register: secondPrimaryIPv4
- name: setup create primary ipv6
- hcloud_primary_ip:
+ hetzner.hcloud.primary_ip:
name: "{{ hcloud_primary_ip_name }}v6"
type: ipv6
datacenter: "fsn1-dc14"
register: primaryIPv6
- name: test create server with primary ips
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
server_type: cpx11
datacenter: "fsn1-dc14"
- image: "ubuntu-20.04"
+ image: "ubuntu-22.04"
ipv4: "{{primaryIPv4.hcloud_primary_ip.id}}"
ipv6: "{{primaryIPv6.hcloud_primary_ip.id}}"
ssh_keys:
- - ci@ansible.hetzner.cloud
+ - "{{ hcloud_ssh_key_name }}"
state: stopped
register: result
- name: verify test create server with primary ips
@@ -40,16 +40,16 @@
- result is changed
- name: test update server with primary ips
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
server_type: cpx11
datacenter: "fsn1-dc14"
- image: "ubuntu-20.04"
+ image: "ubuntu-22.04"
ipv4: "{{secondPrimaryIPv4.hcloud_primary_ip.id}}"
ipv6: ""
- enable_ipv6: no
+ enable_ipv6: false
ssh_keys:
- - ci@ansible.hetzner.cloud
+ - "{{ hcloud_ssh_key_name }}"
state: stopped
register: result
- name: verify test create server with primary ips
@@ -58,23 +58,23 @@
- result is changed
- name: cleanup server with primary ips
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
state: absent
- name: cleanup test create primary ips
- hcloud_primary_ip:
+ hetzner.hcloud.primary_ip:
name: "{{ hcloud_server_name }}v4"
state: absent
- name: cleanup test create primary ips
- hcloud_primary_ip:
+ hetzner.hcloud.primary_ip:
name: "{{ hcloud_server_name }}v42"
state: absent
until: result is not failed
retries: 5
delay: 2
- name: cleanup test create primary ips
- hcloud_primary_ip:
+ hetzner.hcloud.primary_ip:
name: "{{ hcloud_server_name }}v6"
state: absent
until: result is not failed
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/private_network_only.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/server/tasks/test_private_network_only.yml
index a56832873..a4219a00f 100644
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/private_network_only.yml
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/server/tasks/test_private_network_only.yml
@@ -2,28 +2,28 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
- name: setup network 1 to be absent
- hcloud_network:
+ hetzner.hcloud.network:
name: "{{ hcloud_network_name }}-1"
state: absent
- name: setup network 2 to be absent
- hcloud_network:
+ hetzner.hcloud.network:
name: "{{ hcloud_network_name }}-2"
state: absent
- name: setup server to be absent
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
state: absent
- name: setup create network
- hcloud_network:
+ hetzner.hcloud.network:
name: "{{ hcloud_network_name }}-1"
ip_range: 192.168.0.0/23
register: primaryNetwork
- name: setup create network subnet 1
- hcloud_subnetwork:
+ hetzner.hcloud.subnetwork:
network: "{{ hcloud_network_name }}-1"
ip_range: 192.168.0.0/24
network_zone: eu-central
@@ -31,7 +31,7 @@
state: present
- name: setup create network subnet 2
- hcloud_subnetwork:
+ hetzner.hcloud.subnetwork:
network: "{{ hcloud_network_name }}-1"
ip_range: 192.168.1.0/24
network_zone: eu-central
@@ -39,13 +39,13 @@
state: present
- name: setup create secondary network
- hcloud_network:
+ hetzner.hcloud.network:
name: "{{ hcloud_network_name }}-2"
ip_range: 192.168.2.0/23
register: secondaryNetwork
- name: setup create secondary network subnet 1
- hcloud_subnetwork:
+ hetzner.hcloud.subnetwork:
network: "{{ hcloud_network_name }}-2"
ip_range: 192.168.2.0/24
network_zone: eu-central
@@ -53,7 +53,7 @@
state: present
- name: setup create secondary network subnet 2
- hcloud_subnetwork:
+ hetzner.hcloud.subnetwork:
network: "{{ hcloud_network_name }}-2"
ip_range: 192.168.3.0/24
network_zone: eu-central
@@ -61,17 +61,17 @@
state: present
- name: test create server with primary network and no internet
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
server_type: cpx11
datacenter: "fsn1-dc14"
- image: "ubuntu-20.04"
- enable_ipv4: no
- enable_ipv6: no
+ image: "ubuntu-22.04"
+ enable_ipv4: false
+ enable_ipv6: false
private_networks:
- "{{ primaryNetwork.hcloud_network.name }}"
ssh_keys:
- - ci@ansible.hetzner.cloud
+ - "{{ hcloud_ssh_key_name }}"
state: stopped
register: result
- name: verify test create server with primary network
@@ -80,18 +80,18 @@
- result is changed
- name: test update server by adding secondary network
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
server_type: cpx11
datacenter: "fsn1-dc14"
- image: "ubuntu-20.04"
- enable_ipv4: no
- enable_ipv6: no
+ image: "ubuntu-22.04"
+ enable_ipv4: false
+ enable_ipv6: false
private_networks:
- "{{ primaryNetwork.hcloud_network.name }}"
- "{{ secondaryNetwork.hcloud_network.id }}"
ssh_keys:
- - ci@ansible.hetzner.cloud
+ - "{{ hcloud_ssh_key_name }}"
state: stopped
register: result
- name: verify test update server by adding secondary network
@@ -100,18 +100,18 @@
- result is changed
- name: test update server idem
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
server_type: cpx11
datacenter: "fsn1-dc14"
- image: "ubuntu-20.04"
- enable_ipv4: no
- enable_ipv6: no
+ image: "ubuntu-22.04"
+ enable_ipv4: false
+ enable_ipv6: false
private_networks:
- "{{ primaryNetwork.hcloud_network.name }}"
- "{{ secondaryNetwork.hcloud_network.id }}"
ssh_keys:
- - ci@ansible.hetzner.cloud
+ - "{{ hcloud_ssh_key_name }}"
state: stopped
register: result
- name: verify test update server idem
@@ -120,11 +120,11 @@
- result is not changed
- name: cleanup server
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
state: absent
- name: cleanup networks
- hcloud_network:
+ hetzner.hcloud.network:
name: "{{ item }}"
state: absent
with_items:
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/validation.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/server/tasks/test_validation.yml
index f507e87cf..d4e0ef8b4 100644
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/validation.yml
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/server/tasks/test_validation.yml
@@ -2,20 +2,20 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
- name: setup
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
state: absent
register: result
- name: verify setup
assert:
that:
- - result is success
+ - result is success
- name: test missing required parameters on create server
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
register: result
- ignore_errors: yes
+ ignore_errors: true
- name: verify fail test missing required parameters on create server
assert:
that:
@@ -23,13 +23,13 @@
- 'result.msg == "missing required arguments: server_type, image"'
- name: test create server with not existing server type
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
server_type: not-existing-server-type
- image: ubuntu-20.04
+ image: ubuntu-22.04
state: present
register: result
- ignore_errors: yes
+ ignore_errors: true
- name: verify fail test create server with not existing server type
assert:
that:
@@ -37,13 +37,13 @@
- 'result.msg == "server_type not-existing-server-type was not found"'
- name: test create server with not existing image
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
server_type: cx11
image: my-not-existing-image-20.04
state: present
register: result
- ignore_errors: yes
+ ignore_errors: true
- name: verify fail test create server with not existing image
assert:
that:
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/server_info/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/server_info/aliases
new file mode 100644
index 000000000..0e887600e
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/server_info/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+azp/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/server_info/defaults/main/common.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/server_info/defaults/main/common.yml
new file mode 100644
index 000000000..e316b233c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/server_info/defaults/main/common.yml
@@ -0,0 +1,12 @@
+#
+# 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('first') | join() }}"
+hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/server_info/defaults/main/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/server_info/defaults/main/main.yml
new file mode 100644
index 000000000..a85dafcfc
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/server_info/defaults/main/main.yml
@@ -0,0 +1,4 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_server_name: "{{ hcloud_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/server_info/tasks/cleanup.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/server_info/tasks/cleanup.yml
new file mode 100644
index 000000000..0c95d2c65
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/server_info/tasks/cleanup.yml
@@ -0,0 +1,10 @@
+---
+- name: Cleanup test_server
+ hetzner.hcloud.server:
+ name: "{{ hcloud_server_name }}"
+ state: absent
+
+- name: Cleanup test_server2
+ hetzner.hcloud.server:
+ name: "{{ hcloud_server_name }}2"
+ state: absent
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/server_info/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/server_info/tasks/main.yml
new file mode 100644
index 000000000..767fc465b
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/server_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/ansible_collections/hetzner/hcloud/tests/integration/targets/server_info/tasks/prepare.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/server_info/tasks/prepare.yml
new file mode 100644
index 000000000..9e8aa2c9f
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/server_info/tasks/prepare.yml
@@ -0,0 +1,22 @@
+---
+- name: Create test_server
+ hetzner.hcloud.server:
+ name: "{{ hcloud_server_name }}"
+ server_type: cx11
+ image: ubuntu-22.04
+ state: started
+ labels:
+ key: value
+ register: test_server
+
+- name: Create test_server2 (stopped + without ip)
+ hetzner.hcloud.server:
+ name: "{{ hcloud_server_name }}2"
+ server_type: cx11
+ image: ubuntu-22.04
+ state: stopped
+ labels:
+ key: value
+ enable_ipv4: false
+ enable_ipv6: false
+ register: test_server2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/server_info/tasks/test.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/server_info/tasks/test.yml
new file mode 100644
index 000000000..534c50a70
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/server_info/tasks/test.yml
@@ -0,0 +1,89 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: Gather hcloud_server_info
+ hetzner.hcloud.server_info:
+ register: result
+- name: Verify hcloud_server_info
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_server_info | list | count >= 2
+
+- name: Gather hcloud_server_info in check mode
+ hetzner.hcloud.server_info:
+ check_mode: true
+ register: result
+- name: Verify hcloud_server_info in check mode
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_server_info | list | count >= 2
+
+- name: Gather hcloud_server_info with correct id
+ hetzner.hcloud.server_info:
+ id: "{{ test_server.hcloud_server.id }}"
+ register: result
+- name: Verify hcloud_server_info with correct id
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_server_info | list | count == 1
+ - result.hcloud_server_info[0].name == hcloud_server_name
+
+- name: Gather hcloud_server_info with wrong id
+ hetzner.hcloud.server_info:
+ id: "{{ test_server.hcloud_server.id }}4321"
+ ignore_errors: true
+ register: result
+- name: Verify hcloud_server_info with wrong id
+ ansible.builtin.assert:
+ that:
+ - result is failed
+
+- name: Gather hcloud_server_info with correct name
+ hetzner.hcloud.server_info:
+ name: "{{ hcloud_server_name }}"
+ register: result
+- name: Verify hcloud_server_info with correct name
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_server_info | list | count == 1
+ - result.hcloud_server_info[0].name == hcloud_server_name
+
+- name: Gather hcloud_server_info with wrong name
+ hetzner.hcloud.server_info:
+ name: "{{ hcloud_server_name }}-invalid"
+ register: result
+- name: Verify hcloud_server_info with wrong name
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_server_info | list | count == 0
+
+- name: Gather hcloud_server_info with correct label selector
+ hetzner.hcloud.server_info:
+ label_selector: "key=value"
+ register: result
+- name: Verify hcloud_server_info with correct label selector
+ ansible.builtin.assert:
+ that:
+ - >
+ result.hcloud_server_info
+ | selectattr('name', 'equalto', hcloud_server_name)
+ | list | count == 1
+
+- name: Gather hcloud_server_info with wrong label selector
+ hetzner.hcloud.server_info:
+ label_selector: "key!=value"
+ register: result
+- name: Verify hcloud_server_info with wrong label selector
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_server_info | list | count == 0
+
+- name: Gather hcloud_server_info (without ip)
+ hetzner.hcloud.server_info:
+ id: "{{ test_server2.hcloud_server.id }}"
+ register: result
+- name: Verify hcloud_server_info (without ip)
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_server_info | list | count == 1
+ - result.hcloud_server_info[0].name == hcloud_server_name + '2'
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/server_network/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/server_network/aliases
new file mode 100644
index 000000000..6e9b68657
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/server_network/aliases
@@ -0,0 +1,3 @@
+cloud/hcloud
+azp/group2
+disabled
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/server_network/defaults/main/common.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/server_network/defaults/main/common.yml
new file mode 100644
index 000000000..e316b233c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/server_network/defaults/main/common.yml
@@ -0,0 +1,12 @@
+#
+# 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('first') | join() }}"
+hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/server_network/defaults/main/main.yml
index f4c6a9fc9..c9a119410 100644
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/defaults/main.yml
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/server_network/defaults/main/main.yml
@@ -1,5 +1,5 @@
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
-hcloud_prefix: "tests"
-hcloud_floating_ip_name: "{{hcloud_prefix}}-i"
+hcloud_network_name: "{{ hcloud_ns }}"
+hcloud_server_name: "{{ hcloud_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/server_network/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/server_network/tasks/main.yml
new file mode 100644
index 000000000..767fc465b
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/server_network/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/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/server_network/tasks/test.yml
index 754018a66..a77f2e30a 100644
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/tasks/main.yml
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/server_network/tasks/test.yml
@@ -2,7 +2,7 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
- name: setup network
- hcloud_network:
+ hetzner.hcloud.network:
name: "{{ hcloud_network_name }}"
ip_range: "10.0.0.0/8"
state: present
@@ -10,10 +10,10 @@
- name: verify setup network
assert:
that:
- - network is success
+ - network is success
- name: setup subnetwork
- hcloud_subnetwork:
+ hetzner.hcloud.subnetwork:
network: "{{ hcloud_network_name }}"
ip_range: "10.0.0.0/16"
type: "server"
@@ -23,13 +23,13 @@
- name: verify subnetwork
assert:
that:
- - subnetwork is success
+ - subnetwork is success
- name: setup server
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{hcloud_server_name}}"
server_type: cx11
- image: ubuntu-18.04
+ image: ubuntu-22.04
state: started
location: "fsn1"
register: server
@@ -39,10 +39,10 @@
- server is success
- name: test missing required parameters on create server network
- hcloud_server_network:
+ hetzner.hcloud.server_network:
state: present
register: result
- ignore_errors: yes
+ ignore_errors: true
- name: verify fail test missing required parameters on create server network
assert:
that:
@@ -50,19 +50,19 @@
- 'result.msg == "missing required arguments: network, server"'
- name: test create server network with checkmode
- hcloud_server_network:
+ hetzner.hcloud.server_network:
network: "{{ hcloud_network_name }}"
server: "{{hcloud_server_name}}"
state: present
register: result
- check_mode: yes
+ check_mode: true
- name: verify test create server network with checkmode
assert:
that:
- - result is changed
+ - result is changed
- name: test create server network
- hcloud_server_network:
+ hetzner.hcloud.server_network:
network: "{{ hcloud_network_name }}"
server: "{{hcloud_server_name}}"
state: present
@@ -70,12 +70,12 @@
- name: verify create server network
assert:
that:
- - serverNetwork is changed
- - serverNetwork.hcloud_server_network.network == hcloud_network_name
- - serverNetwork.hcloud_server_network.server == hcloud_server_name
+ - serverNetwork is changed
+ - serverNetwork.hcloud_server_network.network == hcloud_network_name
+ - serverNetwork.hcloud_server_network.server == hcloud_server_name
- name: test create server network idempotency
- hcloud_server_network:
+ hetzner.hcloud.server_network:
network: "{{ hcloud_network_name }}"
server: "{{hcloud_server_name}}"
state: present
@@ -83,10 +83,10 @@
- name: verify create server network idempotency
assert:
that:
- - serverNetwork is not changed
+ - serverNetwork is not changed
- name: test absent server network
- hcloud_server_network:
+ hetzner.hcloud.server_network:
network: "{{ hcloud_network_name }}"
server: "{{hcloud_server_name}}"
state: absent
@@ -94,10 +94,10 @@
- name: verify test absent server network
assert:
that:
- - result is changed
+ - result is changed
- name: test create server network with specified ip
- hcloud_server_network:
+ hetzner.hcloud.server_network:
network: "{{ hcloud_network_name }}"
server: "{{hcloud_server_name}}"
ip: "10.0.0.2"
@@ -106,13 +106,13 @@
- name: verify create server network with specified ip
assert:
that:
- - serverNetwork is changed
- - serverNetwork.hcloud_server_network.network == hcloud_network_name
- - serverNetwork.hcloud_server_network.server == hcloud_server_name
- - serverNetwork.hcloud_server_network.ip == "10.0.0.2"
+ - serverNetwork is changed
+ - serverNetwork.hcloud_server_network.network == hcloud_network_name
+ - serverNetwork.hcloud_server_network.server == hcloud_server_name
+ - serverNetwork.hcloud_server_network.ip == "10.0.0.2"
- name: cleanup create server network with specified ip
- hcloud_server_network:
+ hetzner.hcloud.server_network:
network: "{{ hcloud_network_name }}"
server: "{{hcloud_server_name}}"
state: absent
@@ -120,10 +120,10 @@
- name: verify cleanup create server network with specified ip
assert:
that:
- - result is changed
+ - result is changed
- name: test create server network with alias ips
- hcloud_server_network:
+ hetzner.hcloud.server_network:
network: "{{ hcloud_network_name }}"
server: "{{hcloud_server_name}}"
ip: "10.0.0.2"
@@ -135,15 +135,15 @@
- name: verify create server network with alias ips
assert:
that:
- - serverNetwork is changed
- - serverNetwork.hcloud_server_network.network == hcloud_network_name
- - serverNetwork.hcloud_server_network.server == hcloud_server_name
- - serverNetwork.hcloud_server_network.ip == "10.0.0.2"
- - 'serverNetwork.hcloud_server_network.alias_ips[0] == "10.0.2.3"'
- - 'serverNetwork.hcloud_server_network.alias_ips[1] == "10.0.1.2"'
+ - serverNetwork is changed
+ - serverNetwork.hcloud_server_network.network == hcloud_network_name
+ - serverNetwork.hcloud_server_network.server == hcloud_server_name
+ - serverNetwork.hcloud_server_network.ip == "10.0.0.2"
+ - 'serverNetwork.hcloud_server_network.alias_ips[0] == "10.0.2.3"'
+ - 'serverNetwork.hcloud_server_network.alias_ips[1] == "10.0.1.2"'
- name: test update server network with alias ips
- hcloud_server_network:
+ hetzner.hcloud.server_network:
network: "{{ hcloud_network_name }}"
server: "{{hcloud_server_name}}"
ip: "10.0.0.2"
@@ -155,15 +155,15 @@
- name: verify create server network with alias ips
assert:
that:
- - serverNetwork is changed
- - serverNetwork.hcloud_server_network.network == hcloud_network_name
- - serverNetwork.hcloud_server_network.server == hcloud_server_name
- - serverNetwork.hcloud_server_network.ip == "10.0.0.2"
- - 'serverNetwork.hcloud_server_network.alias_ips[0] == "10.0.2.3"'
- - 'serverNetwork.hcloud_server_network.alias_ips[1] == "10.0.3.1"'
+ - serverNetwork is changed
+ - serverNetwork.hcloud_server_network.network == hcloud_network_name
+ - serverNetwork.hcloud_server_network.server == hcloud_server_name
+ - serverNetwork.hcloud_server_network.ip == "10.0.0.2"
+ - 'serverNetwork.hcloud_server_network.alias_ips[0] == "10.0.2.3"'
+ - 'serverNetwork.hcloud_server_network.alias_ips[1] == "10.0.3.1"'
- name: test update server network with alias ips idempotency
- hcloud_server_network:
+ hetzner.hcloud.server_network:
network: "{{ hcloud_network_name }}"
server: "{{hcloud_server_name}}"
ip: "10.0.0.2"
@@ -175,10 +175,10 @@
- name: verify create server network with alias ips idempotency
assert:
that:
- - serverNetwork is not changed
+ - serverNetwork is not changed
- name: cleanup create server network with alias ips
- hcloud_server_network:
+ hetzner.hcloud.server_network:
network: "{{ hcloud_network_name }}"
server: "{{hcloud_server_name}}"
state: absent
@@ -186,20 +186,20 @@
- name: verify cleanup create server network with alias ips
assert:
that:
- - result is changed
+ - result is changed
- name: cleanup server
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
state: absent
register: result
- name: verify cleanup server
assert:
that:
- - result is success
+ - result is success
- name: cleanup subnetwork
- hcloud_subnetwork:
+ hetzner.hcloud.subnetwork:
network: "{{ hcloud_network_name }}"
ip_range: "10.0.0.0/16"
type: "server"
@@ -209,10 +209,10 @@
- name: verify cleanup subnetwork
assert:
that:
- - result is changed
+ - result is changed
- name: cleanup
- hcloud_network:
+ hetzner.hcloud.network:
name: "{{hcloud_network_name}}"
state: absent
register: result
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/server_type_info/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/server_type_info/aliases
new file mode 100644
index 000000000..0e887600e
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/server_type_info/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+azp/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/server_type_info/defaults/main/common.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/server_type_info/defaults/main/common.yml
new file mode 100644
index 000000000..e316b233c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/server_type_info/defaults/main/common.yml
@@ -0,0 +1,12 @@
+#
+# 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('first') | join() }}"
+hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/server_type_info/defaults/main/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/server_type_info/defaults/main/main.yml
new file mode 100644
index 000000000..c488c4dfc
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/server_type_info/defaults/main/main.yml
@@ -0,0 +1,7 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_server_type_name: cx11
+hcloud_server_type_id: 1
+
+hcloud_server_type_id_deprecated: 2 # cx11-ceph
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/server_type_info/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/server_type_info/tasks/main.yml
new file mode 100644
index 000000000..767fc465b
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/server_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/ansible_collections/hetzner/hcloud/tests/integration/targets/server_type_info/tasks/test.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/server_type_info/tasks/test.yml
new file mode 100644
index 000000000..9c51e09c1
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/server_type_info/tasks/test.yml
@@ -0,0 +1,69 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: Gather hcloud_server_type_info
+ hetzner.hcloud.server_type_info:
+ register: result
+- name: Verify hcloud_server_type_info
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_server_type_info | list | count >= 3
+
+- name: Gather hcloud_server_type_info in check mode
+ hetzner.hcloud.server_type_info:
+ check_mode: true
+ register: result
+- name: Verify hcloud_server_type_info in check mode
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_server_type_info | list | count >= 3
+
+- name: Gather hcloud_server_type_info with correct id
+ hetzner.hcloud.server_type_info:
+ id: "{{ hcloud_server_type_id }}"
+ register: result
+- name: Verify hcloud_server_type_info with correct id
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_server_type_info | list | count == 1
+ - result.hcloud_server_type_info[0].deprecation is none # fails if cx11 is ever deprecated
+
+- name: Gather hcloud_server_type_info with wrong id
+ hetzner.hcloud.server_type_info:
+ id: "{{ hcloud_server_type_id }}4321"
+ ignore_errors: true
+ register: result
+- name: Verify hcloud_server_type_info with wrong id
+ ansible.builtin.assert:
+ that:
+ - result is failed
+
+- name: Gather hcloud_server_type_info with correct name
+ hetzner.hcloud.server_type_info:
+ name: "{{ hcloud_server_type_name }}"
+ register: result
+- name: Verify hcloud_server_type_info with correct name
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_server_type_info | list | count == 1
+
+- name: Gather hcloud_server_type_info with wrong name
+ hetzner.hcloud.server_type_info:
+ name: "{{ hcloud_server_type_name }}-invalid"
+ register: result
+- name: Verify hcloud_server_type_info with wrong name
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_server_type_info | list | count == 0
+
+- name: Gather hcloud_server_type_info with deprecated field
+ hetzner.hcloud.server_type_info:
+ id: "{{ hcloud_server_type_id_deprecated }}"
+ register: result
+- name: Verify hcloud_server_type_info with deprecated field
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_server_type_info | list | count == 1
+ - result.hcloud_server_type_info[0].deprecation is not none
+ - result.hcloud_server_type_info[0].deprecation.announced == '2021-11-09T09:00:00+00:00'
+ - result.hcloud_server_type_info[0].deprecation.unavailable_after == '2021-12-01T00:00:00+00:00'
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/setup_hcloud_cli/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/setup_hcloud_cli/tasks/main.yml
new file mode 100644
index 000000000..7b5356b41
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/setup_hcloud_cli/tasks/main.yml
@@ -0,0 +1,16 @@
+---
+- name: Create temporary file for hcloud_cli_path
+ ansible.builtin.tempfile:
+ state: directory
+ register: _tmp_hcloud_cli
+
+- name: Download hcloud cli from Github releases
+ ansible.builtin.unarchive:
+ src: https://github.com/hetznercloud/cli/releases/download/v1.37.0/hcloud-linux-amd64.tar.gz
+ dest: "{{ _tmp_hcloud_cli.path }}"
+ remote_src: true
+ extra_opts: [hcloud]
+
+- name: Set hcloud_cli_path
+ ansible.builtin.set_fact:
+ hcloud_cli_path: "{{ _tmp_hcloud_cli.path }}/hcloud"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/setup_selfsigned_certificate/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/setup_selfsigned_certificate/tasks/main.yml
index 27defe44c..76d6e1791 100644
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/setup_selfsigned_certificate/tasks/main.yml
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/setup_selfsigned_certificate/tasks/main.yml
@@ -1,27 +1,35 @@
-# Copyright: (c) 2020, Hetzner Cloud GmbH <info@hetzner-cloud.de>
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: Create temporary file for test_certificate
+ ansible.builtin.tempfile:
+ suffix: "{{ hcloud_certificate_name }}"
+ register: _tmp_certificate_file
-- name: create a cert temp file
- tempfile:
- state: file
- register: certificate_example_com
- tags:
- - prepare
-- name: create a key temp file
- tempfile:
- state: file
- register: certificate_example_com_key
- tags:
- - prepare
- -
-- name: generate certificate
- shell: openssl req -nodes -new -x509 -keyout {{ certificate_example_com_key.path }} -out {{ certificate_example_com.path }} -subj "/C=DE/ST=Munich/L=Bavaria/O=Dis/CN=www.example.com"
- tags:
- - prepare
+- name: Create certificate privatekey file
+ community.crypto.openssl_privatekey:
+ path: "{{ _tmp_certificate_file.path }}.key"
+ return_content: true
+ register: _certificate_privatekey_file
-- name: set facts for future roles
- set_fact:
- certificate_example_com: "{{ lookup('file',certificate_example_com.path) }}"
- certificate_example_com_key: "{{ lookup('file',certificate_example_com_key.path) }}"
- tags:
- - prepare
+- name: Create certificate signing request file
+ community.crypto.openssl_csr:
+ privatekey_path: "{{ _tmp_certificate_file.path }}.key"
+ path: "{{ _tmp_certificate_file.path }}.csr"
+ country_name: DE
+ locality_name: Bavaria
+ state_or_province_name: Munich
+ organization_name: Dis
+ common_name: www.example.com
+
+- name: Create certificate file
+ community.crypto.x509_certificate:
+ privatekey_path: "{{ _tmp_certificate_file.path }}.key"
+ csr_path: "{{ _tmp_certificate_file.path }}.csr"
+ path: "{{ _tmp_certificate_file.path }}.crt"
+ provider: selfsigned
+ return_content: true
+ register: _certificate_file
+
+- name: Save certificate files content
+ ansible.builtin.set_fact:
+ test_certificate_privatekey_content: "{{ _certificate_privatekey_file.privatekey }}"
+ test_certificate_content: "{{ _certificate_file.certificate }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/setup_ssh_keypair/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/setup_ssh_keypair/tasks/main.yml
new file mode 100644
index 000000000..c51b42863
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/setup_ssh_keypair/tasks/main.yml
@@ -0,0 +1,19 @@
+---
+# https://github.com/ansible-collections/community.crypto/pull/504
+- name: Create temporary directory for test_ssh_keypair
+ ansible.builtin.file:
+ state: directory
+ path: ~/tmp
+ mode: "0755"
+
+- name: Create temporary file for test_ssh_keypair
+ ansible.builtin.tempfile:
+ path: ~/tmp
+ suffix: "{{ hcloud_ssh_key_name }}"
+ register: _tmp_ssh_key_file
+
+- name: Create test_ssh_keypair
+ community.crypto.openssh_keypair:
+ path: "{{ _tmp_ssh_key_file.path }}"
+ force: true
+ register: test_ssh_keypair
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/setup_sshkey/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/setup_sshkey/tasks/main.yml
deleted file mode 100644
index 18c571b67..000000000
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/setup_sshkey/tasks/main.yml
+++ /dev/null
@@ -1,55 +0,0 @@
-# (c) 2014, James Laska <jlaska@ansible.com>
-
-# This file is part of Ansible
-#
-# Ansible is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Ansible is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-
-- name: create a temp file
- tempfile:
- state: file
- register: sshkey_file
- tags:
- - prepare
-
-- name: generate sshkey
- shell: echo 'y' | ssh-keygen -P '' -f {{ sshkey_file.path }}
- tags:
- - prepare
-
-- name: create another temp file
- tempfile:
- state: file
- register: another_sshkey_file
- tags:
- - prepare
-
-- name: generate another_sshkey
- shell: echo 'y' | ssh-keygen -P '' -f {{ another_sshkey_file.path }}
- tags:
- - prepare
-
-- name: record fingerprint
- shell: openssl rsa -in {{ sshkey_file.path }} -pubout -outform DER 2>/dev/null | openssl md5 -c
- register: fingerprint
- tags:
- - prepare
-
-- name: set facts for future roles
- set_fact:
- sshkey: '{{ sshkey_file.path }}'
- key_material: "{{ lookup('file', sshkey_file.path ~ '.pub') }}"
- another_key_material: "{{ lookup('file', another_sshkey_file.path ~ '.pub') }}"
- fingerprint: '{{ fingerprint.stdout.split()[1] }}'
- tags:
- - prepare
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key/aliases
new file mode 100644
index 000000000..0e887600e
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+azp/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key/defaults/main/common.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key/defaults/main/common.yml
new file mode 100644
index 000000000..e316b233c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key/defaults/main/common.yml
@@ -0,0 +1,12 @@
+#
+# 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('first') | join() }}"
+hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_firewall/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key/defaults/main/main.yml
index e7eff02a7..87c4d8e31 100644
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_firewall/defaults/main.yml
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key/defaults/main/main.yml
@@ -1,5 +1,5 @@
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
-hcloud_prefix: "tests"
-hcloud_firewall_name: "{{hcloud_prefix}}-integration"
+hcloud_server_name: "{{ hcloud_ns }}"
+hcloud_ssh_key_name: "{{ hcloud_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key/meta/main.yml
new file mode 100644
index 000000000..3a96ecb2d
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_ssh_keypair
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key/tasks/cleanup.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key/tasks/cleanup.yml
new file mode 100644
index 000000000..fea3ff06d
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key/tasks/cleanup.yml
@@ -0,0 +1,10 @@
+---
+- name: Cleanup test_ssh_key
+ hetzner.hcloud.ssh_key:
+ name: "{{ hcloud_ssh_key_name }}"
+ state: absent
+
+- name: Cleanup test_server
+ hetzner.hcloud.server:
+ name: "{{ hcloud_server_name }}"
+ state: absent
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key/tasks/main.yml
new file mode 100644
index 000000000..767fc465b
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key/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/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key/tasks/test.yml
index 9208e143d..41b9c351d 100644
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/tasks/main.yml
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key/tasks/test.yml
@@ -2,10 +2,10 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
- name: test missing required parameters on create ssh_key
- hcloud_ssh_key:
+ hetzner.hcloud.ssh_key:
name: "{{ hcloud_ssh_key_name }}"
register: result
- ignore_errors: yes
+ ignore_errors: true
- name: verify fail test missing required parameters on create ssh_key
assert:
that:
@@ -13,36 +13,36 @@
- 'result.msg == "missing required arguments: public_key"'
- name: test create ssh key with check mode
- hcloud_ssh_key:
+ hetzner.hcloud.ssh_key:
name: "{{ hcloud_ssh_key_name }}"
- public_key: "{{ key_material }}"
+ public_key: "{{ test_ssh_keypair.public_key }}"
register: result
- check_mode: yes
+ check_mode: true
- name: test create ssh key with check mode
assert:
that:
- result is changed
- name: test create ssh key
- hcloud_ssh_key:
+ hetzner.hcloud.ssh_key:
name: "{{ hcloud_ssh_key_name }}"
- public_key: "{{ key_material }}"
+ public_key: "{{ test_ssh_keypair.public_key }}"
labels:
key: value
my-label: label
- register: sshKey
+ register: ssh_key
- name: verify create ssh key
assert:
that:
- - sshKey is changed
- - sshKey.hcloud_ssh_key.name == "{{ hcloud_ssh_key_name }}"
- - sshKey.hcloud_ssh_key.public_key == "{{ key_material }}"
- - sshKey.hcloud_ssh_key.labels.key == "value"
+ - ssh_key is changed
+ - ssh_key.hcloud_ssh_key.name == hcloud_ssh_key_name
+ - ssh_key.hcloud_ssh_key.public_key == test_ssh_keypair.public_key
+ - ssh_key.hcloud_ssh_key.labels.key == "value"
- name: test create ssh key idempotence
- hcloud_ssh_key:
+ hetzner.hcloud.ssh_key:
name: "{{ hcloud_ssh_key_name }}"
- public_key: "{{ key_material }}"
+ public_key: "{{ test_ssh_keypair.public_key }}"
register: result
- name: verify create ssh key idempotence
assert:
@@ -50,19 +50,19 @@
- result is not changed
- name: test update ssh key with check mode
- hcloud_ssh_key:
- id: "{{ sshKey.hcloud_ssh_key.id }}"
+ hetzner.hcloud.ssh_key:
+ id: "{{ ssh_key.hcloud_ssh_key.id }}"
name: "changed-{{ hcloud_ssh_key_name }}"
register: result
- check_mode: yes
+ check_mode: true
- name: test create ssh key with check mode
assert:
that:
- result is changed
- name: test update ssh key
- hcloud_ssh_key:
- id: "{{ sshKey.hcloud_ssh_key.id }}"
+ hetzner.hcloud.ssh_key:
+ id: "{{ ssh_key.hcloud_ssh_key.id }}"
name: "changed-{{ hcloud_ssh_key_name }}"
labels:
key: value
@@ -74,8 +74,8 @@
- result.hcloud_ssh_key.name == "changed-{{ hcloud_ssh_key_name }}"
- name: test update ssh key with same labels
- hcloud_ssh_key:
- id: "{{ sshKey.hcloud_ssh_key.id }}"
+ hetzner.hcloud.ssh_key:
+ id: "{{ ssh_key.hcloud_ssh_key.id }}"
name: "changed-{{ hcloud_ssh_key_name }}"
labels:
key: value
@@ -86,8 +86,8 @@
- result is not changed
- name: test update ssh key with other labels
- hcloud_ssh_key:
- id: "{{ sshKey.hcloud_ssh_key.id }}"
+ hetzner.hcloud.ssh_key:
+ id: "{{ ssh_key.hcloud_ssh_key.id }}"
name: "changed-{{ hcloud_ssh_key_name }}"
labels:
key: value
@@ -99,21 +99,21 @@
- result is changed
- name: test rename ssh key
- hcloud_ssh_key:
- id: "{{ sshKey.hcloud_ssh_key.id }}"
+ hetzner.hcloud.ssh_key:
+ id: "{{ ssh_key.hcloud_ssh_key.id }}"
name: "{{ hcloud_ssh_key_name }}"
register: result
- name: test rename ssh key
assert:
that:
- result is changed
- - result.hcloud_ssh_key.name == "{{ hcloud_ssh_key_name }}"
+ - result.hcloud_ssh_key.name == hcloud_ssh_key_name
- name: test create server with ssh key
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
server_type: cx11
- image: "ubuntu-20.04"
+ image: "ubuntu-22.04"
ssh_keys:
- "{{ hcloud_ssh_key_name }}"
state: started
@@ -123,34 +123,24 @@
that:
- main_server is changed
-- name: absent ssh key
- hcloud_ssh_key:
- id: "{{ sshKey.hcloud_ssh_key.id }}"
- state: absent
- register: result
-- name: verify absent sshkey
- assert:
- that:
- - result is success
-
- name: test fail cleanly on double created ssh key
- hcloud_ssh_key:
- name: "{{ hcloud_ssh_key_name }}othername"
- public_key: "{{ hcloud_doubled_ssh_key_public_key }}"
+ hetzner.hcloud.ssh_key:
+ name: "{{ hcloud_ssh_key_name }}-other-name"
+ public_key: "{{ test_ssh_keypair.public_key }}"
register: result
- ignore_errors: yes
+ ignore_errors: true
- name: verify failed correctly
assert:
that:
- result is failed
- 'result.msg == "SSH key with the same fingerprint already exists"'
-- name: cleanup
- hcloud_server:
- name: "{{ hcloud_server_name }}"
+- name: test delete ssh key
+ hetzner.hcloud.ssh_key:
+ id: "{{ ssh_key.hcloud_ssh_key.id }}"
state: absent
register: result
-- name: verify cleanup
+- name: verify absent ssh_key
assert:
that:
- result is success
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key_info/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key_info/aliases
new file mode 100644
index 000000000..0e887600e
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key_info/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+azp/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key_info/defaults/main/common.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key_info/defaults/main/common.yml
new file mode 100644
index 000000000..e316b233c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key_info/defaults/main/common.yml
@@ -0,0 +1,12 @@
+#
+# 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('first') | join() }}"
+hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key_info/defaults/main/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key_info/defaults/main/main.yml
new file mode 100644
index 000000000..68a7f5a35
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key_info/defaults/main/main.yml
@@ -0,0 +1,4 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_ssh_key_name: "{{ hcloud_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key_info/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key_info/meta/main.yml
new file mode 100644
index 000000000..3a96ecb2d
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key_info/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_ssh_keypair
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key_info/tasks/cleanup.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key_info/tasks/cleanup.yml
new file mode 100644
index 000000000..8066c4115
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key_info/tasks/cleanup.yml
@@ -0,0 +1,5 @@
+---
+- name: Cleanup test_ssh_key
+ hetzner.hcloud.ssh_key:
+ name: "{{ hcloud_ssh_key_name }}"
+ state: absent
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key_info/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key_info/tasks/main.yml
new file mode 100644
index 000000000..767fc465b
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key_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/ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key_info/tasks/prepare.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key_info/tasks/prepare.yml
new file mode 100644
index 000000000..519bc8526
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key_info/tasks/prepare.yml
@@ -0,0 +1,8 @@
+---
+- name: Create test_ssh_key
+ hetzner.hcloud.ssh_key:
+ name: "{{ hcloud_ssh_key_name }}"
+ public_key: "{{ test_ssh_keypair.public_key }}"
+ labels:
+ key: value
+ register: test_ssh_key
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key_info/tasks/test.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key_info/tasks/test.yml
new file mode 100644
index 000000000..d8ea7cb37
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/ssh_key_info/tasks/test.yml
@@ -0,0 +1,77 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: Gather hcloud_ssh_key_info
+ hetzner.hcloud.ssh_key_info:
+ register: result
+- name: Verify hcloud_ssh_key_info
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_ssh_key_info | list | count >= 1
+
+- name: Gather hcloud_ssh_key_info in check mode
+ hetzner.hcloud.ssh_key_info:
+ check_mode: true
+ register: result
+- name: Verify hcloud_ssh_key_info in check mode
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_ssh_key_info | list | count >= 1
+
+- name: Gather hcloud_ssh_key_info with correct id
+ hetzner.hcloud.ssh_key_info:
+ id: "{{ test_ssh_key.hcloud_ssh_key.id }}"
+ register: result
+- name: Verify hcloud_ssh_key_info with correct id
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_ssh_key_info | list | count == 1
+
+- name: Gather hcloud_ssh_key_info with wrong id
+ hetzner.hcloud.ssh_key_info:
+ id: "{{ test_ssh_key.hcloud_ssh_key.id }}4321"
+ ignore_errors: true
+ register: result
+- name: Verify hcloud_ssh_key_info with wrong id
+ ansible.builtin.assert:
+ that:
+ - result is failed
+
+- name: Gather hcloud_ssh_key_info with correct name
+ hetzner.hcloud.ssh_key_info:
+ name: "{{ hcloud_ssh_key_name }}"
+ register: result
+- name: Verify hcloud_ssh_key_info with correct name
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_ssh_key_info | list | count == 1
+
+- name: Gather hcloud_ssh_key_info with wrong name
+ hetzner.hcloud.ssh_key_info:
+ name: "{{ hcloud_ssh_key_name }}-invalid"
+ register: result
+- name: Verify hcloud_ssh_key_info with wrong name
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_ssh_key_info | list | count == 0
+
+- name: Gather hcloud_ssh_key_info with correct label selector
+ hetzner.hcloud.ssh_key_info:
+ label_selector: "key=value"
+ register: result
+- name: Verify hcloud_ssh_key_info with correct label selector
+ ansible.builtin.assert:
+ that:
+ - >
+ result.hcloud_ssh_key_info
+ | selectattr('name', 'equalto', hcloud_ssh_key_name)
+ | list | count == 1
+
+- name: Gather hcloud_ssh_key_info with wrong label selector
+ hetzner.hcloud.ssh_key_info:
+ label_selector: "key!=value"
+ register: result
+- name: Verify hcloud_ssh_key_info with wrong label selector
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_ssh_key_info | list | count == 0
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/subnetwork/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/subnetwork/aliases
new file mode 100644
index 000000000..a6a90a6bf
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/subnetwork/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+azp/group3
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/subnetwork/defaults/main/common.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/subnetwork/defaults/main/common.yml
new file mode 100644
index 000000000..e316b233c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/subnetwork/defaults/main/common.yml
@@ -0,0 +1,12 @@
+#
+# 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('first') | join() }}"
+hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/subnetwork/defaults/main/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/subnetwork/defaults/main/main.yml
new file mode 100644
index 000000000..afaa77652
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/subnetwork/defaults/main/main.yml
@@ -0,0 +1,23 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_network_name: "{{ hcloud_ns }}"
+# Pool of external Hetzner vSwitch ID, this prevents using the same vSwitch id twice in
+# different jobs.
+hetzner_vswitch_ids:
+ - 43065
+ - 44166
+ - 44167
+ - 44168
+ - 44170
+ - 44171
+ - 44172
+ - 44173
+ - 44174
+ - 44175
+ - 44176
+ - 44177
+ - 44178
+ - 44179
+ - 44180
+ - 44181
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/subnetwork/tasks/cleanup.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/subnetwork/tasks/cleanup.yml
new file mode 100644
index 000000000..989d01b80
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/subnetwork/tasks/cleanup.yml
@@ -0,0 +1,5 @@
+---
+- name: Cleanup test_network
+ hetzner.hcloud.network:
+ name: "{{ hcloud_network_name }}"
+ state: absent
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/subnetwork/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/subnetwork/tasks/main.yml
new file mode 100644
index 000000000..767fc465b
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/subnetwork/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/ansible_collections/hetzner/hcloud/tests/integration/targets/subnetwork/tasks/prepare.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/subnetwork/tasks/prepare.yml
new file mode 100644
index 000000000..69a709ddf
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/subnetwork/tasks/prepare.yml
@@ -0,0 +1,11 @@
+---
+- name: Create test_network
+ hetzner.hcloud.network:
+ name: "{{ hcloud_network_name }}"
+ ip_range: "10.0.0.0/16"
+ state: present
+ register: test_network
+
+- name: Select hetzner vswitch id from pool
+ ansible.builtin.set_fact:
+ test_vswitch_id: "{{ hetzner_vswitch_ids | random }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/subnetwork/tasks/test.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/subnetwork/tasks/test.yml
new file mode 100644
index 000000000..acde98f7b
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/subnetwork/tasks/test.yml
@@ -0,0 +1,103 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: Test missing required parameters
+ hetzner.hcloud.subnetwork:
+ network: "{{ hcloud_network_name }}"
+ state: present
+ ignore_errors: true
+ register: result
+- name: Verify missing required parameters
+ ansible.builtin.assert:
+ that:
+ - result is failed
+ - 'result.msg == "missing required arguments: ip_range, network_zone, type"'
+
+- name: Test create with checkmode
+ hetzner.hcloud.subnetwork:
+ network: "{{ hcloud_network_name }}"
+ network_zone: eu-central
+ type: cloud
+ ip_range: 10.0.0.0/24
+ state: present
+ check_mode: true
+ register: result
+- name: Verify create with checkmode
+ ansible.builtin.assert:
+ that:
+ - result is changed
+
+- name: Test create
+ hetzner.hcloud.subnetwork:
+ network: "{{ hcloud_network_name }}"
+ network_zone: eu-central
+ type: cloud
+ ip_range: 10.0.0.0/24
+ state: present
+ register: result
+- name: Verify create
+ ansible.builtin.assert:
+ that:
+ - result is changed
+ - result.hcloud_subnetwork.network == hcloud_network_name
+ - result.hcloud_subnetwork.network_zone == "eu-central"
+ - result.hcloud_subnetwork.type == "cloud"
+ - result.hcloud_subnetwork.ip_range == "10.0.0.0/24"
+
+- name: Test create idempotency
+ hetzner.hcloud.subnetwork:
+ network: "{{ hcloud_network_name }}"
+ network_zone: eu-central
+ type: cloud
+ ip_range: 10.0.0.0/24
+ state: present
+ register: result
+- name: Verify create idempotency
+ ansible.builtin.assert:
+ that:
+ - result is not changed
+
+- name: Test delete
+ hetzner.hcloud.subnetwork:
+ network: "{{ hcloud_network_name }}"
+ network_zone: eu-central
+ type: cloud
+ ip_range: 10.0.0.0/24
+ state: absent
+ register: result
+- name: Verify delete
+ ansible.builtin.assert:
+ that:
+ - result is changed
+
+- name: Test create with vswitch
+ hetzner.hcloud.subnetwork:
+ network: "{{ hcloud_network_name }}"
+ network_zone: eu-central
+ type: vswitch
+ ip_range: 10.0.1.0/24
+ vswitch_id: "{{ test_vswitch_id }}"
+ state: present
+ register: result
+- name: Verify create with vswitch
+ ansible.builtin.assert:
+ that:
+ - result is changed
+ - result.hcloud_subnetwork.network == hcloud_network_name
+ - result.hcloud_subnetwork.network_zone == "eu-central"
+ - result.hcloud_subnetwork.type == "vswitch"
+ - result.hcloud_subnetwork.ip_range == "10.0.1.0/24"
+ - result.hcloud_subnetwork.vswitch_id | string == test_vswitch_id
+
+- name: Test delete with vswitch
+ hetzner.hcloud.subnetwork:
+ network: "{{ hcloud_network_name }}"
+ network_zone: eu-central
+ type: vswitch
+ ip_range: 10.0.1.0/24
+ state: absent
+ register: subnet
+- name: Verify delete with vswitch
+ ansible.builtin.assert:
+ that:
+ - result is changed
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/volume/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/volume/aliases
new file mode 100644
index 000000000..0e887600e
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/volume/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+azp/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/volume/defaults/main/common.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/volume/defaults/main/common.yml
new file mode 100644
index 000000000..e316b233c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/volume/defaults/main/common.yml
@@ -0,0 +1,12 @@
+#
+# 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('first') | join() }}"
+hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/volume/defaults/main/main.yml
index 6205b19b4..65949c814 100644
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/defaults/main.yml
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/volume/defaults/main/main.yml
@@ -1,5 +1,5 @@
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
-hcloud_prefix: "tests"
-hcloud_certificate_name: "always-there-cert"
+hcloud_volume_name: "{{ hcloud_ns }}"
+hcloud_server_name: "{{ hcloud_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/volume/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/volume/tasks/main.yml
new file mode 100644
index 000000000..767fc465b
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/volume/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/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/volume/tasks/test.yml
index f763a52f2..fd47d5343 100644
--- a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/tasks/main.yml
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/volume/tasks/test.yml
@@ -2,10 +2,10 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
- name: setup server
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{hcloud_server_name}}"
server_type: cx11
- image: ubuntu-18.04
+ image: ubuntu-22.04
state: started
location: "fsn1"
register: vol_server
@@ -15,11 +15,11 @@
- vol_server is changed
- name: test missing size parameter on create Volume
- hcloud_volume:
+ hetzner.hcloud.volume:
name: "{{hcloud_volume_name}}"
server: "{{hcloud_server_name}}"
register: result
- ignore_errors: yes
+ ignore_errors: true
- name: verify fail test missing size parameter on create Volume
assert:
that:
@@ -27,19 +27,19 @@
- 'result.msg == "missing required arguments: size"'
- name: test create Volume with check mode
- hcloud_volume:
+ hetzner.hcloud.volume:
name: "{{hcloud_volume_name}}"
size: 10
location: "fsn1"
register: result
- check_mode: yes
+ check_mode: true
- name: verify create Volume with check mode result
assert:
that:
- result is changed
- name: test create Volume
- hcloud_volume:
+ hetzner.hcloud.volume:
name: "{{hcloud_volume_name}}"
size: 10
location: "fsn1"
@@ -48,14 +48,14 @@
assert:
that:
- volume is changed
- - volume.hcloud_volume.name == "{{hcloud_volume_name}}"
+ - volume.hcloud_volume.name == hcloud_volume_name
- volume.hcloud_volume.location == "fsn1"
- volume.hcloud_volume.size == 10
- - volume.hcloud_volume.server != "{{hcloud_server_name}}"
+ - volume.hcloud_volume.server != hcloud_server_name
- volume.hcloud_volume.linux_device is defined
- name: test create Volume idempotence
- hcloud_volume:
+ hetzner.hcloud.volume:
name: "{{hcloud_volume_name}}"
size: 10
location: "fsn1"
@@ -66,19 +66,19 @@
- volume is not changed
- name: test attach Volume with checkmode
- hcloud_volume:
+ hetzner.hcloud.volume:
name: "{{hcloud_volume_name}}"
server: "{{hcloud_server_name}}"
- check_mode: yes
+ check_mode: true
register: volume
- name: verify test attach Volume with checkmode
assert:
that:
- volume is changed
- - volume.hcloud_volume.server != "{{hcloud_server_name}}"
+ - volume.hcloud_volume.server != hcloud_server_name
- name: test attach Volume
- hcloud_volume:
+ hetzner.hcloud.volume:
name: "{{hcloud_volume_name}}"
server: "{{hcloud_server_name}}"
register: volume
@@ -86,10 +86,10 @@
assert:
that:
- volume is changed
- - volume.hcloud_volume.server == "{{hcloud_server_name}}"
+ - volume.hcloud_volume.server == hcloud_server_name
- name: test attach Volume idempotence
- hcloud_volume:
+ hetzner.hcloud.volume:
name: "{{hcloud_volume_name}}"
server: "{{hcloud_server_name}}"
register: volume
@@ -97,21 +97,21 @@
assert:
that:
- volume is not changed
- - volume.hcloud_volume.server == "{{hcloud_server_name}}"
+ - volume.hcloud_volume.server == hcloud_server_name
- name: test detach Volume with checkmode
- hcloud_volume:
+ hetzner.hcloud.volume:
name: "{{hcloud_volume_name}}"
- check_mode: yes
+ check_mode: true
register: volume
- name: verify detach Volume with checkmode
assert:
that:
- volume is changed
- - volume.hcloud_volume.server == "{{hcloud_server_name}}"
+ - volume.hcloud_volume.server == hcloud_server_name
- name: test detach Volume
- hcloud_volume:
+ hetzner.hcloud.volume:
name: "{{hcloud_volume_name}}"
register: volume
- name: verify detach volume
@@ -119,10 +119,10 @@
that:
- volume is changed
- volume.hcloud_volume.location == "fsn1"
- - volume.hcloud_volume.server != "{{hcloud_server_name}}"
+ - volume.hcloud_volume.server != hcloud_server_name
- name: test update Volume label
- hcloud_volume:
+ hetzner.hcloud.volume:
name: "{{hcloud_volume_name}}"
labels:
key: value
@@ -134,7 +134,7 @@
- volume.hcloud_volume.labels.key == "value"
- name: test update Volume label with the same label
- hcloud_volume:
+ hetzner.hcloud.volume:
name: "{{hcloud_volume_name}}"
labels:
key: value
@@ -145,7 +145,7 @@
- volume is not changed
- name: test increase Volume size
- hcloud_volume:
+ hetzner.hcloud.volume:
name: "{{hcloud_volume_name}}"
size: 11
register: volume
@@ -156,7 +156,7 @@
- volume.hcloud_volume.size == 11
- name: test decreace Volume size
- hcloud_volume:
+ hetzner.hcloud.volume:
name: "{{hcloud_volume_name}}"
size: 10
register: volume
@@ -167,7 +167,7 @@
- volume.hcloud_volume.size == 11
- name: test update Volume delete protection
- hcloud_volume:
+ hetzner.hcloud.volume:
name: "{{hcloud_volume_name}}"
delete_protection: true
register: volume
@@ -178,7 +178,7 @@
- volume.hcloud_volume.delete_protection is sameas true
- name: test update Volume delete protection idempotency
- hcloud_volume:
+ hetzner.hcloud.volume:
name: "{{hcloud_volume_name}}"
delete_protection: true
register: volume
@@ -189,7 +189,7 @@
- volume.hcloud_volume.delete_protection is sameas true
- name: test Volume without delete protection set to be idempotent
- hcloud_volume:
+ hetzner.hcloud.volume:
name: "{{hcloud_volume_name}}"
register: volume
- name: verify test Volume without delete protection set to be idempotent
@@ -199,10 +199,10 @@
- volume.hcloud_volume.delete_protection is sameas true
- name: test delete Volume fails if it is protected
- hcloud_volume:
+ hetzner.hcloud.volume:
name: "{{hcloud_volume_name}}"
state: absent
- ignore_errors: yes
+ ignore_errors: true
register: result
- name: verify delete Volume fails if it is protected
assert:
@@ -211,7 +211,7 @@
- 'result.msg == "volume deletion is protected"'
- name: test update Volume delete protection
- hcloud_volume:
+ hetzner.hcloud.volume:
name: "{{hcloud_volume_name}}"
delete_protection: false
register: volume
@@ -222,7 +222,7 @@
- volume.hcloud_volume.delete_protection is sameas false
- name: test delete Volume
- hcloud_volume:
+ hetzner.hcloud.volume:
name: "{{hcloud_volume_name}}"
state: absent
register: result
@@ -231,9 +231,8 @@
that:
- result is success
-
- name: test create Volume with delete protection
- hcloud_volume:
+ hetzner.hcloud.volume:
name: "{{hcloud_volume_name}}"
size: 10
location: "fsn1"
@@ -246,10 +245,10 @@
- volume.hcloud_volume.delete_protection is sameas true
- name: test delete Volume fails if it is protected
- hcloud_volume:
+ hetzner.hcloud.volume:
name: "{{hcloud_volume_name}}"
state: absent
- ignore_errors: yes
+ ignore_errors: true
register: result
- name: verify delete Volume fails if it is protected
assert:
@@ -258,7 +257,7 @@
- 'result.msg == "volume deletion is protected"'
- name: test update Volume delete protection
- hcloud_volume:
+ hetzner.hcloud.volume:
name: "{{hcloud_volume_name}}"
delete_protection: false
register: volume
@@ -269,7 +268,7 @@
- volume.hcloud_volume.delete_protection is sameas false
- name: test delete Volume
- hcloud_volume:
+ hetzner.hcloud.volume:
name: "{{hcloud_volume_name}}"
state: absent
register: result
@@ -279,11 +278,11 @@
- result is success
- name: cleanup
- hcloud_server:
+ hetzner.hcloud.server:
name: "{{ hcloud_server_name }}"
state: absent
register: result
- name: verify cleanup
assert:
that:
- - result is success
+ - result is success
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/volume_info/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/volume_info/aliases
new file mode 100644
index 000000000..0e887600e
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/volume_info/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+azp/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/volume_info/defaults/main/common.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/volume_info/defaults/main/common.yml
new file mode 100644
index 000000000..e316b233c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/volume_info/defaults/main/common.yml
@@ -0,0 +1,12 @@
+#
+# 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('first') | join() }}"
+hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/volume_info/defaults/main/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/volume_info/defaults/main/main.yml
new file mode 100644
index 000000000..e243ee062
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/volume_info/defaults/main/main.yml
@@ -0,0 +1,4 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_volume_name: "{{ hcloud_ns }}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/volume_info/tasks/cleanup.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/volume_info/tasks/cleanup.yml
new file mode 100644
index 000000000..8fa589a43
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/volume_info/tasks/cleanup.yml
@@ -0,0 +1,5 @@
+---
+- name: Cleanup test_volume
+ hetzner.hcloud.volume:
+ name: "{{ hcloud_volume_name }}"
+ state: absent
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/volume_info/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/volume_info/tasks/main.yml
new file mode 100644
index 000000000..767fc465b
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/volume_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/ansible_collections/hetzner/hcloud/tests/integration/targets/volume_info/tasks/prepare.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/volume_info/tasks/prepare.yml
new file mode 100644
index 000000000..de3c70b42
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/volume_info/tasks/prepare.yml
@@ -0,0 +1,9 @@
+---
+- name: Create test_volume
+ hetzner.hcloud.volume:
+ name: "{{ hcloud_volume_name }}"
+ size: 10
+ location: fsn1
+ labels:
+ key: value
+ register: test_volume
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/volume_info/tasks/test.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/volume_info/tasks/test.yml
new file mode 100644
index 000000000..79912029b
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/volume_info/tasks/test.yml
@@ -0,0 +1,81 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: Gather hcloud_volume_info
+ hetzner.hcloud.volume_info:
+ register: result
+- name: Verify hcloud_volume_info
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_volume_info | list | count >= 1
+
+- name: Gather hcloud_volume_info in check mode
+ hetzner.hcloud.volume_info:
+ check_mode: true
+ register: result
+- name: Verify hcloud_volume_info in check mode
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_volume_info | list | count >= 1
+
+- name: Gather hcloud_volume_info with correct id
+ hetzner.hcloud.volume_info:
+ id: "{{ test_volume.hcloud_volume.id }}"
+ register: result
+- name: Verify hcloud_volume_info with correct id
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_volume_info | list | count == 1
+ - result.hcloud_volume_info[0].name == hcloud_volume_name
+ - result.hcloud_volume_info[0].location == 'fsn1'
+ - result.hcloud_volume_info[0].size == 10
+ - result.hcloud_volume_info[0].linux_device is defined
+
+- name: Gather hcloud_volume_info with wrong id
+ hetzner.hcloud.volume_info:
+ id: "{{ test_volume.hcloud_volume.id }}4321"
+ ignore_errors: true
+ register: result
+- name: Verify hcloud_volume_info with wrong id
+ ansible.builtin.assert:
+ that:
+ - result is failed
+
+- name: Gather hcloud_volume_info with correct name
+ hetzner.hcloud.volume_info:
+ name: "{{ hcloud_volume_name }}"
+ register: result
+- name: Verify hcloud_volume_info with correct name
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_volume_info | list | count == 1
+
+- name: Gather hcloud_volume_info with wrong name
+ hetzner.hcloud.volume_info:
+ name: "{{ hcloud_volume_name }}-invalid"
+ register: result
+- name: Verify hcloud_volume_info with wrong name
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_volume_info | list | count == 0
+
+- name: Gather hcloud_volume_info with correct label selector
+ hetzner.hcloud.volume_info:
+ label_selector: "key=value"
+ register: result
+- name: Verify hcloud_volume_info with correct label selector
+ ansible.builtin.assert:
+ that:
+ - >
+ result.hcloud_volume_info
+ | selectattr('name', 'equalto', hcloud_volume_name)
+ | list | count == 1
+
+- name: Gather hcloud_volume_info with wrong label selector
+ hetzner.hcloud.volume_info:
+ label_selector: "key!=value"
+ register: result
+- name: Verify hcloud_volume_info with wrong label selector
+ ansible.builtin.assert:
+ that:
+ - result.hcloud_volume_info | list | count == 0
diff --git a/ansible_collections/hetzner/hcloud/tests/requirements.yml b/ansible_collections/hetzner/hcloud/tests/requirements.yml
index 6c49d0d9e..3fea3f392 100644
--- a/ansible_collections/hetzner/hcloud/tests/requirements.yml
+++ b/ansible_collections/hetzner/hcloud/tests/requirements.yml
@@ -1,3 +1,5 @@
-integration_tests_dependencies:
-- community.general
-- ansible.netcommon
+---
+collections:
+ - ansible.utils
+ - community.crypto
+ - community.general
diff --git a/ansible_collections/hetzner/hcloud/tests/sanity/ignore-2.12.txt b/ansible_collections/hetzner/hcloud/tests/sanity/ignore-2.12.txt
deleted file mode 100644
index caf221794..000000000
--- a/ansible_collections/hetzner/hcloud/tests/sanity/ignore-2.12.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-tests/utils/shippable/check_matrix.py replace-urlopen
-tests/utils/shippable/timing.py shebang
diff --git a/ansible_collections/hetzner/hcloud/tests/sanity/ignore-2.13.txt b/ansible_collections/hetzner/hcloud/tests/sanity/ignore-2.13.txt
index caf221794..185a458e3 100644
--- a/ansible_collections/hetzner/hcloud/tests/sanity/ignore-2.13.txt
+++ b/ansible_collections/hetzner/hcloud/tests/sanity/ignore-2.13.txt
@@ -1,2 +1,69 @@
-tests/utils/shippable/check_matrix.py replace-urlopen
-tests/utils/shippable/timing.py shebang
+plugins/inventory/hcloud.py validate-modules:illegal-future-imports
+plugins/inventory/hcloud.py validate-modules:import-before-documentation
+plugins/inventory/hcloud.py yamllint:unparsable-with-libyaml # bug in ansible-test - https://github.com/ansible/ansible/issues/82353
+plugins/modules/certificate_info.py validate-modules:illegal-future-imports
+plugins/modules/certificate_info.py validate-modules:import-before-documentation
+plugins/modules/certificate.py validate-modules:illegal-future-imports
+plugins/modules/certificate.py validate-modules:import-before-documentation
+plugins/modules/datacenter_info.py validate-modules:illegal-future-imports
+plugins/modules/datacenter_info.py validate-modules:import-before-documentation
+plugins/modules/firewall_info.py validate-modules:illegal-future-imports
+plugins/modules/firewall_info.py validate-modules:import-before-documentation
+plugins/modules/firewall_resource.py validate-modules:illegal-future-imports
+plugins/modules/firewall_resource.py validate-modules:import-before-documentation
+plugins/modules/firewall.py validate-modules:illegal-future-imports
+plugins/modules/firewall.py validate-modules:import-before-documentation
+plugins/modules/floating_ip_info.py validate-modules:illegal-future-imports
+plugins/modules/floating_ip_info.py validate-modules:import-before-documentation
+plugins/modules/floating_ip.py validate-modules:illegal-future-imports
+plugins/modules/floating_ip.py validate-modules:import-before-documentation
+plugins/modules/image_info.py validate-modules:illegal-future-imports
+plugins/modules/image_info.py validate-modules:import-before-documentation
+plugins/modules/iso_info.py validate-modules:illegal-future-imports
+plugins/modules/iso_info.py validate-modules:import-before-documentation
+plugins/modules/load_balancer_info.py validate-modules:illegal-future-imports
+plugins/modules/load_balancer_info.py validate-modules:import-before-documentation
+plugins/modules/load_balancer_network.py validate-modules:illegal-future-imports
+plugins/modules/load_balancer_network.py validate-modules:import-before-documentation
+plugins/modules/load_balancer_service.py validate-modules:illegal-future-imports
+plugins/modules/load_balancer_service.py validate-modules:import-before-documentation
+plugins/modules/load_balancer_target.py validate-modules:illegal-future-imports
+plugins/modules/load_balancer_target.py validate-modules:import-before-documentation
+plugins/modules/load_balancer_type_info.py validate-modules:illegal-future-imports
+plugins/modules/load_balancer_type_info.py validate-modules:import-before-documentation
+plugins/modules/load_balancer.py validate-modules:illegal-future-imports
+plugins/modules/load_balancer.py validate-modules:import-before-documentation
+plugins/modules/location_info.py validate-modules:illegal-future-imports
+plugins/modules/location_info.py validate-modules:import-before-documentation
+plugins/modules/network_info.py validate-modules:illegal-future-imports
+plugins/modules/network_info.py validate-modules:import-before-documentation
+plugins/modules/network.py validate-modules:illegal-future-imports
+plugins/modules/network.py validate-modules:import-before-documentation
+plugins/modules/placement_group.py validate-modules:illegal-future-imports
+plugins/modules/placement_group.py validate-modules:import-before-documentation
+plugins/modules/primary_ip_info.py validate-modules:illegal-future-imports
+plugins/modules/primary_ip_info.py validate-modules:import-before-documentation
+plugins/modules/primary_ip.py validate-modules:illegal-future-imports
+plugins/modules/primary_ip.py validate-modules:import-before-documentation
+plugins/modules/rdns.py validate-modules:illegal-future-imports
+plugins/modules/rdns.py validate-modules:import-before-documentation
+plugins/modules/route.py validate-modules:illegal-future-imports
+plugins/modules/route.py validate-modules:import-before-documentation
+plugins/modules/server_info.py validate-modules:illegal-future-imports
+plugins/modules/server_info.py validate-modules:import-before-documentation
+plugins/modules/server_network.py validate-modules:illegal-future-imports
+plugins/modules/server_network.py validate-modules:import-before-documentation
+plugins/modules/server_type_info.py validate-modules:illegal-future-imports
+plugins/modules/server_type_info.py validate-modules:import-before-documentation
+plugins/modules/server.py validate-modules:illegal-future-imports
+plugins/modules/server.py validate-modules:import-before-documentation
+plugins/modules/ssh_key_info.py validate-modules:illegal-future-imports
+plugins/modules/ssh_key_info.py validate-modules:import-before-documentation
+plugins/modules/ssh_key.py validate-modules:illegal-future-imports
+plugins/modules/ssh_key.py validate-modules:import-before-documentation
+plugins/modules/subnetwork.py validate-modules:illegal-future-imports
+plugins/modules/subnetwork.py validate-modules:import-before-documentation
+plugins/modules/volume_info.py validate-modules:illegal-future-imports
+plugins/modules/volume_info.py validate-modules:import-before-documentation
+plugins/modules/volume.py validate-modules:illegal-future-imports
+plugins/modules/volume.py validate-modules:import-before-documentation
diff --git a/ansible_collections/hetzner/hcloud/tests/sanity/ignore-2.14.txt b/ansible_collections/hetzner/hcloud/tests/sanity/ignore-2.14.txt
index caf221794..e0d8362f4 100644
--- a/ansible_collections/hetzner/hcloud/tests/sanity/ignore-2.14.txt
+++ b/ansible_collections/hetzner/hcloud/tests/sanity/ignore-2.14.txt
@@ -1,2 +1,68 @@
-tests/utils/shippable/check_matrix.py replace-urlopen
-tests/utils/shippable/timing.py shebang
+plugins/inventory/hcloud.py validate-modules:illegal-future-imports
+plugins/inventory/hcloud.py yamllint:unparsable-with-libyaml # bug in ansible-test - https://github.com/ansible/ansible/issues/82353
+plugins/modules/certificate_info.py validate-modules:illegal-future-imports
+plugins/modules/certificate_info.py validate-modules:import-before-documentation
+plugins/modules/certificate.py validate-modules:illegal-future-imports
+plugins/modules/certificate.py validate-modules:import-before-documentation
+plugins/modules/datacenter_info.py validate-modules:illegal-future-imports
+plugins/modules/datacenter_info.py validate-modules:import-before-documentation
+plugins/modules/firewall_info.py validate-modules:illegal-future-imports
+plugins/modules/firewall_info.py validate-modules:import-before-documentation
+plugins/modules/firewall_resource.py validate-modules:illegal-future-imports
+plugins/modules/firewall_resource.py validate-modules:import-before-documentation
+plugins/modules/firewall.py validate-modules:illegal-future-imports
+plugins/modules/firewall.py validate-modules:import-before-documentation
+plugins/modules/floating_ip_info.py validate-modules:illegal-future-imports
+plugins/modules/floating_ip_info.py validate-modules:import-before-documentation
+plugins/modules/floating_ip.py validate-modules:illegal-future-imports
+plugins/modules/floating_ip.py validate-modules:import-before-documentation
+plugins/modules/image_info.py validate-modules:illegal-future-imports
+plugins/modules/image_info.py validate-modules:import-before-documentation
+plugins/modules/iso_info.py validate-modules:illegal-future-imports
+plugins/modules/iso_info.py validate-modules:import-before-documentation
+plugins/modules/load_balancer_info.py validate-modules:illegal-future-imports
+plugins/modules/load_balancer_info.py validate-modules:import-before-documentation
+plugins/modules/load_balancer_network.py validate-modules:illegal-future-imports
+plugins/modules/load_balancer_network.py validate-modules:import-before-documentation
+plugins/modules/load_balancer_service.py validate-modules:illegal-future-imports
+plugins/modules/load_balancer_service.py validate-modules:import-before-documentation
+plugins/modules/load_balancer_target.py validate-modules:illegal-future-imports
+plugins/modules/load_balancer_target.py validate-modules:import-before-documentation
+plugins/modules/load_balancer_type_info.py validate-modules:illegal-future-imports
+plugins/modules/load_balancer_type_info.py validate-modules:import-before-documentation
+plugins/modules/load_balancer.py validate-modules:illegal-future-imports
+plugins/modules/load_balancer.py validate-modules:import-before-documentation
+plugins/modules/location_info.py validate-modules:illegal-future-imports
+plugins/modules/location_info.py validate-modules:import-before-documentation
+plugins/modules/network_info.py validate-modules:illegal-future-imports
+plugins/modules/network_info.py validate-modules:import-before-documentation
+plugins/modules/network.py validate-modules:illegal-future-imports
+plugins/modules/network.py validate-modules:import-before-documentation
+plugins/modules/placement_group.py validate-modules:illegal-future-imports
+plugins/modules/placement_group.py validate-modules:import-before-documentation
+plugins/modules/primary_ip_info.py validate-modules:illegal-future-imports
+plugins/modules/primary_ip_info.py validate-modules:import-before-documentation
+plugins/modules/primary_ip.py validate-modules:illegal-future-imports
+plugins/modules/primary_ip.py validate-modules:import-before-documentation
+plugins/modules/rdns.py validate-modules:illegal-future-imports
+plugins/modules/rdns.py validate-modules:import-before-documentation
+plugins/modules/route.py validate-modules:illegal-future-imports
+plugins/modules/route.py validate-modules:import-before-documentation
+plugins/modules/server_info.py validate-modules:illegal-future-imports
+plugins/modules/server_info.py validate-modules:import-before-documentation
+plugins/modules/server_network.py validate-modules:illegal-future-imports
+plugins/modules/server_network.py validate-modules:import-before-documentation
+plugins/modules/server_type_info.py validate-modules:illegal-future-imports
+plugins/modules/server_type_info.py validate-modules:import-before-documentation
+plugins/modules/server.py validate-modules:illegal-future-imports
+plugins/modules/server.py validate-modules:import-before-documentation
+plugins/modules/ssh_key_info.py validate-modules:illegal-future-imports
+plugins/modules/ssh_key_info.py validate-modules:import-before-documentation
+plugins/modules/ssh_key.py validate-modules:illegal-future-imports
+plugins/modules/ssh_key.py validate-modules:import-before-documentation
+plugins/modules/subnetwork.py validate-modules:illegal-future-imports
+plugins/modules/subnetwork.py validate-modules:import-before-documentation
+plugins/modules/volume_info.py validate-modules:illegal-future-imports
+plugins/modules/volume_info.py validate-modules:import-before-documentation
+plugins/modules/volume.py validate-modules:illegal-future-imports
+plugins/modules/volume.py validate-modules:import-before-documentation
diff --git a/ansible_collections/hetzner/hcloud/tests/sanity/ignore-2.15.txt b/ansible_collections/hetzner/hcloud/tests/sanity/ignore-2.15.txt
index caf221794..d6cabf4c0 100644
--- a/ansible_collections/hetzner/hcloud/tests/sanity/ignore-2.15.txt
+++ b/ansible_collections/hetzner/hcloud/tests/sanity/ignore-2.15.txt
@@ -1,2 +1 @@
-tests/utils/shippable/check_matrix.py replace-urlopen
-tests/utils/shippable/timing.py shebang
+plugins/inventory/hcloud.py yamllint:unparsable-with-libyaml # bug in ansible-test - https://github.com/ansible/ansible/issues/82353
diff --git a/ansible_collections/hetzner/hcloud/tests/sanity/ignore-2.16.txt b/ansible_collections/hetzner/hcloud/tests/sanity/ignore-2.16.txt
new file mode 100644
index 000000000..d6cabf4c0
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/sanity/ignore-2.16.txt
@@ -0,0 +1 @@
+plugins/inventory/hcloud.py yamllint:unparsable-with-libyaml # bug in ansible-test - https://github.com/ansible/ansible/issues/82353
diff --git a/ansible_collections/hetzner/hcloud/tests/unit/module_utils/test_hcloud.py b/ansible_collections/hetzner/hcloud/tests/unit/module_utils/test_hcloud.py
new file mode 100644
index 000000000..c1a9ffb77
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/unit/module_utils/test_hcloud.py
@@ -0,0 +1,125 @@
+from __future__ import annotations
+
+import traceback
+from datetime import datetime, timezone
+from unittest.mock import MagicMock
+
+from ansible_collections.hetzner.hcloud.plugins.module_utils.hcloud import AnsibleHCloud
+from ansible_collections.hetzner.hcloud.plugins.module_utils.vendor.hcloud import (
+ APIException,
+)
+from ansible_collections.hetzner.hcloud.plugins.module_utils.vendor.hcloud.actions import (
+ Action,
+ ActionException,
+ ActionFailedException,
+ ActionTimeoutException,
+)
+
+
+def test_hcloud_fail_json_hcloud():
+ module = MagicMock()
+ module.params = {
+ "api_token": "fake_token",
+ "api_endpoint": "https://api.hetzner.cloud/v1",
+ }
+ AnsibleHCloud.represent = "hcloud_test"
+ hcloud = AnsibleHCloud(module)
+
+ try:
+ raise APIException(
+ code="invalid_input",
+ message="invalid input in fields 'server', 'home_location'",
+ details={
+ "fields": [
+ {"messages": ["either server or home_location must be provided"], "name": "server"},
+ {"messages": ["either server or home_location must be provided"], "name": "home_location"},
+ ]
+ },
+ )
+ except APIException as exception:
+ hcloud.fail_json_hcloud(exception)
+
+ module.fail_json.assert_called_with(
+ msg="invalid input in fields 'server', 'home_location'",
+ exception=traceback.format_exc(),
+ failure={
+ "message": "invalid input in fields 'server', 'home_location'",
+ "code": "invalid_input",
+ "details": {
+ "fields": [
+ {"messages": ["either server or home_location must be provided"], "name": "server"},
+ {"messages": ["either server or home_location must be provided"], "name": "home_location"},
+ ]
+ },
+ },
+ )
+
+ try:
+ raise ActionFailedException(
+ action=Action(
+ **{
+ "id": 1084730887,
+ "command": "change_server_type",
+ "status": "error",
+ "progress": 100,
+ "resources": [{"id": 34574042, "type": "server"}],
+ "error": {"code": "server_does_not_exist_anymore", "message": "Server does not exist anymore"},
+ "started": "2023-07-06T14:52:42+00:00",
+ "finished": "2023-07-06T14:53:08+00:00",
+ }
+ )
+ )
+ except ActionException as exception:
+ hcloud.fail_json_hcloud(exception)
+
+ module.fail_json.assert_called_with(
+ msg="The pending action failed: Server does not exist anymore",
+ exception=traceback.format_exc(),
+ failure={
+ "action": {
+ "id": 1084730887,
+ "command": "change_server_type",
+ "status": "error",
+ "progress": 100,
+ "resources": [{"id": 34574042, "type": "server"}],
+ "error": {"code": "server_does_not_exist_anymore", "message": "Server does not exist anymore"},
+ "started": datetime(2023, 7, 6, 14, 52, 42, tzinfo=timezone.utc),
+ "finished": datetime(2023, 7, 6, 14, 53, 8, tzinfo=timezone.utc),
+ }
+ },
+ )
+
+ try:
+ raise ActionTimeoutException(
+ action=Action(
+ **{
+ "id": 1084659545,
+ "command": "create_server",
+ "status": "running",
+ "progress": 50,
+ "started": "2023-07-06T13:58:38+00:00",
+ "finished": None,
+ "resources": [{"id": 34572291, "type": "server"}],
+ "error": None,
+ }
+ )
+ )
+ except ActionException as exception:
+ hcloud.fail_json_hcloud(exception)
+
+ module.fail_json.assert_called_with(
+ msg="The pending action timed out",
+ exception=traceback.format_exc(),
+ failure={
+ "action": {
+ "id": 1084659545,
+ "command": "create_server",
+ "status": "running",
+ "progress": 50,
+ "resources": [{"id": 34572291, "type": "server"}],
+ "error": None,
+ "started": datetime(2023, 7, 6, 13, 58, 38, tzinfo=timezone.utc),
+ "finished": None,
+ }
+ },
+ )
diff --git a/ansible_collections/hetzner/hcloud/tests/unit/requirements.txt b/ansible_collections/hetzner/hcloud/tests/unit/requirements.txt
new file mode 100644
index 000000000..bc314c3c2
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/unit/requirements.txt
@@ -0,0 +1,2 @@
+python-dateutil
+requests
diff --git a/ansible_collections/hetzner/hcloud/tests/utils/ci.sh b/ansible_collections/hetzner/hcloud/tests/utils/ci.sh
new file mode 100755
index 000000000..e5d73912a
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/utils/ci.sh
@@ -0,0 +1,141 @@
+#!/usr/bin/env bash
+
+set -o pipefail -eux
+
+error() {
+ echo >&2 "error: $*"
+ exit 1
+}
+
+retry() {
+ local exit_code=1
+
+ for _ in 1 2 3; do
+ set +e
+ "$@"
+ exit_code=$?
+ set -e
+ if [ $exit_code == 0 ]; then
+ return $exit_code
+ fi
+ done
+
+ echo "Command '$*' failed 3 times!"
+ exit $exit_code
+}
+
+declare -a entry_point_args
+IFS='/:' read -ra entry_point_args <<< "$1"
+
+# Explode entry point args, for example '2.16/integration/3.10/2' or '2.16/sanity'
+ansible_version="${entry_point_args[0]}"
+test_name="${entry_point_args[1]}"
+python_version="${entry_point_args[2]:-}"
+test_group="${entry_point_args[3]:-}"
+
+export PYTHONIOENCODING="utf-8"
+export PIP_DISABLE_PIP_VERSION_CHECK=true
+export PIP_NO_WARN_SCRIPT_LOCATION=false # Negative options are a bit weird: https://pip.pypa.io/en/stable/topics/configuration/#boolean-options
+export ANSIBLE_COLLECTIONS_PATH="$PWD/../.."
+
+command -v python
+python -V
+
+command -v pip
+pip --version
+pip list
+
+if [ "$ansible_version" == "devel" ]; then
+ pip install "https://github.com/ansible/ansible/archive/devel.tar.gz"
+else
+ pip install "https://github.com/ansible/ansible/archive/stable-$ansible_version.tar.gz"
+fi
+command -v ansible
+ansible --version
+
+# Prepare coverage args
+if $COVERAGE; then
+ coverage_args="--coverage"
+elif [[ "$COMMIT_MESSAGE" =~ ci_coverage ]]; then
+ coverage_args="--coverage"
+else
+ coverage_args="--coverage-check"
+fi
+
+# Prepare changed args
+if $COMPLETE; then
+ changed_args=""
+elif [[ "$COMMIT_MESSAGE" =~ ci_complete ]]; then
+ changed_args=""
+else
+ changed_args="--changed"
+fi
+
+# Prepare unstable args
+if $IS_PULL_REQUEST; then
+ unstable_args="--allow-unstable-changed"
+else
+ unstable_args=""
+fi
+
+# Install dependencies
+pip install rstcheck
+
+# Ensure we can write other collections to this dir
+sudo chown "$(whoami)" "$ANSIBLE_COLLECTIONS_PATH"
+
+pip install -r tests/integration/requirements.txt -c tests/constraints.txt
+ansible-galaxy -vvv collection install -r tests/requirements.yml
+
+# Dump env and set timeout
+timeout=45
+if $COVERAGE; then
+ timeout=60
+fi
+
+ansible-test env --color -v --dump --show --timeout "$timeout"
+
+# Run tests
+case "$test_name" in
+ sanity)
+ # shellcheck disable=SC2086
+ ansible-test sanity --color -v \
+ --exclude plugins/module_utils/vendor/ \
+ --exclude scripts/ \
+ --exclude tests/utils/ \
+ --docker default \
+ --junit \
+ $coverage_args \
+ $changed_args \
+ --allow-disabled
+ ;;
+
+ units)
+ # shellcheck disable=SC2086
+ ansible-test units --color -v \
+ --docker default \
+ --python "$python_version" \
+ $coverage_args \
+ $changed_args
+ ;;
+
+ integration)
+ # shellcheck disable=SC2086
+ ansible-test integration --color -v \
+ --remote-terminate always \
+ --remote-stage prod \
+ --docker default \
+ --python "$python_version" \
+ --retry-on-error \
+ $coverage_args \
+ $changed_args \
+ --changed-all-target none \
+ --changed-all-mode include \
+ $unstable_args \
+ "azp/group$test_group/"
+ ;;
+
+ *)
+ error "found invalid test_name: $test_name"
+ ;;
+esac
diff --git a/ansible_collections/hetzner/hcloud/tests/utils/gitlab/gitlab.sh b/ansible_collections/hetzner/hcloud/tests/utils/gitlab/gitlab.sh
index b09bd2f3a..a96ad2f4c 100755
--- a/ansible_collections/hetzner/hcloud/tests/utils/gitlab/gitlab.sh
+++ b/ansible_collections/hetzner/hcloud/tests/utils/gitlab/gitlab.sh
@@ -11,77 +11,73 @@ ansible_version="${args[0]}"
script="${args[1]}"
function join {
- local IFS="$1";
- shift;
- echo "$*";
+ local IFS="$1"
+ shift
+ echo "$*"
}
test="$(join / "${args[@]:1}")"
command -v python
python -V
-function retry
-{
- # shellcheck disable=SC2034
- for repetition in 1 2 3; do
- set +e
- "$@"
- result=$?
- set -e
- if [ ${result} == 0 ]; then
- return ${result}
- fi
- echo "@* -> ${result}"
- done
- echo "Command '@*' failed 3 times!"
- exit 1
+function retry {
+ # shellcheck disable=SC2034
+ for repetition in 1 2 3; do
+ set +e
+ "$@"
+ result=$?
+ set -e
+ if [ ${result} == 0 ]; then
+ return ${result}
+ fi
+ echo "@* -> ${result}"
+ done
+ echo "Command '@*' failed 3 times!"
+ exit 1
}
command -v pip
pip --version
pip list --disable-pip-version-check
if [ "${ansible_version}" == "devel" ]; then
- retry pip install https://github.com/ansible/ansible/archive/devel.tar.gz --disable-pip-version-check
+ retry pip install https://github.com/ansible/ansible/archive/devel.tar.gz --disable-pip-version-check
else
- retry pip install "https://github.com/ansible/ansible/archive/stable-${ansible_version}.tar.gz" --disable-pip-version-check
+ retry pip install "https://github.com/ansible/ansible/archive/stable-${ansible_version}.tar.gz" --disable-pip-version-check
fi
-export ANSIBLE_COLLECTIONS_PATHS="${HOME}/.ansible"
+export ANSIBLE_COLLECTIONS_PATH="${HOME}/.ansible"
# shellcheck disable=SC2034
SHIPPABLE_RESULT_DIR="$(pwd)/shippable"
-TEST_DIR="${ANSIBLE_COLLECTIONS_PATHS}/ansible_collections/hetzner/hcloud"
+TEST_DIR="${ANSIBLE_COLLECTIONS_PATH}/ansible_collections/hetzner/hcloud"
rm -rf "${TEST_DIR}"
mkdir -p "${TEST_DIR}"
cp -r "." "${TEST_DIR}"
cd "${TEST_DIR}"
# STAR: HACK install dependencies
-retry ansible-galaxy -vvv collection install community.general
-retry ansible-galaxy -vvv collection install ansible.netcommon
-retry ansible-galaxy -vvv collection install community.internal_test_tools
-retry pip install netaddr --disable-pip-version-check
-retry pip install hcloud
+retry pip install -r tests/integration/requirements.txt -c tests/integration/constraints.txt
+retry ansible-galaxy -vvv collection install -r tests/requirements.yml
+
retry pip install rstcheck
+retry ansible-galaxy -vvv collection install community.internal_test_tools
# END: HACK
export PYTHONIOENCODING='utf-8'
if [ "${JOB_TRIGGERED_BY_NAME:-}" == "nightly-trigger" ]; then
- COMPLETE=yes
+ COMPLETE=yes
fi
-
if [ -n "${COMPLETE:-}" ]; then
- # disable change detection triggered by setting the COMPLETE environment variable to a non-empty value
- export CHANGED=""
+ # disable change detection triggered by setting the COMPLETE environment variable to a non-empty value
+ export CHANGED=""
elif [[ "${CI_COMMIT_MESSAGE}" =~ ci_complete ]]; then
- # disable change detection triggered by having 'ci_complete' in the latest commit message
- export CHANGED=""
+ # disable change detection triggered by having 'ci_complete' in the latest commit message
+ export CHANGED=""
else
- # enable change detection (default behavior)
- export CHANGED=""
+ # enable change detection (default behavior)
+ export CHANGED=""
fi
-
export UNSTABLE="--allow-unstable-changed"
# remove empty core/extras module directories from PRs created prior to the repo-merge
diff --git a/ansible_collections/hetzner/hcloud/tests/utils/gitlab/sanity.sh b/ansible_collections/hetzner/hcloud/tests/utils/gitlab/sanity.sh
index 4ee96aefe..9f6711b05 100755
--- a/ansible_collections/hetzner/hcloud/tests/utils/gitlab/sanity.sh
+++ b/ansible_collections/hetzner/hcloud/tests/utils/gitlab/sanity.sh
@@ -8,32 +8,32 @@ IFS='/:' read -ra args <<< "$1"
group="${args[1]}"
if [ "${BASE_BRANCH:-}" ]; then
- base_branch="origin/${BASE_BRANCH}"
+ base_branch="origin/${BASE_BRANCH}"
else
- base_branch=""
+ base_branch=""
fi
if [ "${group}" == "extra" ]; then
- ../internal_test_tools/tools/run.py --color
- exit
+ ../internal_test_tools/tools/run.py --color
+ exit
fi
case "${group}" in
- 1) options=(--skip-test pylint --skip-test ansible-doc --skip-test validate-modules) ;;
- 2) options=( --test ansible-doc --test validate-modules) ;;
- 3) options=(--test pylint plugins/modules/) ;;
- 4) options=(--test pylint --exclude plugins/modules/) ;;
+ 1) options=(--skip-test pylint --skip-test ansible-doc --skip-test validate-modules) ;;
+ 2) options=(--test ansible-doc --test validate-modules) ;;
+ 3) options=(--test pylint plugins/modules/) ;;
+ 4) options=(--test pylint --exclude plugins/modules/) ;;
esac
# allow collection migration sanity tests for groups 3 and 4 to pass without updating this script during migration
network_path="lib/ansible/modules/network/"
if [ -d "${network_path}" ]; then
- if [ "${group}" -eq 3 ]; then
- options+=(--exclude "${network_path}")
- elif [ "${group}" -eq 4 ]; then
- options+=("${network_path}")
- fi
+ if [ "${group}" -eq 3 ]; then
+ options+=(--exclude "${network_path}")
+ elif [ "${group}" -eq 4 ]; then
+ options+=("${network_path}")
+ fi
fi
pip install pycodestyle
@@ -42,6 +42,8 @@ pip install voluptuous
pip install pylint==2.5.3
# shellcheck disable=SC2086
ansible-test sanity --color -v --junit ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} \
- --base-branch "${base_branch}" \
- --exclude tests/utils/ \
- "${options[@]}" --allow-disabled
+ --base-branch "${base_branch}" \
+ --exclude plugins/module_utils/vendor/ \
+ --exclude scripts/ \
+ --exclude tests/utils/ \
+ "${options[@]}" --allow-disabled
diff --git a/ansible_collections/hetzner/hcloud/tests/utils/shippable/check_matrix.py b/ansible_collections/hetzner/hcloud/tests/utils/shippable/check_matrix.py
deleted file mode 100755
index dfcca3e6d..000000000
--- a/ansible_collections/hetzner/hcloud/tests/utils/shippable/check_matrix.py
+++ /dev/null
@@ -1,120 +0,0 @@
-#!/usr/bin/env python
-"""Verify the currently executing Shippable test matrix matches the one defined in the "shippable.yml" file."""
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import datetime
-import json
-import os
-import re
-import sys
-import time
-
-try:
- from typing import NoReturn
-except ImportError:
- NoReturn = None
-
-try:
- # noinspection PyCompatibility
- from urllib2 import urlopen # pylint: disable=ansible-bad-import-from
-except ImportError:
- # noinspection PyCompatibility
- from urllib.request import urlopen
-
-
-def main(): # type: () -> None
- """Main entry point."""
- repo_full_name = os.environ['REPO_FULL_NAME']
- required_repo_full_name = 'ansible-collections/hetzner.hcloud'
-
- if repo_full_name != required_repo_full_name:
- sys.stderr.write('Skipping matrix check on repo "%s" which is not "%s".\n' % (repo_full_name, required_repo_full_name))
- return
-
- with open('shippable.yml', 'rb') as yaml_file:
- yaml = yaml_file.read().decode('utf-8').splitlines()
-
- defined_matrix = [match.group(1) for match in [re.search(r'^ *- env: T=(.*)$', line) for line in yaml] if match and match.group(1) != 'none']
-
- if not defined_matrix:
- fail('No matrix entries found in the "shippable.yml" file.',
- 'Did you modify the "shippable.yml" file?')
-
- run_id = os.environ['SHIPPABLE_BUILD_ID']
- sleep = 1
- jobs = []
-
- for attempts_remaining in range(4, -1, -1):
- try:
- jobs = json.loads(urlopen('https://api.shippable.com/jobs?runIds=%s' % run_id).read())
-
- if not isinstance(jobs, list):
- raise Exception('Shippable run %s data is not a list.' % run_id)
-
- break
- except Exception as ex:
- if not attempts_remaining:
- fail('Unable to retrieve Shippable run %s matrix.' % run_id,
- str(ex))
-
- sys.stderr.write('Unable to retrieve Shippable run %s matrix: %s\n' % (run_id, ex))
- sys.stderr.write('Trying again in %d seconds...\n' % sleep)
- time.sleep(sleep)
- sleep *= 2
-
- if len(jobs) != len(defined_matrix):
- if len(jobs) == 1:
- hint = '\n\nMake sure you do not use the "Rebuild with SSH" option.'
- else:
- hint = ''
-
- fail('Shippable run %s has %d jobs instead of the expected %d jobs.' % (run_id, len(jobs), len(defined_matrix)),
- 'Try re-running the entire matrix.%s' % hint)
-
- actual_matrix = dict((job.get('jobNumber'), dict(tuple(line.split('=', 1)) for line in job.get('env', [])).get('T', '')) for job in jobs)
- errors = [(job_number, test, actual_matrix.get(job_number)) for job_number, test in enumerate(defined_matrix, 1) if actual_matrix.get(job_number) != test]
-
- if len(errors):
- error_summary = '\n'.join('Job %s expected "%s" but found "%s" instead.' % (job_number, expected, actual) for job_number, expected, actual in errors)
-
- fail('Shippable run %s has a job matrix mismatch.' % run_id,
- 'Try re-running the entire matrix.\n\n%s' % error_summary)
-
-
-def fail(message, output): # type: (str, str) -> NoReturn
- # Include a leading newline to improve readability on Shippable "Tests" tab.
- # Without this, the first line becomes indented.
- output = '\n' + output.strip()
-
- timestamp = datetime.datetime.utcnow().replace(microsecond=0).isoformat()
-
- # hack to avoid requiring junit-xml, which isn't pre-installed on Shippable outside our test containers
- xml = '''
-<?xml version="1.0" encoding="utf-8"?>
-<testsuites disabled="0" errors="1" failures="0" tests="1" time="0.0">
-\t<testsuite disabled="0" errors="1" failures="0" file="None" log="None" name="ansible-test" skipped="0" tests="1" time="0" timestamp="%s" url="None">
-\t\t<testcase classname="timeout" name="timeout">
-\t\t\t<error message="%s" type="error">%s</error>
-\t\t</testcase>
-\t</testsuite>
-</testsuites>
-''' % (timestamp, message, output)
-
- path = 'shippable/testresults/check-matrix.xml'
- dir_path = os.path.dirname(path)
-
- if not os.path.exists(dir_path):
- os.makedirs(dir_path)
-
- with open(path, 'w') as junit_fd:
- junit_fd.write(xml.lstrip())
-
- sys.stderr.write(message + '\n')
- sys.stderr.write(output + '\n')
-
- sys.exit(1)
-
-
-if __name__ == '__main__':
- main()
diff --git a/ansible_collections/hetzner/hcloud/tests/utils/shippable/hcloud.sh b/ansible_collections/hetzner/hcloud/tests/utils/shippable/hcloud.sh
deleted file mode 100755
index da037e09e..000000000
--- a/ansible_collections/hetzner/hcloud/tests/utils/shippable/hcloud.sh
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/usr/bin/env bash
-
-set -o pipefail -eux
-
-declare -a args
-IFS='/:' read -ra args <<< "$1"
-
-cloud="${args[0]}"
-python="${args[1]}"
-group="${args[2]}"
-
-target="shippable/${cloud}/group${group}/"
-
-stage="${S:-prod}"
-
-changed_all_target="shippable/${cloud}/smoketest/"
-
-if ! ansible-test integration "${changed_all_target}" --list-targets > /dev/null 2>&1; then
- # no smoketest tests are available for this cloud
- changed_all_target="none"
-fi
-
-if [ "${group}" == "1" ]; then
- # only run smoketest tests for group1
- changed_all_mode="include"
-else
- # smoketest tests already covered by group1
- changed_all_mode="exclude"
-fi
-
-# shellcheck disable=SC2086
-ansible-test integration --color -v --retry-on-error "${target}" ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} ${UNSTABLE:+"$UNSTABLE"} \
- --remote-terminate always --remote-stage "${stage}" \
- --docker --python "${python}" --changed-all-target "${changed_all_target}" --changed-all-mode "${changed_all_mode}"
diff --git a/ansible_collections/hetzner/hcloud/tests/utils/shippable/sanity.sh b/ansible_collections/hetzner/hcloud/tests/utils/shippable/sanity.sh
deleted file mode 100755
index 9339aeda4..000000000
--- a/ansible_collections/hetzner/hcloud/tests/utils/shippable/sanity.sh
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/usr/bin/env bash
-
-set -o pipefail -eux
-
-declare -a args
-IFS='/:' read -ra args <<< "$1"
-
-group="${args[1]}"
-
-if [ "${BASE_BRANCH:-}" ]; then
- base_branch="origin/${BASE_BRANCH}"
-else
- base_branch=""
-fi
-
-if [ "${group}" == "extra" ]; then
- # ansible-galaxy -vvv collection install community.internal_test_tools
- git clone --single-branch --depth 1 https://github.com/ansible-collections/community.internal_test_tools.git ../../community/internal_test_tools
-
- ../internal_test_tools/tools/run.py --color
- exit
-fi
-
-# shellcheck disable=SC2086
-ansible-test sanity --color -v --junit ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} \
- --docker --base-branch "${base_branch}" \
- --allow-disabled
diff --git a/ansible_collections/hetzner/hcloud/tests/utils/shippable/shippable.sh b/ansible_collections/hetzner/hcloud/tests/utils/shippable/shippable.sh
deleted file mode 100755
index 8c0bd6deb..000000000
--- a/ansible_collections/hetzner/hcloud/tests/utils/shippable/shippable.sh
+++ /dev/null
@@ -1,213 +0,0 @@
-#!/usr/bin/env bash
-
-set -o pipefail -eux
-
-declare -a args
-IFS='/:' read -ra args <<< "$1"
-
-ansible_version="${args[0]}"
-script="${args[1]}"
-
-function join {
- local IFS="$1";
- shift;
- echo "$*";
-}
-
-# Ensure we can write other collections to this dir
-sudo chown "$(whoami)" "${PWD}/../../"
-
-test="$(join / "${args[@]:1}")"
-
-docker images ansible/ansible
-docker images quay.io/ansible/*
-docker ps
-
-for container in $(docker ps --format '{{.Image}} {{.ID}}' | grep -v -e '^drydock/' -e '^quay.io/ansible/azure-pipelines-test-container:' | sed 's/^.* //'); do
- docker rm -f "${container}" || true # ignore errors
-done
-
-docker ps
-
-if [ -d /home/shippable/cache/ ]; then
- ls -la /home/shippable/cache/
-fi
-
-command -v python
-python -V
-
-function retry
-{
- # shellcheck disable=SC2034
- for repetition in 1 2 3; do
- set +e
- "$@"
- result=$?
- set -e
- if [ ${result} == 0 ]; then
- return ${result}
- fi
- echo "@* -> ${result}"
- done
- echo "Command '@*' failed 3 times!"
- exit 1
-}
-
-command -v pip
-pip --version
-pip list --disable-pip-version-check
-if [ "${ansible_version}" == "devel" ]; then
- retry pip install https://github.com/ansible/ansible/archive/devel.tar.gz --disable-pip-version-check
-else
- retry pip install "https://github.com/ansible/ansible/archive/stable-${ansible_version}.tar.gz" --disable-pip-version-check
-fi
-
-if [ "${SHIPPABLE_BUILD_ID:-}" ]; then
- export ANSIBLE_COLLECTIONS_PATHS="${HOME}/.ansible"
- SHIPPABLE_RESULT_DIR="$(pwd)/shippable"
- TEST_DIR="${ANSIBLE_COLLECTIONS_PATHS}/ansible_collections/hetzner/hcloud"
- mkdir -p "${TEST_DIR}"
- cp -aT "${SHIPPABLE_BUILD_DIR}" "${TEST_DIR}"
- cd "${TEST_DIR}"
-else
- export ANSIBLE_COLLECTIONS_PATHS="${PWD}/../../../"
-fi
-
-# STAR: HACK install dependencies
-retry ansible-galaxy -vvv collection install community.general
-retry ansible-galaxy -vvv collection install ansible.netcommon
-
-retry pip install hcloud
-retry pip install netaddr --disable-pip-version-check
-retry ansible-galaxy -vvv collection install community.internal_test_tools
-# END: HACK
-
-export PYTHONIOENCODING='utf-8'
-
-if [ "${JOB_TRIGGERED_BY_NAME:-}" == "nightly-trigger" ]; then
- COVERAGE=yes
- COMPLETE=yes
-fi
-
-if [ -n "${COVERAGE:-}" ]; then
- # on-demand coverage reporting triggered by setting the COVERAGE environment variable to a non-empty value
- export COVERAGE="--coverage"
-elif [[ "${COMMIT_MESSAGE}" =~ ci_coverage ]]; then
- # on-demand coverage reporting triggered by having 'ci_coverage' in the latest commit message
- export COVERAGE="--coverage"
-else
- # on-demand coverage reporting disabled (default behavior, always-on coverage reporting remains enabled)
- export COVERAGE="--coverage-check"
-fi
-
-if [ -n "${COMPLETE:-}" ]; then
- # disable change detection triggered by setting the COMPLETE environment variable to a non-empty value
- export CHANGED=""
-elif [[ "${COMMIT_MESSAGE}" =~ ci_complete ]]; then
- # disable change detection triggered by having 'ci_complete' in the latest commit message
- export CHANGED=""
-else
- # enable change detection (default behavior)
- export CHANGED="--changed"
-fi
-
-if [ "${IS_PULL_REQUEST:-}" == "true" ]; then
- # run unstable tests which are targeted by focused changes on PRs
- export UNSTABLE="--allow-unstable-changed"
-else
- # do not run unstable tests outside PRs
- export UNSTABLE=""
-fi
-
-# remove empty core/extras module directories from PRs created prior to the repo-merge
-find plugins -type d -empty -print -delete
-
-function cleanup
-{
- # for complete on-demand coverage generate a report for all files with no coverage on the "sanity/5" job so we only have one copy
- if [ "${COVERAGE}" == "--coverage" ] && [ "${CHANGED}" == "" ] && [ "${test}" == "sanity/5" ]; then
- stub="--stub"
- # trigger coverage reporting for stubs even if no other coverage data exists
- mkdir -p tests/output/coverage/
- else
- stub=""
- fi
-
- if [ -d tests/output/coverage/ ]; then
- if find tests/output/coverage/ -mindepth 1 -name '.*' -prune -o -print -quit | grep -q .; then
- process_coverage='yes' # process existing coverage files
- elif [ "${stub}" ]; then
- process_coverage='yes' # process coverage when stubs are enabled
- else
- process_coverage=''
- fi
-
- if [ "${process_coverage}" ]; then
- # use python 3.7 for coverage to avoid running out of memory during coverage xml processing
- # only use it for coverage to avoid the additional overhead of setting up a virtual environment for a potential no-op job
- virtualenv --python /usr/bin/python3.7 ~/ansible-venv
- set +ux
- . ~/ansible-venv/bin/activate
- set -ux
-
- # shellcheck disable=SC2086
- ansible-test coverage xml --color -v --requirements --group-by command --group-by version ${stub:+"$stub"}
- cp -a tests/output/reports/coverage=*.xml "$SHIPPABLE_RESULT_DIR/codecoverage/"
-
- if [ "${ansible_version}" != "2.9" ]; then
- # analyze and capture code coverage aggregated by integration test target
- ansible-test coverage analyze targets generate -v "$SHIPPABLE_RESULT_DIR/testresults/coverage-analyze-targets.json"
- fi
-
- # upload coverage report to codecov.io only when using complete on-demand coverage
- if [ "${COVERAGE}" == "--coverage" ] && [ "${CHANGED}" == "" ]; then
- for file in tests/output/reports/coverage=*.xml; do
- flags="${file##*/coverage=}"
- flags="${flags%-powershell.xml}"
- flags="${flags%.xml}"
- # remove numbered component from stub files when converting to tags
- flags="${flags//stub-[0-9]*/stub}"
- flags="${flags//=/,}"
- flags="${flags//[^a-zA-Z0-9_,]/_}"
-
- bash <(curl -s https://ansible-ci-files.s3.us-east-1.amazonaws.com/codecov/codecov.sh) \
- -f "${file}" \
- -F "${flags}" \
- -n "${test}" \
- -t 8a86e979-f37b-4d5d-95a4-960c280d5eaa \
- -X coveragepy \
- -X gcov \
- -X fix \
- -X search \
- -X xcode \
- || echo "Failed to upload code coverage report to codecov.io: ${file}"
- done
- fi
- fi
- fi
-
- if [ -d tests/output/junit/ ]; then
- cp -aT tests/output/junit/ "$SHIPPABLE_RESULT_DIR/testresults/"
- fi
-
- if [ -d tests/output/data/ ]; then
- cp -a tests/output/data/ "$SHIPPABLE_RESULT_DIR/testresults/"
- fi
-
- if [ -d tests/output/bot/ ]; then
- cp -aT tests/output/bot/ "$SHIPPABLE_RESULT_DIR/testresults/"
- fi
-}
-
-if [ "${SHIPPABLE_BUILD_ID:-}" ]; then trap cleanup EXIT; fi
-
-if [[ "${COVERAGE:-}" == "--coverage" ]]; then
- timeout=60
-else
- timeout=45
-fi
-
-ansible-test env --dump --show --timeout "${timeout}" --color -v
-
-if [ "${SHIPPABLE_BUILD_ID:-}" ]; then "tests/utils/shippable/check_matrix.py"; fi
-"tests/utils/shippable/${script}.sh" "${test}"
diff --git a/ansible_collections/hetzner/hcloud/tests/utils/shippable/timing.py b/ansible_collections/hetzner/hcloud/tests/utils/shippable/timing.py
deleted file mode 100755
index fb538271b..000000000
--- a/ansible_collections/hetzner/hcloud/tests/utils/shippable/timing.py
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/usr/bin/env python3.7
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import sys
-import time
-
-start = time.time()
-
-sys.stdin.reconfigure(errors='surrogateescape')
-sys.stdout.reconfigure(errors='surrogateescape')
-
-for line in sys.stdin:
- seconds = time.time() - start
- sys.stdout.write('%02d:%02d %s' % (seconds // 60, seconds % 60, line))
- sys.stdout.flush()
diff --git a/ansible_collections/hetzner/hcloud/tests/utils/shippable/timing.sh b/ansible_collections/hetzner/hcloud/tests/utils/shippable/timing.sh
deleted file mode 100755
index 77e257830..000000000
--- a/ansible_collections/hetzner/hcloud/tests/utils/shippable/timing.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/usr/bin/env bash
-
-set -o pipefail -eu
-
-"$@" 2>&1 | "$(dirname "$0")/timing.py"