From a453ac31f3428614cceb99027f8efbdb9258a40b Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Tue, 14 May 2024 22:03:01 +0200 Subject: Adding upstream version 2.10.7+merged+base+2.10.8+dfsg. Signed-off-by: Daniel Baumann --- .../hetzner/hcloud/tests/.gitignore | 1 + .../hcloud/tests/integration/requirements.txt | 2 + .../integration/targets/hcloud_certificate/aliases | 2 + .../targets/hcloud_certificate/defaults/main.yml | 5 + .../targets/hcloud_certificate/meta/main.yml | 5 + .../targets/hcloud_certificate/tasks/main.yml | 123 ++++ .../targets/hcloud_certificate_info/aliases | 2 + .../hcloud_certificate_info/defaults/main.yml | 5 + .../targets/hcloud_certificate_info/meta/main.yml | 2 + .../targets/hcloud_certificate_info/tasks/main.yml | 39 ++ .../targets/hcloud_datacenter_info/aliases | 2 + .../hcloud_datacenter_info/defaults/main.yml | 6 + .../targets/hcloud_datacenter_info/meta/main.yml | 3 + .../targets/hcloud_datacenter_info/tasks/main.yml | 40 ++ .../integration/targets/hcloud_floating_ip/aliases | 2 + .../targets/hcloud_floating_ip/defaults/main.yml | 6 + .../targets/hcloud_floating_ip/meta/main.yml | 3 + .../targets/hcloud_floating_ip/tasks/main.yml | 443 ++++++++++++++ .../targets/hcloud_floating_ip_info/aliases | 2 + .../hcloud_floating_ip_info/defaults/main.yml | 5 + .../targets/hcloud_floating_ip_info/meta/main.yml | 3 + .../targets/hcloud_floating_ip_info/tasks/main.yml | 87 +++ .../integration/targets/hcloud_image_info/aliases | 2 + .../targets/hcloud_image_info/defaults/main.yml | 6 + .../targets/hcloud_image_info/meta/main.yml | 3 + .../targets/hcloud_image_info/tasks/main.yml | 62 ++ .../targets/hcloud_load_balancer/aliases | 2 + .../targets/hcloud_load_balancer/defaults/main.yml | 5 + .../targets/hcloud_load_balancer/meta/main.yml | 3 + .../targets/hcloud_load_balancer/tasks/main.yml | 247 ++++++++ .../targets/hcloud_load_balancer_info/aliases | 2 + .../hcloud_load_balancer_info/defaults/main.yml | 6 + .../hcloud_load_balancer_info/meta/main.yml | 3 + .../hcloud_load_balancer_info/tasks/main.yml | 128 ++++ .../targets/hcloud_load_balancer_network/aliases | 2 + .../hcloud_load_balancer_network/defaults/main.yml | 6 + .../hcloud_load_balancer_network/meta/main.yml | 3 + .../hcloud_load_balancer_network/tasks/main.yml | 155 +++++ .../targets/hcloud_load_balancer_service/aliases | 2 + .../hcloud_load_balancer_service/defaults/main.yml | 5 + .../hcloud_load_balancer_service/meta/main.yml | 3 + .../hcloud_load_balancer_service/tasks/main.yml | 112 ++++ .../targets/hcloud_load_balancer_target/aliases | 2 + .../hcloud_load_balancer_target/defaults/main.yml | 7 + .../hcloud_load_balancer_target/meta/main.yml | 3 + .../hcloud_load_balancer_target/tasks/main.yml | 129 ++++ .../targets/hcloud_load_balancer_type_info/aliases | 2 + .../defaults/main.yml | 5 + .../hcloud_load_balancer_type_info/meta/main.yml | 3 + .../hcloud_load_balancer_type_info/tasks/main.yml | 38 ++ .../targets/hcloud_location_info/aliases | 2 + .../targets/hcloud_location_info/defaults/main.yml | 5 + .../targets/hcloud_location_info/meta/main.yml | 3 + .../targets/hcloud_location_info/tasks/main.yml | 57 ++ .../integration/targets/hcloud_network/aliases | 3 + .../targets/hcloud_network/defaults/main.yml | 5 + .../targets/hcloud_network/meta/main.yml | 3 + .../targets/hcloud_network/tasks/main.yml | 215 +++++++ .../targets/hcloud_network_info/aliases | 2 + .../targets/hcloud_network_info/defaults/main.yml | 5 + .../targets/hcloud_network_info/meta/main.yml | 3 + .../targets/hcloud_network_info/tasks/main.yml | 117 ++++ .../tests/integration/targets/hcloud_rdns/aliases | 2 + .../targets/hcloud_rdns/defaults/main.yml | 6 + .../integration/targets/hcloud_rdns/meta/main.yml | 3 + .../integration/targets/hcloud_rdns/tasks/main.yml | 140 +++++ .../tests/integration/targets/hcloud_route/aliases | 2 + .../targets/hcloud_route/defaults/main.yml | 5 + .../integration/targets/hcloud_route/meta/main.yml | 3 + .../targets/hcloud_route/tasks/main.yml | 99 ++++ .../integration/targets/hcloud_server/aliases | 2 + .../targets/hcloud_server/defaults/main.yml | 5 + .../targets/hcloud_server/meta/main.yml | 3 + .../targets/hcloud_server/tasks/main.yml | 648 +++++++++++++++++++++ .../integration/targets/hcloud_server_info/aliases | 2 + .../targets/hcloud_server_info/defaults/main.yml | 5 + .../targets/hcloud_server_info/meta/main.yml | 3 + .../targets/hcloud_server_info/tasks/main.yml | 97 +++ .../targets/hcloud_server_network/aliases | 3 + .../hcloud_server_network/defaults/main.yml | 6 + .../targets/hcloud_server_network/meta/main.yml | 3 + .../targets/hcloud_server_network/tasks/main.yml | 222 +++++++ .../targets/hcloud_server_type_info/aliases | 2 + .../hcloud_server_type_info/defaults/main.yml | 5 + .../targets/hcloud_server_type_info/meta/main.yml | 3 + .../targets/hcloud_server_type_info/tasks/main.yml | 38 ++ .../integration/targets/hcloud_ssh_key/aliases | 2 + .../targets/hcloud_ssh_key/defaults/main.yml | 8 + .../targets/hcloud_ssh_key/meta/main.yml | 5 + .../targets/hcloud_ssh_key/tasks/main.yml | 144 +++++ .../targets/hcloud_ssh_key_info/aliases | 2 + .../targets/hcloud_ssh_key_info/defaults/main.yml | 5 + .../targets/hcloud_ssh_key_info/meta/main.yml | 5 + .../targets/hcloud_ssh_key_info/tasks/main.yml | 68 +++ .../integration/targets/hcloud_subnetwork/aliases | 2 + .../targets/hcloud_subnetwork/defaults/main.yml | 6 + .../targets/hcloud_subnetwork/meta/main.yml | 3 + .../targets/hcloud_subnetwork/tasks/main.yml | 125 ++++ .../integration/targets/hcloud_volume/aliases | 2 + .../targets/hcloud_volume/defaults/main.yml | 6 + .../targets/hcloud_volume/meta/main.yml | 3 + .../targets/hcloud_volume/tasks/main.yml | 289 +++++++++ .../integration/targets/hcloud_volume_info/aliases | 2 + .../targets/hcloud_volume_info/defaults/main.yml | 5 + .../targets/hcloud_volume_info/meta/main.yml | 3 + .../targets/hcloud_volume_info/tasks/main.yml | 101 ++++ .../setup_selfsigned_certificate/tasks/main.yml | 27 + .../targets/setup_sshkey/tasks/main.yml | 55 ++ .../hetzner/hcloud/tests/requirements.yml | 3 + .../hetzner/hcloud/tests/sanity/requirements.txt | 4 + .../hetzner/hcloud/tests/utils/gitlab/gitlab.sh | 96 +++ .../hcloud/tests/utils/gitlab/integration.sh | 15 + .../hetzner/hcloud/tests/utils/gitlab/sanity.sh | 47 ++ .../hcloud/tests/utils/shippable/check_matrix.py | 120 ++++ .../hetzner/hcloud/tests/utils/shippable/hcloud.sh | 34 ++ .../hetzner/hcloud/tests/utils/shippable/sanity.sh | 44 ++ .../hcloud/tests/utils/shippable/shippable.sh | 125 ++++ .../hetzner/hcloud/tests/utils/shippable/timing.py | 16 + .../hetzner/hcloud/tests/utils/shippable/timing.sh | 5 + 119 files changed, 4838 insertions(+) create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/.gitignore create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/requirements.txt create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/aliases create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/defaults/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/aliases create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/defaults/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/aliases create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/defaults/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/aliases create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/defaults/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/aliases create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/defaults/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/aliases create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/defaults/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/aliases create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/defaults/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/aliases create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/defaults/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/aliases create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/defaults/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/aliases create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/defaults/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/aliases create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/defaults/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_type_info/aliases create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_type_info/defaults/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_type_info/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_type_info/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/aliases create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/defaults/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/aliases create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/defaults/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/aliases create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/defaults/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/aliases create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/defaults/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/aliases create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/defaults/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/aliases create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/defaults/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/aliases create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/defaults/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/aliases create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/defaults/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/aliases create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/defaults/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/aliases create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/defaults/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/aliases create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/defaults/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/aliases create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/defaults/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/aliases create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/defaults/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/aliases create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/defaults/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/meta/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/setup_selfsigned_certificate/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/setup_sshkey/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/requirements.yml create mode 100644 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/sanity/requirements.txt create mode 100755 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/utils/gitlab/gitlab.sh create mode 100755 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/utils/gitlab/integration.sh create mode 100755 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/utils/gitlab/sanity.sh create mode 100755 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/utils/shippable/check_matrix.py create mode 100755 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/utils/shippable/hcloud.sh create mode 100755 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/utils/shippable/sanity.sh create mode 100755 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/utils/shippable/shippable.sh create mode 100755 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/utils/shippable/timing.py create mode 100755 collections-debian-merged/ansible_collections/hetzner/hcloud/tests/utils/shippable/timing.sh (limited to 'collections-debian-merged/ansible_collections/hetzner/hcloud/tests') diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/.gitignore b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/.gitignore new file mode 100644 index 00000000..ea1472ec --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/.gitignore @@ -0,0 +1 @@ +output/ diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/requirements.txt b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/requirements.txt new file mode 100644 index 00000000..d3249def --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/requirements.txt @@ -0,0 +1,2 @@ +netaddr +hcloud diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/aliases b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/aliases new file mode 100644 index 00000000..55ec821a --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/aliases @@ -0,0 +1,2 @@ +cloud/hcloud +shippable/hcloud/group2 diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/defaults/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/defaults/main.yml new file mode 100644 index 00000000..49b6c6fb --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/defaults/main.yml @@ -0,0 +1,5 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# 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" diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/meta/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/meta/main.yml new file mode 100644 index 00000000..e531064c --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/meta/main.yml @@ -0,0 +1,5 @@ +dependencies: + - setup_selfsigned_certificate +collections: + - community.general.ipfilter + - hetzner.cloud diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/tasks/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/tasks/main.yml new file mode 100644 index 00000000..5f6376e9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/tasks/main.yml @@ -0,0 +1,123 @@ +# Copyright: (c) 2020, Hetzner Cloud GmbH +# 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: + name: "{{ hcloud_certificate_name }}" + register: result + ignore_errors: yes +- name: verify fail test missing required parameters on create certificate + assert: + that: + - result is failed + - 'result.msg == "missing required arguments: certificate, private_key"' + +- name: test create certificate with check mode + hcloud_certificate: + name: "{{ hcloud_certificate_name }}" + certificate: "{{ certificate_example_com }}" + private_key: "{{ certificate_example_com_key }}" + register: result + check_mode: yes +- name: test create certificate with check mode + assert: + that: + - result is changed + +- name: test 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 create certificate idempotence + hcloud_certificate: + name: "{{ hcloud_certificate_name }}" + certificate: "{{ certificate_example_com }}" + private_key: "{{ certificate_example_com_key }}" + register: result +- name: verify create certificate idempotence + assert: + that: + - result is not changed + +- name: test update certificate with check mode + hcloud_certificate: + id: "{{ certificate.hcloud_certificate.id }}" + name: "changed-{{ hcloud_certificate_name }}" + register: result + check_mode: yes +- name: test create certificate with check mode + assert: + that: + - result is changed + +- name: test update certificate + hcloud_certificate: + id: "{{ certificate.hcloud_certificate.id }}" + name: "changed-{{ hcloud_certificate_name }}" + labels: + key: value + register: result +- name: test update certificate + assert: + that: + - result is changed + - result.hcloud_certificate.name == "changed-{{ hcloud_certificate_name }}" + +- name: test update certificate with same labels + hcloud_certificate: + id: "{{ certificate.hcloud_certificate.id }}" + name: "changed-{{ hcloud_certificate_name }}" + labels: + key: value + register: result +- name: test update certificate with same labels + assert: + that: + - result is not changed + +- name: test update certificate with other labels + hcloud_certificate: + id: "{{ certificate.hcloud_certificate.id }}" + name: "changed-{{ hcloud_certificate_name }}" + labels: + key: value + test: "val123" + register: result +- name: test update certificate with other labels + assert: + that: + - result is changed + +- name: test rename certificate + hcloud_certificate: + id: "{{ certificate.hcloud_certificate.id }}" + name: "{{ hcloud_certificate_name }}" + register: result +- name: test rename certificate + assert: + that: + - result is changed + - result.hcloud_certificate.name == "{{ hcloud_certificate_name }}" + +- name: absent certificate + hcloud_certificate: + id: "{{ certificate.hcloud_certificate.id }}" + state: absent + register: result +- name: verify absent server + assert: + that: + - result is success diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/aliases b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/aliases new file mode 100644 index 00000000..55ec821a --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/aliases @@ -0,0 +1,2 @@ +cloud/hcloud +shippable/hcloud/group2 diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/defaults/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/defaults/main.yml new file mode 100644 index 00000000..6205b19b --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/defaults/main.yml @@ -0,0 +1,5 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# 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" diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/meta/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/meta/main.yml new file mode 100644 index 00000000..f830a9da --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/meta/main.yml @@ -0,0 +1,2 @@ +collections: + - hetzner.cloud diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/tasks/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/tasks/main.yml new file mode 100644 index 00000000..7dc4eb72 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/tasks/main.yml @@ -0,0 +1,39 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- + +- 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 diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/aliases b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/aliases new file mode 100644 index 00000000..55ec821a --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/aliases @@ -0,0 +1,2 @@ +cloud/hcloud +shippable/hcloud/group2 diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/defaults/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/defaults/main.yml new file mode 100644 index 00000000..b9e045f4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/defaults/main.yml @@ -0,0 +1,6 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# 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" diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/meta/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/meta/main.yml new file mode 100644 index 00000000..407c9018 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/meta/main.yml @@ -0,0 +1,3 @@ +collections: + - community.general.ipfilter + - hetzner.cloud diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/tasks/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/tasks/main.yml new file mode 100644 index 00000000..7f49b040 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/tasks/main.yml @@ -0,0 +1,40 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# 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 == 3 + +- 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 == 3 + + +- 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/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/aliases b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/aliases new file mode 100644 index 00000000..55ec821a --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/aliases @@ -0,0 +1,2 @@ +cloud/hcloud +shippable/hcloud/group2 diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/defaults/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/defaults/main.yml new file mode 100644 index 00000000..fc60d281 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/defaults/main.yml @@ -0,0 +1,6 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# 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}}-integration" +hcloud_server_name: "{{hcloud_prefix}}-fip-tests" \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/meta/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/meta/main.yml new file mode 100644 index 00000000..407c9018 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/meta/main.yml @@ -0,0 +1,3 @@ +collections: + - community.general.ipfilter + - hetzner.cloud diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/tasks/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/tasks/main.yml new file mode 100644 index 00000000..70f23e33 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/tasks/main.yml @@ -0,0 +1,443 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: setup server + hcloud_server: + name: "{{ hcloud_server_name }}" + server_type: cx11 + image: ubuntu-18.04 + state: started + location: "fsn1" + register: main_server +- name: verify setup server + assert: + that: + - main_server is changed + +- name: setup another server + hcloud_server: + name: "{{ hcloud_server_name }}2" + server_type: cx11 + image: ubuntu-18.04 + state: started + register: main_server2 +- name: verify setup another server + assert: + that: + - main_server2 is changed + +- name: test missing type parameter on create Floating IP + hcloud_floating_ip: + name: "{{ hcloud_floating_ip_name }}" + register: result + ignore_errors: yes +- name: verify fail test missing type parameter on create Floating IP + assert: + that: + - result is failed + - 'result.msg == "missing required arguments: type"' + +- name: test missing required parameters on create Floating IP + hcloud_floating_ip: + name: "{{ hcloud_floating_ip_name }}" + type: ipv4 + register: result + ignore_errors: yes +- name: verify fail test missing required parameters on create Floating IP + assert: + that: + - result is failed + - 'result.msg == "one of the following is required: home_location, server"' + +- name: test missing type parameter on delete Floating IP + hcloud_floating_ip: + type: ipv4 + home_location: "fsn1" + state: "absent" + register: result + ignore_errors: yes +- 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 create Floating IP with check mode + hcloud_floating_ip: + name: "{{ hcloud_floating_ip_name }}" + description: "Web Server" + type: ipv4 + home_location: "fsn1" + register: floatingIP + check_mode: yes +- name: verify test create Floating IP with check mode + assert: + that: + - floatingIP is changed + +- name: test create Floating IP + hcloud_floating_ip: + name: "{{ hcloud_floating_ip_name }}" + description: "Web Server" + type: ipv4 + home_location: "fsn1" + register: floatingIP +- name: verify test create Floating IP + assert: + that: + - floatingIP is changed + - floatingIP.hcloud_floating_ip.name ==hcloud_floating_ip_name + - floatingIP.hcloud_floating_ip.description == "Web Server" + - floatingIP.hcloud_floating_ip.home_location == "fsn1" + +- name: test create Floating IP idempotency + hcloud_floating_ip: + name: "{{ hcloud_floating_ip_name }}" + description: "Web Server" + type: ipv4 + home_location: "fsn1" + register: floatingIP +- name: verify test create Floating IP idempotency + assert: + that: + - floatingIP is not changed + +- name: test update Floating IP with check mode + hcloud_floating_ip: + name: "{{ hcloud_floating_ip_name }}" + description: "changed-description" + type: ipv4 + home_location: "fsn1" + check_mode: yes + register: floatingIP +- name: verify test create Floating IP with check mode + assert: + that: + - floatingIP is changed + - floatingIP.hcloud_floating_ip.description == "Web Server" + +- name: test update Floating IP + hcloud_floating_ip: + name: "{{ hcloud_floating_ip_name }}" + description: "changed-description" + type: ipv4 + home_location: "fsn1" + labels: + key: value + register: floatingIP +- name: verify test update Floating IP + assert: + that: + - floatingIP is changed + - floatingIP.hcloud_floating_ip.description == "changed-description" + +- name: test update Floating IP idempotency + hcloud_floating_ip: + name: "{{ hcloud_floating_ip_name }}" + description: "changed-description" + type: ipv4 + home_location: "fsn1" + labels: + key: value + register: floatingIP +- name: verify test update Floating IP idempotency + assert: + that: + - floatingIP is not changed + +- name: test update Floating IP with same labels + hcloud_floating_ip: + name: "{{ hcloud_floating_ip_name }}" + type: ipv4 + home_location: "fsn1" + labels: + key: value + register: floatingIP +- name: verify test update Floating IP with same labels + assert: + that: + - floatingIP is not changed + +- name: test update Floating IP with other labels + hcloud_floating_ip: + name: "{{ hcloud_floating_ip_name }}" + type: ipv4 + home_location: "fsn1" + labels: + key: value + other: label + register: floatingIP +- name: verify test update Floating IP with other labels + assert: + that: + - floatingIP is changed + +- name: test update Floating IP with other labels in different order + hcloud_floating_ip: + name: "{{ hcloud_floating_ip_name }}" + type: ipv4 + home_location: "fsn1" + labels: + other: label + key: value + register: floatingIP +- name: verify test update Floating IP with other labels in different order + assert: + that: + - floatingIP is not changed + +- name: test assign Floating IP with checkmode + hcloud_floating_ip: + name: "{{ hcloud_floating_ip_name }}" + description: "changed-description" + type: ipv4 + server: "{{ main_server.hcloud_server.name }}" + check_mode: yes + 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 }}" + +- name: test assign Floating IP + hcloud_floating_ip: + name: "{{ hcloud_floating_ip_name }}" + description: "changed-description" + type: ipv4 + server: "{{ main_server.hcloud_server.name }}" + register: floatingIP +- name: verify test assign Floating IP + assert: + that: + - floatingIP is changed + - floatingIP.hcloud_floating_ip.server == "{{ main_server.hcloud_server.name }}" + +- name: test assign Floating IP idempotency + hcloud_floating_ip: + name: "{{ hcloud_floating_ip_name }}" + description: "changed-description" + type: ipv4 + server: "{{ main_server.hcloud_server.name }}" + register: floatingIP +- name: verify test unassign Floating IPidempotency + assert: + that: + - floatingIP is not changed + +- name: test unassign Floating IP + hcloud_floating_ip: + name: "{{ hcloud_floating_ip_name }}" + type: ipv4 + home_location: "fsn1" + register: floatingIP +- name: verify test unassign Floating IP + assert: + that: + - floatingIP is changed + - floatingIP.hcloud_floating_ip.server != "{{ main_server.hcloud_server.name }}" + +- name: test unassign Floating IP idempotency + hcloud_floating_ip: + name: "{{ hcloud_floating_ip_name }}" + type: ipv4 + home_location: "fsn1" + register: floatingIP +- name: verify test unassign Floating IPidempotency + assert: + that: + - floatingIP is not changed + +- name: test assign Floating IP again + hcloud_floating_ip: + name: "{{ hcloud_floating_ip_name }}" + type: ipv4 + server: "{{ main_server.hcloud_server.name }}" + register: floatingIP +- name: verify test assign Floating IP again + assert: + that: + - floatingIP is changed + - floatingIP.hcloud_floating_ip.server == "{{ main_server.hcloud_server.name }}" + +- name: test already assigned Floating IP assign without force + hcloud_floating_ip: + name: "{{ hcloud_floating_ip_name }}" + type: ipv4 + server: "{{ main_server2.hcloud_server.name }}" + register: floatingIP +- name: verify test already assigned Floating IP assign without force + assert: + that: + - floatingIP is changed + - floatingIP.hcloud_floating_ip.server == "{{ main_server.hcloud_server.name }}" + +- name: test already assigned Floating IP assign with force + hcloud_floating_ip: + name: "{{ hcloud_floating_ip_name }}" + type: ipv4 + force: yes + 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 }}" + +- name: test update Floating IP delete protection + hcloud_floating_ip: + name: "{{ hcloud_floating_ip_name }}" + type: ipv4 + delete_protection: true + register: floatingIP +- name: verify update Floating IP delete protection + assert: + that: + - floatingIP is changed + - floatingIP.hcloud_floating_ip.delete_protection is sameas true + +- name: test update Floating IP delete protection idempotency + hcloud_floating_ip: + name: "{{ hcloud_floating_ip_name }}" + type: ipv4 + delete_protection: true + register: floatingIP +- name: verify update Floating IP delete protection idempotency + assert: + that: + - floatingIP is not changed + - floatingIP.hcloud_floating_ip.delete_protection is sameas true + +- name: test Floating IP without delete protection set to be idempotent + hcloud_floating_ip: + name: "{{ hcloud_floating_ip_name }}" + type: ipv4 + register: floatingIP +- name: verify Floating IP without delete protection set to be idempotent + assert: + that: + - floatingIP is not changed + - floatingIP.hcloud_floating_ip.delete_protection is sameas true + +- name: test delete Floating IP fails if it is protected + hcloud_floating_ip: + name: "{{ hcloud_floating_ip_name }}" + state: "absent" + register: result + ignore_errors: yes +- name: verify test delete floating ip + assert: + that: + - result is failed + - 'result.msg == "Floating IP deletion is protected"' + +- name: test update Floating IP delete protection + hcloud_floating_ip: + name: "{{ hcloud_floating_ip_name }}" + type: ipv4 + delete_protection: false + register: floatingIP +- name: verify update Floating IP delete protection + assert: + that: + - floatingIP is changed + - floatingIP.hcloud_floating_ip.delete_protection is sameas false + +- name: test delete floating ip + hcloud_floating_ip: + name: "{{ hcloud_floating_ip_name }}" + state: "absent" + register: result +- name: verify test delete floating ip + assert: + that: + - result is changed + +- name: test create ipv6 floating ip + hcloud_floating_ip: + name: "{{ hcloud_floating_ip_name }}" + type: ipv6 + home_location: "fsn1" + state: "present" + register: result +- name: verify test create ipv6 floating ip + assert: + that: + - result is changed + +- name: test delete ipv6 floating ip + hcloud_floating_ip: + name: "{{ hcloud_floating_ip_name }}" + state: "absent" + register: result +- name: verify test delete ipv6 floating ip + assert: + that: + - result is changed + +- name: cleanup + hcloud_server: + name: "{{ hcloud_server_name }}" + state: absent + register: result +- name: verify cleanup + assert: + that: + - result is changed +- name: cleanup another server + hcloud_server: + name: "{{ main_server2.hcloud_server.name }}" + state: absent + register: result +- name: verify cleanup another server + assert: + that: + - result is changed + +- name: test create Floating IP with delete protection + hcloud_floating_ip: + name: "{{ hcloud_floating_ip_name }}" + type: ipv4 + home_location: fsn1 + delete_protection: true + register: floatingIP +- name: verify create Floating IP with delete protection + assert: + that: + - floatingIP is changed + - floatingIP.hcloud_floating_ip.delete_protection is sameas true + +- name: test delete Floating IP fails if it is protected + hcloud_floating_ip: + name: "{{ hcloud_floating_ip_name }}" + state: "absent" + register: result + ignore_errors: yes +- name: verify test delete floating ip + assert: + that: + - result is failed + - 'result.msg == "Floating IP deletion is protected"' + +- name: test update Floating IP delete protection + hcloud_floating_ip: + name: "{{ hcloud_floating_ip_name }}" + type: ipv4 + delete_protection: false + register: floatingIP +- name: verify update Floating IP delete protection + assert: + that: + - floatingIP is changed + - floatingIP.hcloud_floating_ip.delete_protection is sameas false + +- name: test delete floating ip + hcloud_floating_ip: + name: "{{ hcloud_floating_ip_name }}" + state: "absent" + register: result +- name: verify test delete floating ip + assert: + that: + - result is changed diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/aliases b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/aliases new file mode 100644 index 00000000..55ec821a --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/aliases @@ -0,0 +1,2 @@ +cloud/hcloud +shippable/hcloud/group2 diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/defaults/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/defaults/main.yml new file mode 100644 index 00000000..2a21de73 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/defaults/main.yml @@ -0,0 +1,5 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# 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}}-integration" diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/meta/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/meta/main.yml new file mode 100644 index 00000000..407c9018 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/meta/main.yml @@ -0,0 +1,3 @@ +collections: + - community.general.ipfilter + - hetzner.cloud diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/tasks/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/tasks/main.yml new file mode 100644 index 00000000..9ca1c2a4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/tasks/main.yml @@ -0,0 +1,87 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# 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/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/aliases b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/aliases new file mode 100644 index 00000000..55ec821a --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/aliases @@ -0,0 +1,2 @@ +cloud/hcloud +shippable/hcloud/group2 diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/defaults/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/defaults/main.yml new file mode 100644 index 00000000..ddca3328 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/defaults/main.yml @@ -0,0 +1,6 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# 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 diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/meta/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/meta/main.yml new file mode 100644 index 00000000..407c9018 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/meta/main.yml @@ -0,0 +1,3 @@ +collections: + - community.general.ipfilter + - hetzner.cloud diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/tasks/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/tasks/main.yml new file mode 100644 index 00000000..503d5b78 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/tasks/main.yml @@ -0,0 +1,62 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# 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 diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/aliases b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/aliases new file mode 100644 index 00000000..18dc30b6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/aliases @@ -0,0 +1,2 @@ +cloud/hcloud +shippable/hcloud/group1 diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/defaults/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/defaults/main.yml new file mode 100644 index 00000000..38e96f6d --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/defaults/main.yml @@ -0,0 +1,5 @@ +# Copyright: (c) 2020, Hetzner Cloud GmbH +# 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}}-integration" diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/meta/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/meta/main.yml new file mode 100644 index 00000000..407c9018 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/meta/main.yml @@ -0,0 +1,3 @@ +collections: + - community.general.ipfilter + - hetzner.cloud diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/tasks/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/tasks/main.yml new file mode 100644 index 00000000..a25e550d --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/tasks/main.yml @@ -0,0 +1,247 @@ +# Copyright: (c) 2020, Hetzner Cloud GmbH +# 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/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/aliases b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/aliases new file mode 100644 index 00000000..18dc30b6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/aliases @@ -0,0 +1,2 @@ +cloud/hcloud +shippable/hcloud/group1 diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/defaults/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/defaults/main.yml new file mode 100644 index 00000000..b5e53281 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/defaults/main.yml @@ -0,0 +1,6 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# 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}}-integration" +hcloud_server_name: "{{hcloud_prefix}}-lb-info" diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/meta/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/meta/main.yml new file mode 100644 index 00000000..407c9018 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/meta/main.yml @@ -0,0 +1,3 @@ +collections: + - community.general.ipfilter + - hetzner.cloud diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/tasks/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/tasks/main.yml new file mode 100644 index 00000000..9e652885 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/tasks/main.yml @@ -0,0 +1,128 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# 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/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/aliases b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/aliases new file mode 100644 index 00000000..18dc30b6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/aliases @@ -0,0 +1,2 @@ +cloud/hcloud +shippable/hcloud/group1 diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/defaults/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/defaults/main.yml new file mode 100644 index 00000000..8747bff4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/defaults/main.yml @@ -0,0 +1,6 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# 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}}-load_balancer-network" +hcloud_load_balancer_name: "{{hcloud_prefix}}-load_balancer-network" diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/meta/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/meta/main.yml new file mode 100644 index 00000000..407c9018 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/meta/main.yml @@ -0,0 +1,3 @@ +collections: + - community.general.ipfilter + - hetzner.cloud diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/tasks/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/tasks/main.yml new file mode 100644 index 00000000..76788ed8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/tasks/main.yml @@ -0,0 +1,155 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: setup network + hcloud_network: + name: "{{ hcloud_network_name }}" + ip_range: "10.0.0.0/8" + state: present + register: network +- name: verify setup network + assert: + that: + - network is success + +- name: setup subnetwork + hcloud_subnetwork: + network: "{{ hcloud_network_name }}" + ip_range: "10.0.0.0/16" + type: "cloud" + network_zone: "eu-central" + state: present + register: subnetwork +- name: verify subnetwork + assert: + that: + - subnetwork is success + +- name: setup load_balancer + hcloud_load_balancer: + name: "{{hcloud_load_balancer_name}}" + load_balancer_type: lb11 + state: present + location: "fsn1" + register: load_balancer +- name: verify setup load_balancer + assert: + that: + - load_balancer is success + +- name: test missing required parameters on create load_balancer network + hcloud_load_balancer_network: + state: present + register: result + ignore_errors: yes +- name: verify fail test missing required parameters on create load_balancer network + assert: + that: + - result is failed + - 'result.msg == "missing required arguments: load_balancer, network"' + +- name: test create load_balancer network with checkmode + hcloud_load_balancer_network: + network: "{{ hcloud_network_name }}" + load_balancer: "{{hcloud_load_balancer_name}}" + state: present + register: result + check_mode: yes +- name: verify test create load_balancer network with checkmode + assert: + that: + - result is changed + +- name: test create load_balancer network + hcloud_load_balancer_network: + network: "{{ hcloud_network_name }}" + load_balancer: "{{hcloud_load_balancer_name}}" + state: present + register: load_balancerNetwork +- 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 + +- name: test create load_balancer network idempotency + hcloud_load_balancer_network: + network: "{{ hcloud_network_name }}" + load_balancer: "{{hcloud_load_balancer_name}}" + state: present + register: load_balancerNetwork +- name: verify create load_balancer network idempotency + assert: + that: + - load_balancerNetwork is not changed + +- name: test absent load_balancer network + hcloud_load_balancer_network: + network: "{{ hcloud_network_name }}" + load_balancer: "{{hcloud_load_balancer_name}}" + state: absent + register: result +- name: verify test absent load_balancer network + assert: + that: + - result is changed + +- name: test create load_balancer network with specified ip + hcloud_load_balancer_network: + network: "{{ hcloud_network_name }}" + load_balancer: "{{hcloud_load_balancer_name}}" + ip: "10.0.0.2" + state: present + register: load_balancerNetwork +- 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" + +- name: cleanup create load_balancer network with specified ip + hcloud_load_balancer_network: + network: "{{ hcloud_network_name }}" + load_balancer: "{{hcloud_load_balancer_name}}" + state: absent + register: result +- name: verify cleanup create load_balancer network with specified ip + assert: + that: + - result is changed + +- name: cleanup load_balancer + hcloud_load_balancer: + name: "{{ hcloud_load_balancer_name }}" + state: absent + register: result +- name: verify cleanup load_balancer + assert: + that: + - result is success + +- name: cleanup 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 cleanup 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/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/aliases b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/aliases new file mode 100644 index 00000000..18dc30b6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/aliases @@ -0,0 +1,2 @@ +cloud/hcloud +shippable/hcloud/group1 diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/defaults/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/defaults/main.yml new file mode 100644 index 00000000..0876695b --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/defaults/main.yml @@ -0,0 +1,5 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# 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}}-load_balancer-target" diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/meta/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/meta/main.yml new file mode 100644 index 00000000..407c9018 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/meta/main.yml @@ -0,0 +1,3 @@ +collections: + - community.general.ipfilter + - hetzner.cloud diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/tasks/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/tasks/main.yml new file mode 100644 index 00000000..101effc0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/tasks/main.yml @@ -0,0 +1,112 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# 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: + name: "{{hcloud_load_balancer_name}}" + load_balancer_type: lb11 + state: present + location: "fsn1" + register: load_balancer +- name: verify setup load_balancer + assert: + that: + - load_balancer is success + +- name: test create load_balancer service with checkmode + hcloud_load_balancer_service: + load_balancer: "{{hcloud_load_balancer_name}}" + protocol: "http" + listen_port: 80 + state: present + register: result + check_mode: yes +- name: verify test create load_balancer service with checkmode + assert: + that: + - result is changed + +- 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 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: + load_balancer: "{{hcloud_load_balancer_name}}" + protocol: "http" + listen_port: 80 + state: present + register: load_balancer_service +- name: verify create load_balancer service idempotency + assert: + that: + - load_balancer_service is not changed + +- name: test update load_balancer service + hcloud_load_balancer_service: + load_balancer: "{{hcloud_load_balancer_name}}" + protocol: "tcp" + listen_port: 80 + 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 == "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: + load_balancer: "{{hcloud_load_balancer_name}}" + protocol: "http" + listen_port: 80 + state: absent + register: result +- name: verify test absent load_balancer service + assert: + that: + - result is changed + +- name: test create load_balancer service with http + hcloud_load_balancer_service: + load_balancer: "{{hcloud_load_balancer_name}}" + protocol: "http" + listen_port: 80 + http: + cookie_name: "Test" + sticky_sessions: yes + 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 + +- name: cleanup load_balancer + hcloud_load_balancer: + name: "{{ hcloud_load_balancer_name }}" + state: absent + register: result +- name: verify cleanup load_balancer + assert: + that: + - result is success diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/aliases b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/aliases new file mode 100644 index 00000000..18dc30b6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/aliases @@ -0,0 +1,2 @@ +cloud/hcloud +shippable/hcloud/group1 diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/defaults/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/defaults/main.yml new file mode 100644 index 00000000..bb38666b --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/defaults/main.yml @@ -0,0 +1,7 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# 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}}-lb-target" +hcloud_load_balancer_name: "{{hcloud_prefix}}-load_balancer-target" +hcloud_testing_ip: "176.9.59.39" diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/meta/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/meta/main.yml new file mode 100644 index 00000000..407c9018 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/meta/main.yml @@ -0,0 +1,3 @@ +collections: + - community.general.ipfilter + - hetzner.cloud diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/tasks/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/tasks/main.yml new file mode 100644 index 00000000..33756688 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/tasks/main.yml @@ -0,0 +1,129 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: setup server + hcloud_server: + name: "{{hcloud_server_name}}" + server_type: cx11 + image: ubuntu-20.04 + state: started + location: "fsn1" + 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 + state: present + location: "fsn1" + register: load_balancer +- name: verify setup load_balancer + assert: + that: + - load_balancer is success + +- name: test create load_balancer target with checkmode + hcloud_load_balancer_target: + type: "server" + load_balancer: "{{hcloud_load_balancer_name}}" + server: "{{hcloud_server_name}}" + state: present + register: result + check_mode: yes +- name: verify test create load_balancer target with checkmode + assert: + that: + - result 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 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: + type: "server" + load_balancer: "{{hcloud_load_balancer_name}}" + server: "{{hcloud_server_name}}" + state: present + register: load_balancer_target +- name: verify create load_balancer target idempotency + assert: + that: + - load_balancer_target is not changed + +- name: test absent load_balancer target + hcloud_load_balancer_target: + type: "server" + load_balancer: "{{hcloud_load_balancer_name}}" + server: "{{hcloud_server_name}}" + state: absent + register: result +- name: verify test absent load_balancer target + assert: + that: + - result is changed + +- name: test create label_selector target + hcloud_load_balancer_target: + type: "label_selector" + load_balancer: "{{hcloud_load_balancer_name}}" + label_selector: "application=backend" + state: present + register: load_balancer_target +- 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 + +- name: test create ip target + hcloud_load_balancer_target: + type: "ip" + load_balancer: "{{hcloud_load_balancer_name}}" + ip: "{{hcloud_testing_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 + +- name: cleanup load_balancer + hcloud_load_balancer: + name: "{{ hcloud_load_balancer_name }}" + state: absent + register: result +- name: verify cleanup load_balancer + assert: + that: + - result is success + +- name: cleanup + hcloud_server: + name: "{{hcloud_server_name}}" + state: absent + register: result +- name: verify cleanup + assert: + that: + - result is success diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_type_info/aliases b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_type_info/aliases new file mode 100644 index 00000000..55ec821a --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_type_info/aliases @@ -0,0 +1,2 @@ +cloud/hcloud +shippable/hcloud/group2 diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_type_info/defaults/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_type_info/defaults/main.yml new file mode 100644 index 00000000..b7fd8631 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_type_info/defaults/main.yml @@ -0,0 +1,5 @@ +# Copyright: (c) 2020, Hetzner Cloud GmbH +# 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 diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_type_info/meta/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_type_info/meta/main.yml new file mode 100644 index 00000000..407c9018 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_type_info/meta/main.yml @@ -0,0 +1,3 @@ +collections: + - community.general.ipfilter + - hetzner.cloud diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_type_info/tasks/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_type_info/tasks/main.yml new file mode 100644 index 00000000..bcd805a8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_type_info/tasks/main.yml @@ -0,0 +1,38 @@ +# Copyright: (c) 2020, Hetzner Cloud GmbH +# 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/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/aliases b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/aliases new file mode 100644 index 00000000..55ec821a --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/aliases @@ -0,0 +1,2 @@ +cloud/hcloud +shippable/hcloud/group2 diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/defaults/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/defaults/main.yml new file mode 100644 index 00000000..0d72a75c --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/defaults/main.yml @@ -0,0 +1,5 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# 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 diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/meta/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/meta/main.yml new file mode 100644 index 00000000..407c9018 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/meta/main.yml @@ -0,0 +1,3 @@ +collections: + - community.general.ipfilter + - hetzner.cloud diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/tasks/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/tasks/main.yml new file mode 100644 index 00000000..e0ae5f17 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/tasks/main.yml @@ -0,0 +1,57 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# 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 == 3 + +- 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 == 3 + +- 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/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/aliases b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/aliases new file mode 100644 index 00000000..4b3a9b36 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/aliases @@ -0,0 +1,3 @@ +cloud/hcloud +shippable/hcloud/group1 +disabled diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/defaults/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/defaults/main.yml new file mode 100644 index 00000000..ecfa6a73 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/defaults/main.yml @@ -0,0 +1,5 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# 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}}-integ" diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/meta/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/meta/main.yml new file mode 100644 index 00000000..407c9018 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/meta/main.yml @@ -0,0 +1,3 @@ +collections: + - community.general.ipfilter + - hetzner.cloud diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/tasks/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/tasks/main.yml new file mode 100644 index 00000000..6c40e4e0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/tasks/main.yml @@ -0,0 +1,215 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# 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 }}" + state: absent + register: result +- name: verify setup + assert: + that: + - result is success + +- name: test missing ip_range parameter on create Network + hcloud_network: + name: "{{hcloud_network_name}}" + register: result + ignore_errors: yes +- name: verify fail missing ip_range parameter on create Network result + assert: + that: + - result is failed + - 'result.msg == "missing required arguments: ip_range"' + +- name: test create Network with check mode + hcloud_network: + name: "{{hcloud_network_name}}" + ip_range: "10.0.0.0/16" + register: result + check_mode: yes +- name: verify create Network with check mode result + assert: + that: + - result is changed + +- name: test create Network + hcloud_network: + name: "{{hcloud_network_name}}" + ip_range: "10.0.0.0/16" + register: network +- name: verify test create Network result + assert: + that: + - network is changed + - network.hcloud_network.name == "{{hcloud_network_name}}" + - network.hcloud_network.ip_range == "10.0.0.0/16" + +- name: test create Network idempotence + hcloud_network: + name: "{{hcloud_network_name}}" + ip_range: "10.0.0.0/16" + register: network +- name: verify test create network + assert: + that: + - network is not changed + +- name: test update Network label + hcloud_network: + name: "{{hcloud_network_name}}" + labels: + key: value + register: network +- name: verify test update Network label + assert: + that: + - network is changed + - network.hcloud_network.labels.key == "value" + +- name: test update Network label idempotency + hcloud_network: + name: "{{hcloud_network_name}}" + labels: + key: value + register: network +- name: verify test update Network label idempotency + assert: + that: + - network is not changed + +- name: test update Network ip range + hcloud_network: + name: "{{hcloud_network_name}}" + ip_range: "10.0.0.0/8" + register: network +- name: verify test update Network ip range + assert: + that: + - network is changed + - network.hcloud_network.ip_range == "10.0.0.0/8" + +- name: test update Network ip range idempotency + hcloud_network: + name: "{{hcloud_network_name}}" + ip_range: "10.0.0.0/8" + register: network +- name: verify test update Network ip range idempotency + assert: + that: + - network is not changed + +- name: test update Network delete protection + hcloud_network: + name: "{{hcloud_network_name}}" + ip_range: "10.0.0.0/8" + delete_protection: true + register: network +- name: verify test update Network delete protection + assert: + that: + - network is changed + - network.hcloud_network.delete_protection is sameas true + +- name: test update Network delete protection idempotency + hcloud_network: + name: "{{hcloud_network_name}}" + ip_range: "10.0.0.0/8" + delete_protection: true + register: network +- name: verify test update Network delete protection idempotency + assert: + that: + - network is not changed + - network.hcloud_network.delete_protection is sameas true + +- name: test Network without delete protection set to be idempotent + hcloud_network: + name: "{{hcloud_network_name}}" + ip_range: "10.0.0.0/8" + register: network +- name: verify test Network without delete protection set to be idempotent + assert: + that: + - network is not changed + - network.hcloud_network.delete_protection is sameas true + +- name: test delete Network fails if it is protected + hcloud_network: + name: "{{hcloud_network_name}}" + state: absent + ignore_errors: yes + register: result +- name: verify delete Network + assert: + that: + - result is failed + - 'result.msg == "network deletion is protected"' + +- name: test update Network delete protection + hcloud_network: + name: "{{hcloud_network_name}}" + ip_range: "10.0.0.0/8" + delete_protection: false + register: network +- name: verify test update Network delete protection + assert: + that: + - network is changed + - network.hcloud_network.delete_protection is sameas false + +- name: test delete Network + hcloud_network: + name: "{{hcloud_network_name}}" + state: absent + register: result +- name: verify delete Network + assert: + that: + - result is success + + +- name: test create Network with delete protection + hcloud_network: + name: "{{hcloud_network_name}}" + ip_range: "10.0.0.0/8" + delete_protection: true + register: network +- name: verify create Network with delete protection + assert: + that: + - network is changed + - network.hcloud_network.delete_protection is sameas true + +- name: test delete Network fails if it is protected + hcloud_network: + name: "{{hcloud_network_name}}" + state: absent + ignore_errors: yes + register: result +- name: verify delete Network + assert: + that: + - result is failed + - 'result.msg == "network deletion is protected"' + +- name: test update Network delete protection + hcloud_network: + name: "{{hcloud_network_name}}" + delete_protection: false + register: network +- name: verify test update Network delete protection + assert: + that: + - network is changed + - network.hcloud_network.delete_protection is sameas false + +- name: test delete Network + hcloud_network: + name: "{{hcloud_network_name}}" + state: absent + register: result +- name: verify delete Network + assert: + that: + - result is success diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/aliases b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/aliases new file mode 100644 index 00000000..18dc30b6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/aliases @@ -0,0 +1,2 @@ +cloud/hcloud +shippable/hcloud/group1 diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/defaults/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/defaults/main.yml new file mode 100644 index 00000000..f8a5279f --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/defaults/main.yml @@ -0,0 +1,5 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# 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/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/meta/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/meta/main.yml new file mode 100644 index 00000000..407c9018 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/meta/main.yml @@ -0,0 +1,3 @@ +collections: + - community.general.ipfilter + - hetzner.cloud diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/tasks/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/tasks/main.yml new file mode 100644 index 00000000..e7924a8d --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/tasks/main.yml @@ -0,0 +1,117 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# 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/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/aliases b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/aliases new file mode 100644 index 00000000..18dc30b6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/aliases @@ -0,0 +1,2 @@ +cloud/hcloud +shippable/hcloud/group1 diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/defaults/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/defaults/main.yml new file mode 100644 index 00000000..fb46d1e1 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/defaults/main.yml @@ -0,0 +1,6 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# 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}}-rdns" +hcloud_floating_ip_name: "{{hcloud_prefix}}-rdns" diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/meta/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/meta/main.yml new file mode 100644 index 00000000..67d54d73 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/meta/main.yml @@ -0,0 +1,3 @@ +collections: + - ansible.netcommon + - hetzner.cloud diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/tasks/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/tasks/main.yml new file mode 100644 index 00000000..f34f1047 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/tasks/main.yml @@ -0,0 +1,140 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# 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-18.04" + ssh_keys: + - ci@ansible.hetzner.cloud + state: present + register: setup +- name: verify setup + assert: + that: + - setup is success + +- name: test create Floating IP + hcloud_floating_ip: + name: "{{ hcloud_floating_ip_name }}" + type: ipv4 + home_location: "fsn1" + register: floatingIP +- name: verify test create Floating IP + assert: + that: + - floatingIP 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 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: 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 diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/aliases b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/aliases new file mode 100644 index 00000000..18dc30b6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/aliases @@ -0,0 +1,2 @@ +cloud/hcloud +shippable/hcloud/group1 diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/defaults/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/defaults/main.yml new file mode 100644 index 00000000..62156272 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/defaults/main.yml @@ -0,0 +1,5 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# 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}}-routes" diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/meta/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/meta/main.yml new file mode 100644 index 00000000..67d54d73 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/meta/main.yml @@ -0,0 +1,3 @@ +collections: + - ansible.netcommon + - hetzner.cloud diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/tasks/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/tasks/main.yml new file mode 100644 index 00000000..7d816bf5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/tasks/main.yml @@ -0,0 +1,99 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# 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_route: + 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: destination, gateway, network"' + +- name: test create route with checkmode + hcloud_route: + network: "{{ hcloud_network_name }}" + destination: "10.100.1.0/24" + gateway: "10.0.1.1" + state: present + register: result + check_mode: yes +- name: verify test create route with checkmode + assert: + that: + - result is changed + +- name: test create route + hcloud_route: + network: "{{ hcloud_network_name }}" + destination: "10.100.1.0/24" + gateway: "10.0.1.1" + state: present + register: route +- 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" + +- name: test create route idempotency + hcloud_route: + network: "{{ hcloud_network_name }}" + destination: "10.100.1.0/24" + gateway: "10.0.1.1" + state: present + register: result +- name: verify create route idempotency + assert: + that: + - result is not changed + +- name: test fail create route with wrong gateway + hcloud_route: + network: "{{ hcloud_network_name }}" + destination: "10.100.1.0/24" + gateway: "10.0.1.2" + state: present + register: route + ignore_errors: yes +- name: verfiy fail create route with wrong gateway + assert: + that: + - route is failed + +- name: test absent route + hcloud_route: + network: "{{ hcloud_network_name }}" + destination: "10.100.1.0/24" + gateway: "10.0.1.1" + state: absent + register: result +- name: verify test absent route + 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/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/aliases b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/aliases new file mode 100644 index 00000000..18dc30b6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/aliases @@ -0,0 +1,2 @@ +cloud/hcloud +shippable/hcloud/group1 diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/defaults/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/defaults/main.yml new file mode 100644 index 00000000..b9a9a8df --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/defaults/main.yml @@ -0,0 +1,5 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# 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}}-integration" diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/meta/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/meta/main.yml new file mode 100644 index 00000000..407c9018 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/meta/main.yml @@ -0,0 +1,3 @@ +collections: + - community.general.ipfilter + - hetzner.cloud diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/main.yml new file mode 100644 index 00000000..f4464f18 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/main.yml @@ -0,0 +1,648 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# 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 }}" + state: absent + register: result +- name: verify setup + assert: + that: + - result is success +- name: test missing required parameters on create server + hcloud_server: + name: "{{ hcloud_server_name }}" + register: result + ignore_errors: yes +- name: verify fail test missing required parameters on create server + assert: + that: + - result is failed + - 'result.msg == "missing required arguments: server_type, image"' + +- name: test create server with check mode + hcloud_server: + name: "{{ hcloud_server_name }}" + server_type: cx11 + image: ubuntu-18.04 + state: present + register: result + check_mode: yes +- name: test create server server + assert: + that: + - result is changed + +- name: test create server + hcloud_server: + name: "{{ hcloud_server_name}}" + server_type: cx11 + image: ubuntu-18.04 + state: started + 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 create server idempotence + hcloud_server: + name: "{{ hcloud_server_name }}" + state: started + register: result +- name: verify create server idempotence + assert: + that: + - result is not changed + +- name: test stop server with check mode + hcloud_server: + name: "{{ hcloud_server_name }}" + state: stopped + register: result + check_mode: yes +- name: verify stop server with check mode + assert: + that: + - result is changed + - result.hcloud_server.status == "running" + +- name: test stop server + hcloud_server: + name: "{{ hcloud_server_name }}" + state: stopped + register: result +- name: verify stop server + assert: + that: + - result is changed + - result.hcloud_server.status == "off" + +- name: test start server with check mode + hcloud_server: + name: "{{ hcloud_server_name }}" + state: started + register: result + check_mode: true +- name: verify start server with check mode + assert: + that: + - result is changed + +- name: test start server + hcloud_server: + name: "{{ hcloud_server_name }}" + state: started + register: result +- name: verify start server + assert: + that: + - result is changed + - result.hcloud_server.status == "running" + +- name: test start server idempotence + hcloud_server: + name: "{{ hcloud_server_name }}" + state: started + register: result +- name: verify start server idempotence + assert: + that: + - result is not changed + - result.hcloud_server.status == "running" + +- name: test stop server by its id + hcloud_server: + id: "{{ main_server.hcloud_server.id }}" + state: stopped + register: result +- name: verify stop server by its id + assert: + that: + - result is changed + - result.hcloud_server.status == "off" + +- name: test resize server running without force + hcloud_server: + name: "{{ hcloud_server_name }}" + server_type: "cx21" + state: present + register: result + check_mode: true +- name: verify test resize server running without force + assert: + that: + - result is changed + - result.hcloud_server.server_type == "cx11" + +- name: test resize server with check mode + hcloud_server: + name: "{{ hcloud_server_name }}" + server_type: "cx21" + state: stopped + register: result + check_mode: true +- name: verify resize server with check mode + assert: + that: + - result is changed + +- name: test resize server without disk + hcloud_server: + name: "{{ hcloud_server_name }}" + server_type: "cx21" + state: stopped + register: result +- name: verify resize server without disk + assert: + that: + - result is changed + - result.hcloud_server.server_type == "cx21" + +- name: test resize server idempotence + hcloud_server: + name: "{{ hcloud_server_name }}" + server_type: "cx21" + state: stopped + register: result +- name: verify resize server idempotence + assert: + that: + - result is not changed + +- name: test resize server to smaller plan + hcloud_server: + name: "{{ hcloud_server_name }}" + server_type: "cx11" + state: stopped + register: result +- name: verify resize server to smaller plan + assert: + that: + - result is changed + - result.hcloud_server.server_type == "cx11" + +- name: test resize server with disk + hcloud_server: + name: "{{ hcloud_server_name }}" + server_type: "cx21" + upgrade_disk: true + state: stopped + register: result +- name: verify resize server with disk + assert: + that: + - result is changed + - result.hcloud_server.server_type == "cx21" + +- name: test enable backups with check mode + hcloud_server: + name: "{{ hcloud_server_name }}" + backups: true + state: stopped + register: result + check_mode: true +- name: verify enable backups with check mode + assert: + that: + - result is changed + +- name: test enable backups + hcloud_server: + name: "{{ hcloud_server_name }}" + backups: true + state: stopped + register: result +- name: verify enable backups + assert: + that: + - result is changed + - result.hcloud_server.backup_window != "" + +- name: test enable backups idempotence + hcloud_server: + name: "{{ hcloud_server_name }}" + backups: true + state: stopped + register: result +- name: verify enable backups idempotence + assert: + that: + - result is not changed + - result.hcloud_server.backup_window != "" + +- name: test rebuild server + hcloud_server: + name: "{{ hcloud_server_name }}" + image: ubuntu-18.04 + state: rebuild + register: result_after_test +- name: verify rebuild server + assert: + that: + - result_after_test is changed + - result.hcloud_server.id == result_after_test.hcloud_server.id + +- name: test rebuild server with check mode + hcloud_server: + name: "{{ hcloud_server_name }}" + image: ubuntu-18.04 + state: rebuild + register: result_after_test + check_mode: true +- name: verify rebuild server with check mode + assert: + that: + - result_after_test is changed + +- name: test update server protection booth protection arguments are required + hcloud_server: + name: "{{ hcloud_server_name }}" + delete_protection: true + state: present + register: result_after_test + ignore_errors: true +- name: verify update server protection booth protection arguments are required + assert: + that: + - result_after_test is failed + - '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: + name: "{{ hcloud_server_name }}" + delete_protection: true + rebuild_protection: false + state: present + register: result_after_test + ignore_errors: true +- name: verify update server protection fails if they are not the same + assert: + that: + - result_after_test is failed + +- name: test update server protection + hcloud_server: + name: "{{ hcloud_server_name }}" + delete_protection: true + rebuild_protection: true + state: present + register: result_after_test + ignore_errors: true +- name: verify update server protection + assert: + that: + - result_after_test is changed + - result_after_test.hcloud_server.delete_protection is sameas true + - result_after_test.hcloud_server.rebuild_protection is sameas true + +- name: test server without protection set to be idempotent + hcloud_server: + name: "{{hcloud_server_name}}" + register: result_after_test +- name: verify test server without protection set to be idempotent + assert: + that: + - result_after_test is not changed + - result_after_test.hcloud_server.delete_protection is sameas true + - result_after_test.hcloud_server.rebuild_protection is sameas true + +- name: test delete server fails if it is protected + hcloud_server: + name: "{{hcloud_server_name}}" + state: absent + ignore_errors: yes + register: result +- name: verify delete server fails if it is protected + assert: + that: + - result is failed + - 'result.msg == "server deletion is protected"' + +- name: test rebuild server fails if it is protected + hcloud_server: + name: "{{hcloud_server_name}}" + image: ubuntu-18.04 + state: rebuild + ignore_errors: yes + register: result +- name: verify rebuild server fails if it is protected + assert: + that: + - result is failed + - 'result.msg == "server rebuild is protected"' + +- name: test remove server protection + hcloud_server: + name: "{{ hcloud_server_name }}" + delete_protection: false + rebuild_protection: false + state: present + register: result_after_test + ignore_errors: true +- name: verify remove server protection + assert: + that: + - result_after_test is changed + - result_after_test.hcloud_server.delete_protection is sameas false + - result_after_test.hcloud_server.rebuild_protection is sameas false + +- name: absent server + hcloud_server: + name: "{{ hcloud_server_name }}" + state: absent + register: result +- name: verify absent server + assert: + that: + - result is success + +- name: test create server with ssh key + hcloud_server: + name: "{{ hcloud_server_name}}" + server_type: cx11 + image: "ubuntu-18.04" + ssh_keys: + - ci@ansible.hetzner.cloud + 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.server_type == "cx11" + - main_server.hcloud_server.status == "running" + - main_server.root_password != "" + +- name: absent server + hcloud_server: + name: "{{ hcloud_server_name }}" + state: absent + register: result +- name: verify absent server + assert: + that: + - result is success + +- name: test create server with rescue_mode + hcloud_server: + name: "{{ hcloud_server_name}}" + server_type: cx11 + image: "ubuntu-18.04" + ssh_keys: + - ci@ansible.hetzner.cloud + rescue_mode: "linux64" + state: started + register: main_server +- name: verify create server with rescue_mode + 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 != "" + - main_server.hcloud_server.rescue_enabled is sameas true + +- name: absent server + hcloud_server: + name: "{{ hcloud_server_name }}" + state: absent + register: result +- name: verify absent server + assert: + that: + - result is success + +- name: setup server + hcloud_server: + name: "{{ hcloud_server_name}}" + server_type: cx11 + image: ubuntu-18.04 + state: started + register: main_server +- name: verify setup 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 activate rescue mode with check_mode + hcloud_server: + name: "{{ hcloud_server_name }}" + rescue_mode: "linux64" + ssh_keys: + - ci@ansible.hetzner.cloud + state: present + register: main_server + check_mode: true +- name: verify activate rescue mode + assert: + that: + - main_server is changed + +- name: test activate rescue mode + hcloud_server: + name: "{{ hcloud_server_name }}" + rescue_mode: "linux64" + ssh_keys: + - ci@ansible.hetzner.cloud + state: present + register: main_server +- name: verify activate rescue mode + assert: + that: + - main_server is changed + - main_server.hcloud_server.rescue_enabled is sameas true + +- name: test disable rescue mode + hcloud_server: + name: "{{ hcloud_server_name }}" + ssh_keys: + - ci@ansible.hetzner.cloud + state: present + register: main_server +- name: verify activate rescue mode + assert: + that: + - main_server is changed + - main_server.hcloud_server.rescue_enabled is sameas false + +- name: test activate rescue mode without ssh keys + hcloud_server: + name: "{{ hcloud_server_name }}" + rescue_mode: "linux64" + state: present + register: main_server +- name: verify activate rescue mode without ssh keys + assert: + that: + - main_server is changed + - main_server.hcloud_server.rescue_enabled is sameas true + +- name: cleanup + hcloud_server: + name: "{{ hcloud_server_name }}" + state: absent + register: result +- name: verify cleanup + assert: + that: + - result is success + +- name: test create server with labels + hcloud_server: + name: "{{ hcloud_server_name}}" + server_type: cx11 + image: "ubuntu-18.04" + ssh_keys: + - ci@ansible.hetzner.cloud + labels: + key: value + mylabel: "val123" + state: started + register: main_server +- name: verify create server with labels + assert: + that: + - main_server is changed + - main_server.hcloud_server.labels.key == "value" + - main_server.hcloud_server.labels.mylabel == "val123" + +- name: test update server with labels + hcloud_server: + name: "{{ hcloud_server_name}}" + server_type: cx11 + image: "ubuntu-18.04" + ssh_keys: + - ci@ansible.hetzner.cloud + labels: + key: other + mylabel: "val123" + state: started + register: main_server +- name: verify update server with labels + assert: + that: + - main_server is changed + - main_server.hcloud_server.labels.key == "other" + - main_server.hcloud_server.labels.mylabel == "val123" + +- name: test update server with labels in other order + hcloud_server: + name: "{{ hcloud_server_name}}" + server_type: cx11 + image: "ubuntu-18.04" + ssh_keys: + - ci@ansible.hetzner.cloud + labels: + mylabel: "val123" + key: other + state: started + register: main_server +- name: verify update server with labels in other order + assert: + that: + - main_server is not changed + +- name: cleanup with labels + hcloud_server: + name: "{{ hcloud_server_name }}" + state: absent + register: result +- name: verify cleanup + assert: + that: + - result is success + +- name: test create server with enabled backups + hcloud_server: + name: "{{ hcloud_server_name }}" + server_type: cpx11 + backups: true + image: "ubuntu-18.04" + ssh_keys: + - ci@ansible.hetzner.cloud + state: present + register: result +- name: verify enable backups + assert: + that: + - result is changed + - result.hcloud_server.backup_window != "" + +- name: test create server with enabled backups + hcloud_server: + name: "{{ hcloud_server_name }}" + state: absent + register: result +- name: verify cleanup + assert: + that: + - result is success + +- name: test create server with protection + hcloud_server: + name: "{{ hcloud_server_name }}" + delete_protection: true + rebuild_protection: true + server_type: cpx11 + image: "ubuntu-20.04" + ssh_keys: + - ci@ansible.hetzner.cloud + state: present + register: result_after_test + ignore_errors: true +- name: verify create server with protection + assert: + that: + - result_after_test is changed + - result_after_test.hcloud_server.delete_protection is sameas true + - result_after_test.hcloud_server.rebuild_protection is sameas true + + +- name: test delete server fails if it is protected + hcloud_server: + name: "{{hcloud_server_name}}" + state: absent + ignore_errors: yes + register: result +- name: verify delete server fails if it is protected + assert: + that: + - result is failed + - 'result.msg == "server deletion is protected"' + +- name: remove protection from server + hcloud_server: + name: "{{ hcloud_server_name }}" + delete_protection: false + rebuild_protection: false + state: present + register: result_after_test + ignore_errors: true +- name: verify update server protection + assert: + that: + - result_after_test is changed + - result_after_test.hcloud_server.delete_protection is sameas false + - result_after_test.hcloud_server.rebuild_protection is sameas false + +- name: cleanup + hcloud_server: + name: "{{ hcloud_server_name }}" + state: absent + register: result +- name: verify cleanup + assert: + that: + - result is success diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/aliases b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/aliases new file mode 100644 index 00000000..55ec821a --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/aliases @@ -0,0 +1,2 @@ +cloud/hcloud +shippable/hcloud/group2 diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/defaults/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/defaults/main.yml new file mode 100644 index 00000000..b9a9a8df --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/defaults/main.yml @@ -0,0 +1,5 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# 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}}-integration" diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/meta/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/meta/main.yml new file mode 100644 index 00000000..407c9018 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/meta/main.yml @@ -0,0 +1,3 @@ +collections: + - community.general.ipfilter + - hetzner.cloud diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/tasks/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/tasks/main.yml new file mode 100644 index 00000000..92eac5cc --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/tasks/main.yml @@ -0,0 +1,97 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# 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-18.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: hcloud_server + check_mode: yes + +- name: verify test gather hcloud server infos in check mode + assert: + that: + - hcloud_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: hcloud_server +- name: verify test gather hcloud server infos with correct label selector + assert: + that: + - hcloud_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: hcloud_server +- name: verify test gather hcloud server infos with wrong label selector + assert: + that: + - hcloud_server.hcloud_server_info | list | count == 0 + +- name: test gather hcloud server infos with correct name + hcloud_server_info: + name: "{{hcloud_server_name}}" + register: hcloud_server +- name: verify test gather hcloud server infos with correct name + assert: + that: + - hcloud_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: hcloud_server +- name: verify test gather hcloud server infos with wrong name + assert: + that: + - hcloud_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: hcloud_server +- name: verify test gather hcloud server infos with correct id + assert: + that: + - hcloud_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: hcloud_server +- name: verify test gather hcloud server infos with wrong id + assert: + that: + - hcloud_server.hcloud_server_info | list | count == 0 + +- name: cleanup + hcloud_server: + name: "{{ hcloud_server_name }}" + state: absent diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/aliases b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/aliases new file mode 100644 index 00000000..7f17468b --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/aliases @@ -0,0 +1,3 @@ +cloud/hcloud +shippable/hcloud/group2 +disabled diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/defaults/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/defaults/main.yml new file mode 100644 index 00000000..1d62e5dc --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/defaults/main.yml @@ -0,0 +1,6 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# 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}}-server-network" +hcloud_server_name: "{{hcloud_prefix}}-server-network" diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/meta/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/meta/main.yml new file mode 100644 index 00000000..407c9018 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/meta/main.yml @@ -0,0 +1,3 @@ +collections: + - community.general.ipfilter + - hetzner.cloud diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/tasks/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/tasks/main.yml new file mode 100644 index 00000000..754018a6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/tasks/main.yml @@ -0,0 +1,222 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: setup network + hcloud_network: + name: "{{ hcloud_network_name }}" + ip_range: "10.0.0.0/8" + state: present + register: network +- name: verify setup network + assert: + that: + - network is success + +- name: setup subnetwork + hcloud_subnetwork: + network: "{{ hcloud_network_name }}" + ip_range: "10.0.0.0/16" + type: "server" + network_zone: "eu-central" + state: present + register: subnetwork +- name: verify subnetwork + assert: + that: + - subnetwork is success + +- name: setup server + hcloud_server: + name: "{{hcloud_server_name}}" + server_type: cx11 + image: ubuntu-18.04 + state: started + location: "fsn1" + register: server +- name: verify setup server + assert: + that: + - server is success + +- name: test missing required parameters on create server network + hcloud_server_network: + state: present + register: result + ignore_errors: yes +- name: verify fail test missing required parameters on create server network + assert: + that: + - result is failed + - 'result.msg == "missing required arguments: network, server"' + +- name: test create server network with checkmode + hcloud_server_network: + network: "{{ hcloud_network_name }}" + server: "{{hcloud_server_name}}" + state: present + register: result + check_mode: yes +- name: verify test create server network with checkmode + assert: + that: + - result is changed + +- name: test create server network + hcloud_server_network: + network: "{{ hcloud_network_name }}" + server: "{{hcloud_server_name}}" + state: present + register: serverNetwork +- 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 + +- name: test create server network idempotency + hcloud_server_network: + network: "{{ hcloud_network_name }}" + server: "{{hcloud_server_name}}" + state: present + register: serverNetwork +- name: verify create server network idempotency + assert: + that: + - serverNetwork is not changed + +- name: test absent server network + hcloud_server_network: + network: "{{ hcloud_network_name }}" + server: "{{hcloud_server_name}}" + state: absent + register: result +- name: verify test absent server network + assert: + that: + - result is changed + +- name: test create server network with specified ip + hcloud_server_network: + network: "{{ hcloud_network_name }}" + server: "{{hcloud_server_name}}" + ip: "10.0.0.2" + state: present + register: serverNetwork +- 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" + +- name: cleanup create server network with specified ip + hcloud_server_network: + network: "{{ hcloud_network_name }}" + server: "{{hcloud_server_name}}" + state: absent + register: result +- name: verify cleanup create server network with specified ip + assert: + that: + - result is changed + +- name: test create server network with alias ips + hcloud_server_network: + network: "{{ hcloud_network_name }}" + server: "{{hcloud_server_name}}" + ip: "10.0.0.2" + alias_ips: + - "10.0.1.2" + - "10.0.2.3" + state: present + register: serverNetwork +- 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"' + +- name: test update server network with alias ips + hcloud_server_network: + network: "{{ hcloud_network_name }}" + server: "{{hcloud_server_name}}" + ip: "10.0.0.2" + alias_ips: + - "10.0.2.3" + - "10.0.3.1" + state: present + register: serverNetwork +- 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"' + +- name: test update server network with alias ips idempotency + hcloud_server_network: + network: "{{ hcloud_network_name }}" + server: "{{hcloud_server_name}}" + ip: "10.0.0.2" + alias_ips: + - "10.0.2.3" + - "10.0.3.1" + state: present + register: serverNetwork +- name: verify create server network with alias ips idempotency + assert: + that: + - serverNetwork is not changed + +- name: cleanup create server network with alias ips + hcloud_server_network: + network: "{{ hcloud_network_name }}" + server: "{{hcloud_server_name}}" + state: absent + register: result +- name: verify cleanup create server network with alias ips + assert: + that: + - result is changed + +- name: cleanup server + hcloud_server: + name: "{{ hcloud_server_name }}" + state: absent + register: result +- name: verify cleanup server + assert: + that: + - result is success + +- name: cleanup subnetwork + hcloud_subnetwork: + network: "{{ hcloud_network_name }}" + ip_range: "10.0.0.0/16" + type: "server" + network_zone: "eu-central" + state: absent + register: result +- name: verify cleanup 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/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/aliases b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/aliases new file mode 100644 index 00000000..55ec821a --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/aliases @@ -0,0 +1,2 @@ +cloud/hcloud +shippable/hcloud/group2 diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/defaults/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/defaults/main.yml new file mode 100644 index 00000000..05502aa9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/defaults/main.yml @@ -0,0 +1,5 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# 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 diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/meta/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/meta/main.yml new file mode 100644 index 00000000..407c9018 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/meta/main.yml @@ -0,0 +1,3 @@ +collections: + - community.general.ipfilter + - hetzner.cloud diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/tasks/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/tasks/main.yml new file mode 100644 index 00000000..3c1fce8c --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/tasks/main.yml @@ -0,0 +1,38 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# 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/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/aliases b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/aliases new file mode 100644 index 00000000..55ec821a --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/aliases @@ -0,0 +1,2 @@ +cloud/hcloud +shippable/hcloud/group2 diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/defaults/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/defaults/main.yml new file mode 100644 index 00000000..666d3346 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/defaults/main.yml @@ -0,0 +1,8 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# 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}}-integration" +hcloud_ssh_key_name: "{{hcloud_prefix}}-integration" +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" diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/meta/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/meta/main.yml new file mode 100644 index 00000000..5dcc0725 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/meta/main.yml @@ -0,0 +1,5 @@ +dependencies: + - setup_sshkey +collections: + - community.general.ipfilter + - hetzner.cloud diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/tasks/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/tasks/main.yml new file mode 100644 index 00000000..baaadd4d --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/tasks/main.yml @@ -0,0 +1,144 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# 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: + name: "{{ hcloud_ssh_key_name }}" + register: result + ignore_errors: yes +- name: verify fail test missing required parameters on create ssh_key + assert: + that: + - result is failed + - 'result.msg == "missing required arguments: public_key"' + +- name: test create ssh key with check mode + hcloud_ssh_key: + name: "{{ hcloud_ssh_key_name }}" + public_key: "{{ key_material }}" + register: result + check_mode: yes +- name: test create ssh key with check mode + assert: + that: + - result is changed + +- name: test create ssh key + hcloud_ssh_key: + name: "{{ hcloud_ssh_key_name }}" + public_key: "{{ key_material }}" + labels: + key: value + my-label: label + register: sshKey +- 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" + +- name: test create ssh key idempotence + hcloud_ssh_key: + name: "{{ hcloud_ssh_key_name }}" + public_key: "{{ key_material }}" + register: result +- name: verify create ssh key idempotence + assert: + that: + - result is not changed + +- name: test update ssh key with check mode + hcloud_ssh_key: + id: "{{ sshKey.hcloud_ssh_key.id }}" + name: "changed-{{ hcloud_ssh_key_name }}" + register: result + check_mode: yes +- 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 }}" + name: "changed-{{ hcloud_ssh_key_name }}" + labels: + key: value + register: result +- name: test update ssh key + assert: + that: + - result is changed + - 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 }}" + name: "changed-{{ hcloud_ssh_key_name }}" + labels: + key: value + register: result +- name: test update ssh key with same labels + assert: + that: + - result is not changed + +- name: test update ssh key with other labels + hcloud_ssh_key: + id: "{{ sshKey.hcloud_ssh_key.id }}" + name: "changed-{{ hcloud_ssh_key_name }}" + labels: + key: value + test: "val123" + register: result +- name: test update ssh key with other labels + assert: + that: + - result is changed + +- name: test rename ssh key + hcloud_ssh_key: + id: "{{ sshKey.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 }}" + +- name: test create server with ssh key + hcloud_server: + name: "{{ hcloud_server_name }}" + server_type: cx11 + image: "ubuntu-18.04" + ssh_keys: + - "{{ hcloud_ssh_key_name }}" + state: started + register: main_server +- name: verify create server with ssh key + assert: + 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 server + assert: + that: + - result is success + +- name: cleanup + hcloud_server: + name: "{{ hcloud_server_name }}" + state: absent + register: result +- name: verify cleanup + assert: + that: + - result is success diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/aliases b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/aliases new file mode 100644 index 00000000..55ec821a --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/aliases @@ -0,0 +1,2 @@ +cloud/hcloud +shippable/hcloud/group2 diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/defaults/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/defaults/main.yml new file mode 100644 index 00000000..06c1471a --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/defaults/main.yml @@ -0,0 +1,5 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# 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}}-ssh_key_facts" diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/meta/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/meta/main.yml new file mode 100644 index 00000000..5dcc0725 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/meta/main.yml @@ -0,0 +1,5 @@ +dependencies: + - setup_sshkey +collections: + - community.general.ipfilter + - hetzner.cloud diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/tasks/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/tasks/main.yml new file mode 100644 index 00000000..87cbd262 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/tasks/main.yml @@ -0,0 +1,68 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# 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/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/aliases b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/aliases new file mode 100644 index 00000000..af1d98c3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/aliases @@ -0,0 +1,2 @@ +cloud/hcloud +shippable/hcloud/group3 diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/defaults/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/defaults/main.yml new file mode 100644 index 00000000..51a123db --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/defaults/main.yml @@ -0,0 +1,6 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# 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}}-subnet" +hetzner_vswitch_id: 15311 diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/meta/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/meta/main.yml new file mode 100644 index 00000000..407c9018 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/meta/main.yml @@ -0,0 +1,3 @@ +collections: + - community.general.ipfilter + - hetzner.cloud diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/tasks/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/tasks/main.yml new file mode 100644 index 00000000..0453f9d1 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/tasks/main.yml @@ -0,0 +1,125 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# 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/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/aliases b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/aliases new file mode 100644 index 00000000..55ec821a --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/aliases @@ -0,0 +1,2 @@ +cloud/hcloud +shippable/hcloud/group2 diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/defaults/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/defaults/main.yml new file mode 100644 index 00000000..a8f03b4e --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/defaults/main.yml @@ -0,0 +1,6 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# 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}}-integ" +hcloud_server_name: "{{hcloud_prefix}}-volume-server" diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/meta/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/meta/main.yml new file mode 100644 index 00000000..407c9018 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/meta/main.yml @@ -0,0 +1,3 @@ +collections: + - community.general.ipfilter + - hetzner.cloud diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/tasks/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/tasks/main.yml new file mode 100644 index 00000000..f763a52f --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/tasks/main.yml @@ -0,0 +1,289 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: setup server + hcloud_server: + name: "{{hcloud_server_name}}" + server_type: cx11 + image: ubuntu-18.04 + state: started + location: "fsn1" + register: vol_server +- name: verify setup server + assert: + that: + - vol_server is changed + +- name: test missing size parameter on create Volume + hcloud_volume: + name: "{{hcloud_volume_name}}" + server: "{{hcloud_server_name}}" + register: result + ignore_errors: yes +- name: verify fail test missing size parameter on create Volume + assert: + that: + - result is failed + - 'result.msg == "missing required arguments: size"' + +- name: test create Volume with check mode + hcloud_volume: + name: "{{hcloud_volume_name}}" + size: 10 + location: "fsn1" + register: result + check_mode: yes +- name: verify create Volume with check mode result + assert: + that: + - result is changed + +- name: test create Volume + hcloud_volume: + name: "{{hcloud_volume_name}}" + size: 10 + location: "fsn1" + register: volume +- name: verify test create Volume + assert: + that: + - volume is changed + - 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.linux_device is defined + +- name: test create Volume idempotence + hcloud_volume: + name: "{{hcloud_volume_name}}" + size: 10 + location: "fsn1" + register: volume +- name: verify test create Volume + assert: + that: + - volume is not changed + +- name: test attach Volume with checkmode + hcloud_volume: + name: "{{hcloud_volume_name}}" + server: "{{hcloud_server_name}}" + check_mode: yes + register: volume +- name: verify test attach Volume with checkmode + assert: + that: + - volume is changed + - volume.hcloud_volume.server != "{{hcloud_server_name}}" + +- name: test attach Volume + hcloud_volume: + name: "{{hcloud_volume_name}}" + server: "{{hcloud_server_name}}" + register: volume +- name: verify attach volume + assert: + that: + - volume is changed + - volume.hcloud_volume.server == "{{hcloud_server_name}}" + +- name: test attach Volume idempotence + hcloud_volume: + name: "{{hcloud_volume_name}}" + server: "{{hcloud_server_name}}" + register: volume +- name: verify attach Volume idempotence + assert: + that: + - volume is not changed + - volume.hcloud_volume.server == "{{hcloud_server_name}}" + +- name: test detach Volume with checkmode + hcloud_volume: + name: "{{hcloud_volume_name}}" + check_mode: yes + register: volume +- name: verify detach Volume with checkmode + assert: + that: + - volume is changed + - volume.hcloud_volume.server == "{{hcloud_server_name}}" + +- name: test detach Volume + hcloud_volume: + name: "{{hcloud_volume_name}}" + register: volume +- name: verify detach volume + assert: + that: + - volume is changed + - volume.hcloud_volume.location == "fsn1" + - volume.hcloud_volume.server != "{{hcloud_server_name}}" + +- name: test update Volume label + hcloud_volume: + name: "{{hcloud_volume_name}}" + labels: + key: value + register: volume +- name: verify test update Volume label + assert: + that: + - volume is changed + - volume.hcloud_volume.labels.key == "value" + +- name: test update Volume label with the same label + hcloud_volume: + name: "{{hcloud_volume_name}}" + labels: + key: value + register: volume +- name: verify test update Volume lable with the same label + assert: + that: + - volume is not changed + +- name: test increase Volume size + hcloud_volume: + name: "{{hcloud_volume_name}}" + size: 11 + register: volume +- name: verify test increase Volume size + assert: + that: + - volume is changed + - volume.hcloud_volume.size == 11 + +- name: test decreace Volume size + hcloud_volume: + name: "{{hcloud_volume_name}}" + size: 10 + register: volume +- name: verify test decreace Volume size + assert: + that: + - volume is not changed + - volume.hcloud_volume.size == 11 + +- name: test update Volume delete protection + hcloud_volume: + name: "{{hcloud_volume_name}}" + delete_protection: true + register: volume +- name: verify test update Volume delete protection + assert: + that: + - volume is changed + - volume.hcloud_volume.delete_protection is sameas true + +- name: test update Volume delete protection idempotency + hcloud_volume: + name: "{{hcloud_volume_name}}" + delete_protection: true + register: volume +- name: verify test update Volume delete protection idempotency + assert: + that: + - volume is not changed + - volume.hcloud_volume.delete_protection is sameas true + +- name: test Volume without delete protection set to be idempotent + hcloud_volume: + name: "{{hcloud_volume_name}}" + register: volume +- name: verify test Volume without delete protection set to be idempotent + assert: + that: + - volume is not changed + - volume.hcloud_volume.delete_protection is sameas true + +- name: test delete Volume fails if it is protected + hcloud_volume: + name: "{{hcloud_volume_name}}" + state: absent + ignore_errors: yes + register: result +- name: verify delete Volume fails if it is protected + assert: + that: + - result is failed + - 'result.msg == "volume deletion is protected"' + +- name: test update Volume delete protection + hcloud_volume: + name: "{{hcloud_volume_name}}" + delete_protection: false + register: volume +- name: verify test update Volume delete protection + assert: + that: + - volume is changed + - volume.hcloud_volume.delete_protection is sameas false + +- name: test delete Volume + hcloud_volume: + name: "{{hcloud_volume_name}}" + state: absent + register: result +- name: verify delete Volume + assert: + that: + - result is success + + +- name: test create Volume with delete protection + hcloud_volume: + name: "{{hcloud_volume_name}}" + size: 10 + location: "fsn1" + delete_protection: true + register: volume +- name: verify create Volume with delete protection + assert: + that: + - volume is changed + - volume.hcloud_volume.delete_protection is sameas true + +- name: test delete Volume fails if it is protected + hcloud_volume: + name: "{{hcloud_volume_name}}" + state: absent + ignore_errors: yes + register: result +- name: verify delete Volume fails if it is protected + assert: + that: + - result is failed + - 'result.msg == "volume deletion is protected"' + +- name: test update Volume delete protection + hcloud_volume: + name: "{{hcloud_volume_name}}" + delete_protection: false + register: volume +- name: verify test update Volume delete protection + assert: + that: + - volume is changed + - volume.hcloud_volume.delete_protection is sameas false + +- name: test delete Volume + hcloud_volume: + name: "{{hcloud_volume_name}}" + state: absent + register: result +- name: verify delete Volume + assert: + that: + - result is success + +- name: cleanup + hcloud_server: + name: "{{ hcloud_server_name }}" + state: absent + register: result +- name: verify cleanup + assert: + that: + - result is success diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/aliases b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/aliases new file mode 100644 index 00000000..55ec821a --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/aliases @@ -0,0 +1,2 @@ +cloud/hcloud +shippable/hcloud/group2 diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/defaults/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/defaults/main.yml new file mode 100644 index 00000000..d308c950 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/defaults/main.yml @@ -0,0 +1,5 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# 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}}-facts" diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/meta/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/meta/main.yml new file mode 100644 index 00000000..407c9018 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/meta/main.yml @@ -0,0 +1,3 @@ +collections: + - community.general.ipfilter + - hetzner.cloud diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/tasks/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/tasks/main.yml new file mode 100644 index 00000000..ecea7ad3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/tasks/main.yml @@ -0,0 +1,101 @@ +# Copyright: (c) 2019, Hetzner Cloud GmbH +# 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/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/setup_selfsigned_certificate/tasks/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/setup_selfsigned_certificate/tasks/main.yml new file mode 100644 index 00000000..27defe44 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/setup_selfsigned_certificate/tasks/main.yml @@ -0,0 +1,27 @@ +# Copyright: (c) 2020, Hetzner Cloud GmbH +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +- 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: 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 diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/setup_sshkey/tasks/main.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/setup_sshkey/tasks/main.yml new file mode 100644 index 00000000..18c571b6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/integration/targets/setup_sshkey/tasks/main.yml @@ -0,0 +1,55 @@ +# (c) 2014, James Laska + +# 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 . + +- 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/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/requirements.yml b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/requirements.yml new file mode 100644 index 00000000..6c49d0d9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/requirements.yml @@ -0,0 +1,3 @@ +integration_tests_dependencies: +- community.general +- ansible.netcommon diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/sanity/requirements.txt b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/sanity/requirements.txt new file mode 100644 index 00000000..3e3a9669 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/sanity/requirements.txt @@ -0,0 +1,4 @@ +packaging # needed for update-bundled and changelog +sphinx ; python_version >= '3.5' # docs build requires python 3+ +sphinx-notfound-page ; python_version >= '3.5' # docs build requires python 3+ +straight.plugin ; python_version >= '3.5' # needed for hacking/build-ansible.py which will host changelog generation and requires python 3+ diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/utils/gitlab/gitlab.sh b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/utils/gitlab/gitlab.sh new file mode 100755 index 00000000..33c3af8e --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/utils/gitlab/gitlab.sh @@ -0,0 +1,96 @@ +#!/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 "$*"; +} + +test="$(join / "${args[@]:1}")" +command -v python +python -V + +function retry +{ + 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 +export ANSIBLE_COLLECTIONS_PATHS="${HOME}/.ansible" +SHIPPABLE_RESULT_DIR="$(pwd)/shippable" +TEST_DIR="${ANSIBLE_COLLECTIONS_PATHS}/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 rstcheck +# END: HACK + +export PYTHONIOENCODING='utf-8' + +if [ "${JOB_TRIGGERED_BY_NAME:-}" == "nightly-trigger" ]; then + COMPLETE=yes +fi + + +if [ -n "${COMPLETE:-}" ]; then + # 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="" +else + # 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 +find plugins -type d -empty -print -delete + +ansible-test env --dump --show --timeout "50" --color -v + +group="${args[1]}" +echo $test +if [[ "${test}" =~ hcloud ]]; then + group="${args[3]}" + bash tests/utils/gitlab/integration.sh "shippable/hcloud/group${group}/" +else + bash tests/utils/gitlab/sanity.sh "sanity/${group}" +fi diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/utils/gitlab/integration.sh b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/utils/gitlab/integration.sh new file mode 100755 index 00000000..2d660c88 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/utils/gitlab/integration.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +target="$1" + +HCLOUD_TOKEN=$(cat hcloud_token.txt) +changed_all_target="shippable/${cloud}/smoketest/" + +echo "[default] +hcloud_api_token=${HCLOUD_TOKEN} +" >> $(pwd)/tests/integration/cloud-config-hcloud.ini +# shellcheck disable=SC2086 +export SHIPPABLE="true" +export SHIPPABLE_BUILD_NUMBER="gl-$(cat prefix.txt)" +export SHIPPABLE_JOB_NUMBER="$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 2 | head -n 1)" +ansible-test integration --color --local -vv "${target}" ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} ${UNSTABLE:+"$UNSTABLE"} diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/utils/gitlab/sanity.sh b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/utils/gitlab/sanity.sh new file mode 100755 index 00000000..1418edc0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/utils/gitlab/sanity.sh @@ -0,0 +1,47 @@ +#!/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 + ../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/) ;; +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 +fi + +pip install pycodestyle +pip install yamllint +pip install voluptuous +pip install pylint +# shellcheck disable=SC2086 +ansible-test sanity --color -v --junit ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} \ + --base-branch "${base_branch}" \ + --exclude shippable.yml --exclude tests/utils/ \ + "${options[@]}" --allow-disabled diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/utils/shippable/check_matrix.py b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/utils/shippable/check_matrix.py new file mode 100755 index 00000000..dfcca3e6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/utils/shippable/check_matrix.py @@ -0,0 +1,120 @@ +#!/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 = ''' + + +\t +\t\t +\t\t\t%s +\t\t +\t + +''' % (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/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/utils/shippable/hcloud.sh b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/utils/shippable/hcloud.sh new file mode 100755 index 00000000..da037e09 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/utils/shippable/hcloud.sh @@ -0,0 +1,34 @@ +#!/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/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/utils/shippable/sanity.sh b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/utils/shippable/sanity.sh new file mode 100755 index 00000000..1c297c58 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/utils/shippable/sanity.sh @@ -0,0 +1,44 @@ +#!/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 + pip install antsibull-changelog + python ../../community/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/) ;; +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 +fi + +# shellcheck disable=SC2086 +ansible-test sanity --color -v --junit ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} \ + --docker --base-branch "${base_branch}" \ + --exclude shippable.yml --exclude tests/utils/ \ + "${options[@]}" --allow-disabled diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/utils/shippable/shippable.sh b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/utils/shippable/shippable.sh new file mode 100755 index 00000000..9303277f --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/utils/shippable/shippable.sh @@ -0,0 +1,125 @@ +#!/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 "$*"; +} + +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 '^drydock/' | 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 +{ + 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 +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}" + +# 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 + COMPLETE=yes +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 +{ + 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 +} + +trap cleanup EXIT + +ansible-test env --dump --show --timeout "50" --color -v + +"tests/utils/shippable/check_matrix.py" +"tests/utils/shippable/${script}.sh" "${test}" diff --git a/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/utils/shippable/timing.py b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/utils/shippable/timing.py new file mode 100755 index 00000000..fb538271 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/utils/shippable/timing.py @@ -0,0 +1,16 @@ +#!/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/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/utils/shippable/timing.sh b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/utils/shippable/timing.sh new file mode 100755 index 00000000..77e25783 --- /dev/null +++ b/collections-debian-merged/ansible_collections/hetzner/hcloud/tests/utils/shippable/timing.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +set -o pipefail -eu + +"$@" 2>&1 | "$(dirname "$0")/timing.py" -- cgit v1.2.3