summaryrefslogtreecommitdiffstats
path: root/ansible_collections/hetzner/hcloud/tests/integration
diff options
context:
space:
mode:
Diffstat (limited to 'ansible_collections/hetzner/hcloud/tests/integration')
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/constraints.txt1
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/requirements.txt2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/defaults/main.yml6
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/meta/main.yml5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/tasks/main.yml155
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/defaults/main.yml5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/meta/main.yml4
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/tasks/main.yml66
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/defaults/main.yml6
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/tasks/main.yml39
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_firewall/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_firewall/defaults/main.yml5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_firewall/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_firewall/tasks/main.yml210
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/defaults/main.yml6
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/tasks/main.yml470
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/defaults/main.yml5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/tasks/main.yml87
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/defaults/main.yml7
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/tasks/main.yml93
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/defaults/main.yml5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/tasks/main.yml247
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/defaults/main.yml6
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/tasks/main.yml128
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/defaults/main.yml6
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/tasks/main.yml181
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/defaults/main.yml5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/tasks/main.yml126
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/defaults/main.yml7
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/tasks/main.yml154
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_type_info/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_type_info/defaults/main.yml5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_type_info/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_type_info/tasks/main.yml38
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/defaults/main.yml5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/tasks/main.yml57
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/aliases3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/defaults/main.yml5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/tasks/main.yml215
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/defaults/main.yml5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/tasks/main.yml117
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_placement_group/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_placement_group/defaults/main.yml6
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_placement_group/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_placement_group/tasks/main.yml169
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_primary_ip/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_primary_ip/defaults/main.yml6
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_primary_ip/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_primary_ip/tasks/main.yml243
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/defaults/main.yml8
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/tasks/main.yml224
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/defaults/main.yml5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/tasks/main.yml99
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/defaults/main.yml8
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/basic.yml615
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/firewalls.yml105
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/main.yml8
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/primary_ips.yml82
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/private_network_only.yml135
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/validation.yml51
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/defaults/main.yml5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/tasks/main.yml128
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/aliases3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/defaults/main.yml6
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/tasks/main.yml222
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/defaults/main.yml5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/tasks/main.yml38
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/defaults/main.yml11
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/meta/main.yml5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/tasks/main.yml156
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/defaults/main.yml5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/meta/main.yml5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/tasks/main.yml68
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/defaults/main.yml6
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/tasks/main.yml125
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/defaults/main.yml6
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/tasks/main.yml289
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/aliases2
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/defaults/main.yml5
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/meta/main.yml3
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/tasks/main.yml101
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/setup_selfsigned_certificate/tasks/main.yml27
-rw-r--r--ansible_collections/hetzner/hcloud/tests/integration/targets/setup_sshkey/tasks/main.yml55
125 files changed, 5651 insertions, 0 deletions
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/constraints.txt b/ansible_collections/hetzner/hcloud/tests/integration/constraints.txt
new file mode 100644
index 000000000..19d5ecf28
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/constraints.txt
@@ -0,0 +1 @@
+hcloud >= 1.10.0 # minimum version
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/requirements.txt b/ansible_collections/hetzner/hcloud/tests/integration/requirements.txt
new file mode 100644
index 000000000..d3249deff
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/requirements.txt
@@ -0,0 +1,2 @@
+netaddr
+hcloud
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/aliases
new file mode 100644
index 000000000..55ec821a4
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+shippable/hcloud/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/defaults/main.yml
new file mode 100644
index 000000000..58312aec1
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/defaults/main.yml
@@ -0,0 +1,6 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_prefix: "tests"
+hcloud_certificate_name: "{{hcloud_prefix}}-integration"
+hcloud_dns_test_domain: "{{hcloud_prefix | truncate(19, False, 'ans')}}-{{100 | random }}.hc-certs.de"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/meta/main.yml
new file mode 100644
index 000000000..e531064ca
--- /dev/null
+++ b/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/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/tasks/main.yml
new file mode 100644
index 000000000..615c89d0e
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate/tasks/main.yml
@@ -0,0 +1,155 @@
+# Copyright: (c) 2020, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: test missing required parameters 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
+
+- name: generate dns domain name
+ set_fact:
+ # hcloud_dns_test_domain uses random, which generates a new random number
+ # on every invocation, by saving it into a fact we generate the number once
+ hcloud_dns_test_domain: "{{ hcloud_dns_test_domain }}"
+
+- name: test create managed certificate
+ hcloud_certificate:
+ name: "{{ hcloud_certificate_name }}"
+ domain_names:
+ - "{{ hcloud_dns_test_domain }}"
+ type: managed
+ labels:
+ HC-Use-Staging-CA: "true"
+ register: result
+- name: verify create managed certificate
+ assert:
+ that:
+ - result is changed
+ - result.hcloud_certificate.name == "{{ hcloud_certificate_name }}"
+ - result.hcloud_certificate.domain_names[0] == "{{ hcloud_dns_test_domain }}"
+
+- name: absent certificate
+ hcloud_certificate:
+ id: "{{ result.hcloud_certificate.id }}"
+ state: absent
+ register: result
+- name: verify absent certificate
+ assert:
+ that:
+ - result is success
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/aliases
new file mode 100644
index 000000000..55ec821a4
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+shippable/hcloud/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/defaults/main.yml
new file mode 100644
index 000000000..6205b19b4
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/defaults/main.yml
@@ -0,0 +1,5 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_prefix: "tests"
+hcloud_certificate_name: "always-there-cert"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/meta/main.yml
new file mode 100644
index 000000000..34657c1c2
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/meta/main.yml
@@ -0,0 +1,4 @@
+dependencies:
+ - setup_selfsigned_certificate
+collections:
+ - hetzner.cloud
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/tasks/main.yml
new file mode 100644
index 000000000..d7128db34
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_certificate_info/tasks/main.yml
@@ -0,0 +1,66 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+
+- name: create certificate
+ hcloud_certificate:
+ name: "{{ hcloud_certificate_name }}"
+ certificate: "{{ certificate_example_com }}"
+ private_key: "{{ certificate_example_com_key }}"
+ labels:
+ key: value
+ my-label: label
+ register: certificate
+- name: verify create certificate
+ assert:
+ that:
+ - certificate is changed
+ - certificate.hcloud_certificate.name == "{{ hcloud_certificate_name }}"
+ - certificate.hcloud_certificate.domain_names[0] == "www.example.com"
+ - certificate.hcloud_certificate.labels.key == "value"
+
+- name: test gather hcloud certificate infos in check mode
+ hcloud_certificate_info:
+ register: hcloud_certificate
+ check_mode: yes
+- name: verify test gather hcloud certificate infos in check mode
+ assert:
+ that:
+ - hcloud_certificate.hcloud_certificate_info| list | count >= 1
+
+- name: test gather hcloud certificate infos
+ hcloud_certificate_info:
+ register: hcloud_certificate
+ check_mode: yes
+- name: verify test gather hcloud certificate infos
+ assert:
+ that:
+ - hcloud_certificate.hcloud_certificate_info| list | count >= 1
+
+- name: test gather hcloud certificate infos with correct label selector
+ hcloud_certificate_info:
+ label_selector: "key=value"
+ register: hcloud_certificate
+- name: verify test gather hcloud certificate infos with correct label selector
+ assert:
+ that:
+ - hcloud_certificate.hcloud_certificate_info|selectattr('name','equalto','{{ hcloud_certificate_name }}') | list | count == 1
+
+- name: test gather hcloud certificate infos with wrong label selector
+ hcloud_certificate_info:
+ label_selector: "key!=value"
+ register: hcloud_certificate
+- name: verify test gather hcloud certificate infos with wrong label selector
+ assert:
+ that:
+ - hcloud_certificate.hcloud_certificate_info | list | count == 0
+
+- name: absent certificate
+ hcloud_certificate:
+ id: "{{ certificate.hcloud_certificate.id }}"
+ state: absent
+ register: result
+- name: verify absent certificate
+ assert:
+ that:
+ - result is success
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/aliases
new file mode 100644
index 000000000..55ec821a4
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+shippable/hcloud/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/defaults/main.yml
new file mode 100644
index 000000000..b9e045f40
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/defaults/main.yml
@@ -0,0 +1,6 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_datacenter_name: "fsn1-dc14"
+hcloud_datacenter_id: 4
+hcloud_location_name: "fsn1"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/meta/main.yml
new file mode 100644
index 000000000..407c9018a
--- /dev/null
+++ b/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/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/tasks/main.yml
new file mode 100644
index 000000000..3d144ae47
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_datacenter_info/tasks/main.yml
@@ -0,0 +1,39 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: test gather hcloud datacenter infos
+ hcloud_datacenter_info:
+ register: hcloud_datacenters
+
+- name: verify test gather hcloud datacenter infos
+ assert:
+ that:
+ - hcloud_datacenters.hcloud_datacenter_info| list | count >= 5
+
+- name: test gather hcloud datacenter infos in check mode
+ hcloud_datacenter_info:
+ register: hcloud_datacenters
+ check_mode: yes
+
+- name: verify test gather hcloud datacenter infos in check mode
+ assert:
+ that:
+ - hcloud_datacenters.hcloud_datacenter_info| list | count >= 5
+
+- name: test gather hcloud datacenter infos with correct name
+ hcloud_datacenter_info:
+ name: "{{hcloud_datacenter_name}}"
+ register: hcloud_datacenter
+- name: verify test gather hcloud datacenter with correct name
+ assert:
+ that:
+ - hcloud_datacenter.hcloud_datacenter_info|selectattr('name','equalto','{{ hcloud_datacenter_name }}') |selectattr('location','equalto','{{ hcloud_location_name }}') | list | count == 1
+
+- name: test gather hcloud datacenter infos with correct id
+ hcloud_datacenter_info:
+ id: "{{hcloud_datacenter_id}}"
+ register: hcloud_datacenter
+- name: verify test gather hcloud datacenter with correct id
+ assert:
+ that:
+ - hcloud_datacenter.hcloud_datacenter_info|selectattr('name','equalto','{{ hcloud_datacenter_name }}') | list | count == 1
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_firewall/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_firewall/aliases
new file mode 100644
index 000000000..55ec821a4
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_firewall/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+shippable/hcloud/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_firewall/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_firewall/defaults/main.yml
new file mode 100644
index 000000000..e7eff02a7
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_firewall/defaults/main.yml
@@ -0,0 +1,5 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_prefix: "tests"
+hcloud_firewall_name: "{{hcloud_prefix}}-integration"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_firewall/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_firewall/meta/main.yml
new file mode 100644
index 000000000..407c9018a
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_firewall/meta/main.yml
@@ -0,0 +1,3 @@
+collections:
+ - community.general.ipfilter
+ - hetzner.cloud
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_firewall/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_firewall/tasks/main.yml
new file mode 100644
index 000000000..f54d351b2
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_firewall/tasks/main.yml
@@ -0,0 +1,210 @@
+# Copyright: (c) 2020, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: setup firewall to be absent
+ hcloud_firewall:
+ name: "{{ hcloud_firewall_name }}"
+ state: absent
+
+- name: test missing required parameters on create firewall
+ hcloud_firewall:
+ register: result
+ ignore_errors: yes
+- name: verify fail test missing required parameters on create firewall
+ assert:
+ that:
+ - result is failed
+ - 'result.msg == "one of the following is required: id, name"'
+
+- name: test create firewall with check mode
+ hcloud_firewall:
+ name: "{{ hcloud_firewall_name }}"
+ register: result
+ check_mode: yes
+- name: test create firewall with check mode
+ assert:
+ that:
+ - result is changed
+
+- name: test create firewall
+ hcloud_firewall:
+ name: "{{ hcloud_firewall_name }}"
+ rules:
+ - direction: in
+ protocol: icmp
+ source_ips:
+ - 0.0.0.0/0
+ - ::/0
+ description: "allow icmp in"
+ labels:
+ key: value
+ my-label: label
+ register: firewall
+- name: verify create firewall
+ assert:
+ that:
+ - firewall is changed
+ - firewall.hcloud_firewall.name == "{{ hcloud_firewall_name }}"
+ - firewall.hcloud_firewall.rules | list | count == 1
+ - firewall.hcloud_firewall.rules | selectattr('direction','equalto','in') | list | count == 1
+ - firewall.hcloud_firewall.rules | selectattr('protocol','equalto','icmp') | list | count == 1
+ - firewall.hcloud_firewall.rules | selectattr('description', 'equalto', 'allow icmp in') | list | count == 1
+
+- name: test create firewall idempotence
+ hcloud_firewall:
+ name: "{{ hcloud_firewall_name }}"
+ rules:
+ - direction: in
+ protocol: icmp
+ source_ips:
+ - 0.0.0.0/0
+ - ::/0
+ description: "allow icmp in"
+ labels:
+ key: value
+ my-label: label
+ register: result
+- name: verify create firewall idempotence
+ assert:
+ that:
+ - result is not changed
+
+- name: test update firewall rules
+ hcloud_firewall:
+ name: "{{ hcloud_firewall_name }}"
+ rules:
+ - direction: in
+ protocol: icmp
+ source_ips:
+ - 0.0.0.0/0
+ - ::/0
+ - direction: in
+ protocol: tcp
+ port: 80
+ source_ips:
+ - 0.0.0.0/0
+ - ::/0
+ - direction: out
+ protocol: tcp
+ port: 80
+ destination_ips:
+ - 0.0.0.0/0
+ - ::/0
+ description: allow tcp out
+ labels:
+ key: value
+ my-label: label
+ register: firewall
+- name: verify update firewall rules
+ assert:
+ that:
+ - firewall is changed
+ - firewall.hcloud_firewall.name == "{{ hcloud_firewall_name }}"
+ - firewall.hcloud_firewall.rules | list | count == 3
+ - firewall.hcloud_firewall.rules | selectattr('direction','equalto','in') | list | count == 2
+ - firewall.hcloud_firewall.rules | selectattr('direction','equalto','out') | list | count == 1
+ - firewall.hcloud_firewall.rules | selectattr('protocol','equalto','icmp') | list | count == 1
+ - firewall.hcloud_firewall.rules | selectattr('protocol','equalto','tcp') | list | count == 2
+ - firewall.hcloud_firewall.rules | selectattr('port','equalto','80') | list | count == 2
+ - firewall.hcloud_firewall.rules | selectattr('description', 'equalto', 'allow tcp out') | list | count == 1
+
+- name: test update firewall rules idempotence
+ hcloud_firewall:
+ name: "{{ hcloud_firewall_name }}"
+ rules:
+ - direction: in
+ protocol: icmp
+ source_ips:
+ - 0.0.0.0/0
+ - ::/0
+ - direction: in
+ protocol: tcp
+ port: 80
+ source_ips:
+ - 0.0.0.0/0
+ - ::/0
+ - direction: out
+ protocol: tcp
+ port: 80
+ destination_ips:
+ - 0.0.0.0/0
+ - ::/0
+ description: allow tcp out
+ labels:
+ key: value
+ my-label: label
+ register: result
+- name: verify update firewall rules idempotence
+ assert:
+ that:
+ - result is not changed
+
+- name: test update firewall with check mode
+ hcloud_firewall:
+ id: "{{ firewall.hcloud_firewall.id }}"
+ name: "changed-{{ hcloud_firewall_name }}"
+ register: result
+ check_mode: yes
+- name: test create firewall with check mode
+ assert:
+ that:
+ - result is changed
+
+- name: test update firewall
+ hcloud_firewall:
+ id: "{{ firewall.hcloud_firewall.id }}"
+ name: "changed-{{ hcloud_firewall_name }}"
+ labels:
+ key: value
+ register: result
+- name: test update firewall
+ assert:
+ that:
+ - result is changed
+ - result.hcloud_firewall.name == "changed-{{ hcloud_firewall_name }}"
+
+- name: test update firewall with same labels
+ hcloud_firewall:
+ id: "{{ firewall.hcloud_firewall.id }}"
+ name: "changed-{{ hcloud_firewall_name }}"
+ labels:
+ key: value
+ register: result
+- name: test update firewall with same labels
+ assert:
+ that:
+ - result is not changed
+
+- name: test update firewall with other labels
+ hcloud_firewall:
+ id: "{{ firewall.hcloud_firewall.id }}"
+ name: "changed-{{ hcloud_firewall_name }}"
+ labels:
+ key: value
+ test: "val123"
+ register: result
+- name: test update firewall with other labels
+ assert:
+ that:
+ - result is changed
+
+- name: test rename firewall
+ hcloud_firewall:
+ id: "{{ firewall.hcloud_firewall.id }}"
+ name: "{{ hcloud_firewall_name }}"
+ register: result
+- name: test rename firewall
+ assert:
+ that:
+ - result is changed
+ - result.hcloud_firewall.name == "{{ hcloud_firewall_name }}"
+
+- name: absent firewall
+ hcloud_firewall:
+ id: "{{ firewall.hcloud_firewall.id }}"
+ state: absent
+ register: result
+- name: verify absent server
+ assert:
+ that:
+ - result is success
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/aliases
new file mode 100644
index 000000000..55ec821a4
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+shippable/hcloud/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/defaults/main.yml
new file mode 100644
index 000000000..ebd5ccc38
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/defaults/main.yml
@@ -0,0 +1,6 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_prefix: "tests"
+hcloud_floating_ip_name: "{{hcloud_prefix}}-i"
+hcloud_server_name: "{{ hcloud_prefix | truncate(45, True, '', 0) }}-fip-t"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/meta/main.yml
new file mode 100644
index 000000000..407c9018a
--- /dev/null
+++ b/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/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/tasks/main.yml
new file mode 100644
index 000000000..8ada4172f
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip/tasks/main.yml
@@ -0,0 +1,470 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: setup 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 invalid type
+ hcloud_floating_ip:
+ name: "{{ hcloud_floating_ip_name }}"
+ type: ipv5
+ home_location: "fsn1"
+ register: result
+ ignore_errors: yes
+- name: verify invalid type
+ assert:
+ that:
+ - result is failed
+ - 'result.msg == "value of type must be one of: ipv4, ipv6, got: ipv5"'
+
+- name: test invalid location
+ hcloud_floating_ip:
+ name: "{{ hcloud_floating_ip_name }}"
+ type: ipv4
+ home_location: "abc"
+ register: result
+ ignore_errors: yes
+- name: verify invalid location
+ assert:
+ that:
+ - result is failed
+ - result.msg == "invalid input in fields 'server', 'home_location'"
+
+- 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/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/aliases
new file mode 100644
index 000000000..55ec821a4
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+shippable/hcloud/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/defaults/main.yml
new file mode 100644
index 000000000..f4c6a9fc9
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/defaults/main.yml
@@ -0,0 +1,5 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_prefix: "tests"
+hcloud_floating_ip_name: "{{hcloud_prefix}}-i"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/meta/main.yml
new file mode 100644
index 000000000..407c9018a
--- /dev/null
+++ b/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/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/tasks/main.yml
new file mode 100644
index 000000000..9ca1c2a4a
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_floating_ip_info/tasks/main.yml
@@ -0,0 +1,87 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: setup ensure floating ip is absent
+ hcloud_floating_ip:
+ name: "{{ hcloud_floating_ip_name }}"
+ state: absent
+
+- name: setup floating ip
+ hcloud_floating_ip:
+ name: "{{ hcloud_floating_ip_name }}"
+ home_location: "fsn1"
+ type: ipv4
+ labels:
+ key: value
+ register: test_floating_ip
+
+- name: verify setup floating ip
+ assert:
+ that:
+ - test_floating_ip is changed
+
+- name: test gather hcloud floating ip infos
+ hcloud_floating_ip_info:
+ register: hcloud_floating_ips
+- name: verify test gather hcloud floating ip infos
+ assert:
+ that:
+ - hcloud_floating_ips.hcloud_floating_ip_info| list | count >= 1
+
+- name: test gather hcloud floating ip infos in check mode
+ hcloud_floating_ip_info:
+ check_mode: yes
+ register: hcloud_floating_ips
+
+- name: verify test gather hcloud floating ip infos in check mode
+ assert:
+ that:
+ - hcloud_floating_ips.hcloud_floating_ip_info| list | count >= 1
+
+
+- name: test gather hcloud floating ip infos with correct label selector
+ hcloud_floating_ip_info:
+ label_selector: "key=value"
+ register: hcloud_floating_ips
+- name: verify test gather hcloud floating ip with correct label selector
+ assert:
+ that:
+ - hcloud_floating_ips.hcloud_floating_ip_info|selectattr('name','equalto','{{ test_floating_ip.hcloud_floating_ip.name }}') | list | count == 1
+
+- name: test gather hcloud floating ip infos with wrong label selector
+ hcloud_floating_ip_info:
+ label_selector: "key!=value"
+ register: hcloud_floating_ips
+- name: verify test gather hcloud floating ip with wrong label selector
+ assert:
+ that:
+ - hcloud_floating_ips.hcloud_floating_ip_info | list | count == 0
+
+- name: test gather hcloud floating ip infos with correct id
+ hcloud_floating_ip_info:
+ id: "{{test_floating_ip.hcloud_floating_ip.id}}"
+ register: hcloud_floating_ips
+- name: verify test gather hcloud floating ip with correct id
+ assert:
+ that:
+ - hcloud_floating_ips.hcloud_floating_ip_info|selectattr('name','equalto','{{ test_floating_ip.hcloud_floating_ip.name }}') | list | count == 1
+
+- name: test gather hcloud floating ip infos with wrong id
+ hcloud_floating_ip_info:
+ id: "{{test_floating_ip.hcloud_floating_ip.id}}1"
+ register: result
+ ignore_errors: yes
+- name: verify test gather hcloud floating ip with wrong id
+ assert:
+ that:
+ - result is failed
+
+- name: cleanup
+ hcloud_floating_ip:
+ id: "{{ test_floating_ip.hcloud_floating_ip.id }}"
+ state: absent
+ register: result
+- name: verify cleanup
+ assert:
+ that:
+ - result is success
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/aliases
new file mode 100644
index 000000000..55ec821a4
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+shippable/hcloud/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/defaults/main.yml
new file mode 100644
index 000000000..7c25d171d
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/defaults/main.yml
@@ -0,0 +1,7 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_prefix: "tests"
+hcloud_test_image_name: "always-there-snapshot"
+hcloud_test_image_id: 10164049
+hcloud_test_image_name_os: "ubuntu-22.04"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/meta/main.yml
new file mode 100644
index 000000000..407c9018a
--- /dev/null
+++ b/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/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/tasks/main.yml
new file mode 100644
index 000000000..16ed44a28
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_image_info/tasks/main.yml
@@ -0,0 +1,93 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: test gather hcloud image infos with type system
+ hcloud_image_info:
+ register: hcloud_images
+- name: verify test gather hcloud image infos in check mode
+ assert:
+ that:
+ - hcloud_images.hcloud_image_info| list | count > 2
+
+- name: test gather hcloud image infos in check mode
+ hcloud_image_info:
+ check_mode: yes
+ register: hcloud_images
+
+- name: verify test gather hcloud image infos in check mode
+ assert:
+ that:
+ - hcloud_images.hcloud_image_info| list | count > 2
+
+
+- name: test gather hcloud image infos with correct label selector
+ hcloud_image_info:
+ label_selector: "key=value"
+ type: snapshot
+ register: hcloud_images
+- name: verify test gather hcloud image with correct label selector
+ assert:
+ that:
+ - hcloud_images.hcloud_image_info|selectattr('description','equalto','{{ hcloud_test_image_name }}') | list | count == 1
+
+- name: test gather hcloud image infos with wrong label selector
+ hcloud_image_info:
+ label_selector: "key!=value"
+ type: snapshot
+ register: hcloud_images
+- name: verify test gather hcloud image with wrong label selector
+ assert:
+ that:
+ - hcloud_images.hcloud_image_info | list | count == 0
+
+- name: test gather hcloud image infos with correct id
+ hcloud_image_info:
+ id: "{{hcloud_test_image_id}}"
+ type: snapshot
+ register: hcloud_images
+- name: verify test gather hcloud image with correct id
+ assert:
+ that:
+ - hcloud_images.hcloud_image_info|selectattr('description','equalto','{{ hcloud_test_image_name }}') | list | count == 1
+
+- name: test gather hcloud image infos with wrong id
+ hcloud_image_info:
+ id: "{{hcloud_test_image_id}}1"
+ type: snapshot
+ ignore_errors: yes
+ register: result
+- name: verify test gather hcloud image with wrong id
+ assert:
+ that:
+ - result is failed
+
+- name: test gather hcloud image infos with name
+ hcloud_image_info:
+ name: "{{ hcloud_test_image_name_os }}"
+ register: hcloud_images
+- name: verify test gather hcloud image infos with name
+ assert:
+ that:
+ - hcloud_images.hcloud_image_info | list | count == 1
+ - hcloud_images.hcloud_image_info[0].architecture == "x86"
+
+- name: test gather hcloud image infos with name and architecture
+ hcloud_image_info:
+ name: "{{ hcloud_test_image_name_os }}"
+ architecture: arm
+ register: hcloud_images
+- name: verify test gather hcloud image infos with name
+ assert:
+ that:
+ - hcloud_images.hcloud_image_info | list | count == 1
+ - hcloud_images.hcloud_image_info[0].architecture == "arm"
+
+- name: test gather hcloud image infos with architecture
+ hcloud_image_info:
+ architecture: arm
+ register: hcloud_images
+- name: verify test gather hcloud image infos with name
+ assert:
+ that:
+ - hcloud_images.hcloud_image_info | selectattr('architecture','equalto','x86') | list | count == 0
+ - hcloud_images.hcloud_image_info | selectattr('architecture','equalto','arm') | list | count > 2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/aliases
new file mode 100644
index 000000000..18dc30b6c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+shippable/hcloud/group1
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/defaults/main.yml
new file mode 100644
index 000000000..7f431cd8d
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/defaults/main.yml
@@ -0,0 +1,5 @@
+# Copyright: (c) 2020, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_prefix: "tests"
+hcloud_load_balancer_name: "{{hcloud_prefix}}-i"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/meta/main.yml
new file mode 100644
index 000000000..407c9018a
--- /dev/null
+++ b/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/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/tasks/main.yml
new file mode 100644
index 000000000..a25e550d0
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer/tasks/main.yml
@@ -0,0 +1,247 @@
+# Copyright: (c) 2020, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: setup
+ hcloud_load_balancer:
+ name: "{{ hcloud_load_balancer_name }}"
+ state: absent
+ register: result
+- name: verify setup
+ assert:
+ that:
+ - result is success
+- name: test missing required parameters on create Load Balancer
+ hcloud_load_balancer:
+ name: "{{ hcloud_load_balancer_name }}"
+ register: result
+ ignore_errors: yes
+- name: verify fail test missing required parameters on create Load Balancer
+ assert:
+ that:
+ - result is failed
+ - 'result.msg == "missing required arguments: load_balancer_type"'
+
+- name: test create Load Balancer with check mode
+ hcloud_load_balancer:
+ name: "{{ hcloud_load_balancer_name }}"
+ load_balancer_type: lb11
+ network_zone: eu-central
+ state: present
+ register: result
+ check_mode: yes
+- name: test create Load Balancer with check mode
+ assert:
+ that:
+ - result is changed
+
+- name: test create Load Balancer
+ hcloud_load_balancer:
+ name: "{{ hcloud_load_balancer_name}}"
+ load_balancer_type: lb11
+ network_zone: eu-central
+ state: present
+ register: main_load_balancer
+- name: verify create Load Balancer
+ assert:
+ that:
+ - main_load_balancer is changed
+ - main_load_balancer.hcloud_load_balancer.name == "{{ hcloud_load_balancer_name }}"
+ - main_load_balancer.hcloud_load_balancer.load_balancer_type == "lb11"
+
+- name: test create Load Balancer idempotence
+ hcloud_load_balancer:
+ name: "{{ hcloud_load_balancer_name }}"
+ load_balancer_type: lb11
+ network_zone: eu-central
+ state: present
+ register: result
+- name: verify create Load Balancer idempotence
+ assert:
+ that:
+ - result is not changed
+
+- name: test change Load Balancer type
+ hcloud_load_balancer:
+ name: "{{ hcloud_load_balancer_name }}"
+ load_balancer_type: lb21
+ state: present
+ register: result_after_test
+ ignore_errors: true
+- name: verify change Load Balancer type
+ assert:
+ that:
+ - result_after_test is changed
+ - result_after_test.hcloud_load_balancer.load_balancer_type == "lb21"
+
+- name: test Load Balancer without type set to be idempotent
+ hcloud_load_balancer:
+ name: "{{hcloud_load_balancer_name}}"
+ register: result_after_test
+- name: verify test Load Balancer without type set to be idempotent
+ assert:
+ that:
+ - result_after_test is not changed
+ - result_after_test.hcloud_load_balancer.load_balancer_type == "lb21"
+
+- name: test update Load Balancer protection
+ hcloud_load_balancer:
+ name: "{{ hcloud_load_balancer_name }}"
+ delete_protection: true
+ state: present
+ register: result_after_test
+ ignore_errors: true
+- name: verify update Load Balancer protection
+ assert:
+ that:
+ - result_after_test is changed
+ - result_after_test.hcloud_load_balancer.delete_protection is sameas true
+
+- name: test Load Balancer without protection set to be idempotent
+ hcloud_load_balancer:
+ name: "{{hcloud_load_balancer_name}}"
+ register: result_after_test
+- name: verify test Load Balancer without protection set to be idempotent
+ assert:
+ that:
+ - result_after_test is not changed
+ - result_after_test.hcloud_load_balancer.delete_protection is sameas true
+
+- name: test delete Load Balancer fails if it is protected
+ hcloud_load_balancer:
+ name: "{{hcloud_load_balancer_name}}"
+ state: absent
+ ignore_errors: yes
+ register: result
+- name: verify delete Load Balancer fails if it is protected
+ assert:
+ that:
+ - result is failed
+ - 'result.msg == "load balancer deletion is protected"'
+
+- name: test remove Load Balancer protection
+ hcloud_load_balancer:
+ name: "{{ hcloud_load_balancer_name }}"
+ delete_protection: false
+ state: present
+ register: result_after_test
+ ignore_errors: true
+- name: verify remove Load Balancer protection
+ assert:
+ that:
+ - result_after_test is changed
+ - result_after_test.hcloud_load_balancer.delete_protection is sameas false
+
+- name: absent Load Balancer
+ hcloud_load_balancer:
+ name: "{{ hcloud_load_balancer_name }}"
+ state: absent
+ register: result
+- name: verify absent Load Balancer
+ assert:
+ that:
+ - result is success
+
+- name: test create Load Balancer with labels
+ hcloud_load_balancer:
+ name: "{{ hcloud_load_balancer_name}}"
+ load_balancer_type: lb11
+ network_zone: eu-central
+ labels:
+ key: value
+ mylabel: "val123"
+ state: present
+ register: main_load_balancer
+- name: verify create Load Balancer with labels
+ assert:
+ that:
+ - main_load_balancer is changed
+ - main_load_balancer.hcloud_load_balancer.labels.key == "value"
+ - main_load_balancer.hcloud_load_balancer.labels.mylabel == "val123"
+
+- name: test update Load Balancer with labels
+ hcloud_load_balancer:
+ name: "{{ hcloud_load_balancer_name}}"
+ load_balancer_type: lb11
+ network_zone: eu-central
+ labels:
+ key: other
+ mylabel: "val123"
+ state: present
+ register: main_load_balancer
+- name: verify update Load Balancer with labels
+ assert:
+ that:
+ - main_load_balancer is changed
+ - main_load_balancer.hcloud_load_balancer.labels.key == "other"
+ - main_load_balancer.hcloud_load_balancer.labels.mylabel == "val123"
+
+- name: test update Load Balancer with labels in other order
+ hcloud_load_balancer:
+ name: "{{ hcloud_load_balancer_name}}"
+ load_balancer_type: lb11
+ network_zone: eu-central
+ labels:
+ mylabel: "val123"
+ key: other
+ state: present
+ register: main_load_balancer
+- name: verify update Load Balancer with labels in other order
+ assert:
+ that:
+ - main_load_balancer is not changed
+
+- name: cleanup with labels
+ hcloud_load_balancer:
+ name: "{{ hcloud_load_balancer_name }}"
+ state: absent
+ register: result
+- name: verify cleanup
+ assert:
+ that:
+ - result is success
+
+- name: test create Load Balancer with delete protection
+ hcloud_load_balancer:
+ name: "{{ hcloud_load_balancer_name }}"
+ load_balancer_type: lb11
+ network_zone: eu-central
+ delete_protection: true
+ register: main_load_balancer
+- name: verify create Load Balancer with delete protection
+ assert:
+ that:
+ - main_load_balancer is changed
+ - main_load_balancer.hcloud_load_balancer.delete_protection is sameas true
+
+- name: test delete Load Balancer fails if it is protected
+ hcloud_load_balancer:
+ name: "{{ hcloud_load_balancer_name }}"
+ state: "absent"
+ register: result
+ ignore_errors: yes
+- name: verify test delete Load Balancer
+ assert:
+ that:
+ - result is failed
+ - 'result.msg == "load balancer deletion is protected"'
+
+- name: test update Load Balancer delete protection
+ hcloud_load_balancer:
+ name: "{{ hcloud_load_balancer_name }}"
+ delete_protection: false
+ register: main_load_balancer
+- name: verify update Load Balancer delete protection
+ assert:
+ that:
+ - main_load_balancer is changed
+ - main_load_balancer.hcloud_load_balancer.delete_protection is sameas false
+
+- name: test delete Load Balancer
+ hcloud_load_balancer:
+ name: "{{ hcloud_load_balancer_name }}"
+ state: "absent"
+ register: result
+- name: verify test delete Load Balancer
+ assert:
+ that:
+ - result is changed
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/aliases
new file mode 100644
index 000000000..18dc30b6c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+shippable/hcloud/group1
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/defaults/main.yml
new file mode 100644
index 000000000..326973a78
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/defaults/main.yml
@@ -0,0 +1,6 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_prefix: "tests"
+hcloud_load_balancer_name: "{{hcloud_prefix}}-i"
+hcloud_server_name: "{{ hcloud_prefix | truncate(45, True, '', 0) }}-lb-i"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/meta/main.yml
new file mode 100644
index 000000000..407c9018a
--- /dev/null
+++ b/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/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/tasks/main.yml
new file mode 100644
index 000000000..9e6528858
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_info/tasks/main.yml
@@ -0,0 +1,128 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: setup ensure Load Balancer is absent
+ hcloud_load_balancer:
+ name: "{{ hcloud_load_balancer_name }}"
+ state: absent
+- name: setup server
+ hcloud_server:
+ name: "{{hcloud_server_name}}"
+ server_type: cx11
+ image: ubuntu-20.04
+ state: started
+ register: server
+- name: verify setup server
+ assert:
+ that:
+ - server is success
+- name: setup Load Balancer
+ hcloud_load_balancer:
+ name: "{{ hcloud_load_balancer_name }}"
+ load_balancer_type: lb11
+ network_zone: eu-central
+ labels:
+ key: value
+ register: test_load_balancer
+
+- name: verify setup Load Balancer
+ assert:
+ that:
+ - test_load_balancer is changed
+
+- name: test create load_balancer target
+ hcloud_load_balancer_target:
+ type: "server"
+ load_balancer: "{{hcloud_load_balancer_name}}"
+ server: "{{hcloud_server_name}}"
+ state: present
+ register: load_balancer_target
+- name: verify create load_balancer target
+ assert:
+ that:
+ - load_balancer_target is success
+- name: test create load_balancer service
+ hcloud_load_balancer_service:
+ load_balancer: "{{hcloud_load_balancer_name}}"
+ protocol: "http"
+ listen_port: 80
+ state: present
+ register: load_balancer_service
+- name: verify create load_balancer service
+ assert:
+ that:
+ - load_balancer_service is success
+
+- name: test gather hcloud Load Balancer infos
+ hcloud_load_balancer_info:
+ id: "{{test_load_balancer.hcloud_load_balancer.id}}"
+ register: hcloud_load_balancers
+- name: verify test gather hcloud Load Balancer infos
+ assert:
+ that:
+ - hcloud_load_balancers.hcloud_load_balancer_info| list | count >= 1
+ - hcloud_load_balancers.hcloud_load_balancer_info[0].targets | list | count == 1
+ - hcloud_load_balancers.hcloud_load_balancer_info[0].targets | selectattr('type','equalto','server') | list | count == 1
+ - hcloud_load_balancers.hcloud_load_balancer_info[0].targets | selectattr('server','equalto','{{ hcloud_server_name }}') | list | count == 1
+ - hcloud_load_balancers.hcloud_load_balancer_info[0].services | list | count == 1
+ - hcloud_load_balancers.hcloud_load_balancer_info[0].services | selectattr('protocol','equalto','http') | list | count == 1
+ - hcloud_load_balancers.hcloud_load_balancer_info[0].services | selectattr('listen_port','equalto',80) | list | count == 1
+ - hcloud_load_balancers.hcloud_load_balancer_info[0].services | selectattr('destination_port','equalto',80) | list | count == 1
+
+- name: test gather hcloud Load Balancer infos in check mode
+ hcloud_load_balancer_info:
+ check_mode: yes
+ register: hcloud_load_balancers
+
+- name: verify test gather hcloud Load Balancer infos in check mode
+ assert:
+ that:
+ - hcloud_load_balancers.hcloud_load_balancer_info| list | count >= 1
+
+
+- name: test gather hcloud Load Balancer infos with correct label selector
+ hcloud_load_balancer_info:
+ label_selector: "key=value"
+ register: hcloud_load_balancers
+- name: verify test gather hcloud Load Balancer with correct label selector
+ assert:
+ that:
+ - hcloud_load_balancers.hcloud_load_balancer_info|selectattr('name','equalto','{{ test_load_balancer.hcloud_load_balancer.name }}') | list | count == 1
+
+- name: test gather hcloud Load Balancer infos with wrong label selector
+ hcloud_load_balancer_info:
+ label_selector: "key!=value"
+ register: hcloud_load_balancers
+- name: verify test gather hcloud Load Balancer with wrong label selector
+ assert:
+ that:
+ - hcloud_load_balancers.hcloud_load_balancer_info | list | count == 0
+
+- name: test gather hcloud Load Balancer infos with correct id
+ hcloud_load_balancer_info:
+ id: "{{test_load_balancer.hcloud_load_balancer.id}}"
+ register: hcloud_load_balancers
+- name: verify test gather hcloud Load Balancer with correct id
+ assert:
+ that:
+ - hcloud_load_balancers.hcloud_load_balancer_info|selectattr('name','equalto','{{ test_load_balancer.hcloud_load_balancer.name }}') | list | count == 1
+
+- name: test gather hcloud Load Balancer infos with wrong id
+ hcloud_load_balancer_info:
+ id: "{{test_load_balancer.hcloud_load_balancer.id}}1"
+ register: result
+ ignore_errors: yes
+- name: verify test gather hcloud Load Balancer with wrong id
+ assert:
+ that:
+ - result is failed
+
+- name: cleanup
+ hcloud_load_balancer:
+ id: "{{ test_load_balancer.hcloud_load_balancer.id }}"
+ state: absent
+ register: result
+- name: verify cleanup
+ assert:
+ that:
+ - result is success
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/aliases
new file mode 100644
index 000000000..18dc30b6c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+shippable/hcloud/group1
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/defaults/main.yml
new file mode 100644
index 000000000..6abf9ceec
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/defaults/main.yml
@@ -0,0 +1,6 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_prefix: "tests"
+hcloud_network_name: "{{hcloud_prefix}}-lb-n"
+hcloud_load_balancer_name: "{{hcloud_prefix}}-lb-n"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/meta/main.yml
new file mode 100644
index 000000000..407c9018a
--- /dev/null
+++ b/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/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/tasks/main.yml
new file mode 100644
index 000000000..9a1bf5175
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_network/tasks/main.yml
@@ -0,0 +1,181 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: setup 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
+ - '"missing required arguments:" in result.msg'
+
+- name: test fail load balancer does not exist
+ hetzner.hcloud.hcloud_load_balancer_network:
+ network: "{{ hcloud_network_name }}"
+ load_balancer: does-not-exist
+ state: present
+ register: result
+ ignore_errors: true
+- name: verify test fail load_balancer does not exist
+ assert:
+ that:
+ - result is failed
+ - "result.msg == 'Load balancer does not exist: does-not-exist'"
+
+- name: test fail network does not exist
+ hetzner.hcloud.hcloud_load_balancer_network:
+ network: does-not-exist
+ load_balancer: "{{ hcloud_load_balancer_name }}"
+ state: present
+ register: result
+ ignore_errors: true
+- name: verify test fail network does not exist
+ assert:
+ that:
+ - result is failed
+ - "result.msg == 'Network does not exist: does-not-exist'"
+
+- 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/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/aliases
new file mode 100644
index 000000000..18dc30b6c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+shippable/hcloud/group1
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/defaults/main.yml
new file mode 100644
index 000000000..ebf456312
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/defaults/main.yml
@@ -0,0 +1,5 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_prefix: "tests"
+hcloud_load_balancer_name: "{{hcloud_prefix}}-lb-target"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/meta/main.yml
new file mode 100644
index 000000000..407c9018a
--- /dev/null
+++ b/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/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/tasks/main.yml
new file mode 100644
index 000000000..b0db6bb63
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_service/tasks/main.yml
@@ -0,0 +1,126 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: setup 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 fail load balancer does not exist
+ hetzner.hcloud.hcloud_load_balancer_service:
+ load_balancer: does-not-exist
+ protocol: http
+ listen_port: 80
+ state: present
+ register: result
+ ignore_errors: true
+- name: verify test fail load_balancer does not exist
+ assert:
+ that:
+ - result is failed
+ - "result.msg == 'Load balancer does not exist: does-not-exist'"
+
+- 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/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/aliases
new file mode 100644
index 000000000..18dc30b6c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+shippable/hcloud/group1
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/defaults/main.yml
new file mode 100644
index 000000000..180133fde
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/defaults/main.yml
@@ -0,0 +1,7 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_prefix: "tests"
+hcloud_server_name: "{{ hcloud_prefix | truncate(45, True, '', 0) }}-lb-t"
+hcloud_load_balancer_name: "{{hcloud_prefix}}-lb-target"
+hcloud_testing_ip: "176.9.59.39"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/meta/main.yml
new file mode 100644
index 000000000..407c9018a
--- /dev/null
+++ b/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/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/tasks/main.yml
new file mode 100644
index 000000000..bd96c1a54
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_target/tasks/main.yml
@@ -0,0 +1,154 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: setup 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 fail load balancer does not exist
+ hetzner.hcloud.hcloud_load_balancer_target:
+ type: server
+ load_balancer: does-not-exist
+ server: "{{ hcloud_server_name }}"
+ register: result
+ ignore_errors: true
+- name: verify test fail load_balancer does not exist
+ assert:
+ that:
+ - result is failed
+ - "result.msg == 'Load balancer does not exist: does-not-exist'"
+
+- name: test fail server does not exist
+ hetzner.hcloud.hcloud_load_balancer_target:
+ type: server
+ load_balancer: "{{ hcloud_load_balancer_name }}"
+ server: does-not-exist
+ register: result
+ ignore_errors: true
+- name: verify test fail server does not exist
+ assert:
+ that:
+ - result is failed
+ - "result.msg == 'Server not found: does-not-exist'"
+
+- 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
+ until: result is not failed
+ retries: 5
+ delay: 2
+
+- name: cleanup
+ hcloud_server:
+ name: "{{hcloud_server_name}}"
+ state: absent
+ register: result
+- name: verify cleanup
+ assert:
+ that:
+ - result is success
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_type_info/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_type_info/aliases
new file mode 100644
index 000000000..55ec821a4
--- /dev/null
+++ b/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/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_type_info/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_type_info/defaults/main.yml
new file mode 100644
index 000000000..b7fd86316
--- /dev/null
+++ b/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 <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_load_balancer_type_name: "lb11"
+hcloud_load_balancer_type_id: 1
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_type_info/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_type_info/meta/main.yml
new file mode 100644
index 000000000..407c9018a
--- /dev/null
+++ b/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/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_type_info/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_load_balancer_type_info/tasks/main.yml
new file mode 100644
index 000000000..bcd805a83
--- /dev/null
+++ b/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 <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: test gather hcloud Load Balancer type infos
+ hcloud_load_balancer_type_info:
+ register: hcloud_load_balancer_types
+- name: verify test gather hcloud Load Balancer type infos
+ assert:
+ that:
+ - hcloud_load_balancer_types.hcloud_load_balancer_type_info| list | count >= 1
+
+- name: test gather hcloud Load Balancer type infos in check mode
+ hcloud_load_balancer_type_info:
+ check_mode: yes
+ register: hcloud_load_balancer_types
+
+- name: verify test gather hcloud Load Balancer type infos in check mode
+ assert:
+ that:
+ - hcloud_load_balancer_types.hcloud_load_balancer_type_info| list | count >= 1
+
+- name: test gather hcloud Load Balancer type infos with name
+ hcloud_load_balancer_type_info:
+ name: "{{hcloud_load_balancer_type_name}}"
+ register: hcloud_load_balancer_types
+- name: verify test gather hcloud Load Balancer type with name
+ assert:
+ that:
+ - hcloud_load_balancer_types.hcloud_load_balancer_type_info|selectattr('name','equalto','{{ hcloud_load_balancer_type_name }}') | list | count == 1
+
+- name: test gather hcloud Load Balancer type infos with correct id
+ hcloud_load_balancer_type_info:
+ id: "{{hcloud_load_balancer_type_id}}"
+ register: hcloud_load_balancer_types
+- name: verify test gather hcloud Load Balancer type with correct id
+ assert:
+ that:
+ - hcloud_load_balancer_types.hcloud_load_balancer_type_info|selectattr('name','equalto','{{ hcloud_load_balancer_type_name }}') | list | count == 1
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/aliases
new file mode 100644
index 000000000..55ec821a4
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+shippable/hcloud/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/defaults/main.yml
new file mode 100644
index 000000000..0d72a75c2
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/defaults/main.yml
@@ -0,0 +1,5 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_location_name: "fsn1"
+hcloud_location_id: 1
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/meta/main.yml
new file mode 100644
index 000000000..407c9018a
--- /dev/null
+++ b/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/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/tasks/main.yml
new file mode 100644
index 000000000..99d5880ab
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_location_info/tasks/main.yml
@@ -0,0 +1,57 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: test gather hcloud location infos
+ hcloud_location_info:
+ register: hcloud_location
+
+- name: verify test gather hcloud location infos
+ assert:
+ that:
+ - hcloud_location.hcloud_location_info | list | count >= 5
+
+- name: test gather hcloud location infos in check mode
+ hcloud_location_info:
+ check_mode: yes
+ register: hcloud_location
+
+- name: verify test gather hcloud location infos in check mode
+ assert:
+ that:
+ - hcloud_location.hcloud_location_info | list | count >= 5
+
+- name: test gather hcloud location infos with correct name
+ hcloud_location_info:
+ name: "{{hcloud_location_name}}"
+ register: hcloud_location
+- name: verify test gather hcloud location with correct name
+ assert:
+ that:
+ - hcloud_location.hcloud_location_info|selectattr('name','equalto','{{ hcloud_location_name }}') | list | count == 1
+
+- name: test gather hcloud location infos with wrong name
+ hcloud_location_info:
+ name: "{{hcloud_location_name}}1"
+ register: hcloud_location
+- name: verify test gather hcloud location with wrong name
+ assert:
+ that:
+ - hcloud_location.hcloud_location_info | list | count == 0
+
+- name: test gather hcloud location infos with correct id
+ hcloud_location_info:
+ id: "{{hcloud_location_id}}"
+ register: hcloud_location
+- name: verify test gather hcloud location with correct id
+ assert:
+ that:
+ - hcloud_location.hcloud_location_info|selectattr('name','equalto','{{ hcloud_location_name }}') | list | count == 1
+
+- name: test gather hcloud location infos with wrong id
+ hcloud_location_info:
+ name: "4711"
+ register: hcloud_location
+- name: verify test gather hcloud location with wrong id
+ assert:
+ that:
+ - hcloud_location.hcloud_location_info | list | count == 0
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/aliases
new file mode 100644
index 000000000..4b3a9b36f
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/aliases
@@ -0,0 +1,3 @@
+cloud/hcloud
+shippable/hcloud/group1
+disabled
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/defaults/main.yml
new file mode 100644
index 000000000..081eb1472
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/defaults/main.yml
@@ -0,0 +1,5 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_prefix: "tests"
+hcloud_network_name: "{{hcloud_prefix}}-i"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/meta/main.yml
new file mode 100644
index 000000000..407c9018a
--- /dev/null
+++ b/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/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/tasks/main.yml
new file mode 100644
index 000000000..6c40e4e01
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network/tasks/main.yml
@@ -0,0 +1,215 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: setup
+ hcloud_network:
+ name: "{{ hcloud_network_name }}"
+ 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/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/aliases
new file mode 100644
index 000000000..18dc30b6c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+shippable/hcloud/group1
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/defaults/main.yml
new file mode 100644
index 000000000..f8a5279fb
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/defaults/main.yml
@@ -0,0 +1,5 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_prefix: "tests"
+hcloud_network_name: "{{hcloud_prefix}}-integration"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/meta/main.yml
new file mode 100644
index 000000000..407c9018a
--- /dev/null
+++ b/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/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/tasks/main.yml
new file mode 100644
index 000000000..e7924a8d0
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_network_info/tasks/main.yml
@@ -0,0 +1,117 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+
+- name: setup ensure network is absent
+ hcloud_network:
+ name: "{{ hcloud_network_name }}"
+ state: absent
+ register: result
+
+- name: create network
+ hcloud_network:
+ name: "{{ hcloud_network_name }}"
+ ip_range: "10.0.0.0/16"
+ labels:
+ key: value
+ register: main_network
+- name: verify create network
+ assert:
+ that:
+ - main_network is changed
+ - main_network.hcloud_network.name == "{{ hcloud_network_name }}"
+ - main_network.hcloud_network.ip_range == "10.0.0.0/16"
+- name: create subnetwork
+ hcloud_subnetwork:
+ network: "{{ hcloud_network_name }}"
+ type: server
+ network_zone: eu-central
+ ip_range: "10.0.1.0/24"
+ register: main_subnetwork
+- name: verify create subnetwork
+ assert:
+ that:
+ - main_subnetwork is changed
+ - main_subnetwork.hcloud_subnetwork.network == "{{ hcloud_network_name }}"
+- name: create route
+ hcloud_route:
+ network: "{{ hcloud_network_name }}"
+ destination: "10.0.3.0/24"
+ gateway: "10.0.2.1"
+ register: main_route
+- name: verify create route
+ assert:
+ that:
+ - main_route is changed
+ - main_route.hcloud_route.network == "{{ hcloud_network_name }}"
+
+- name: test gather hcloud network info in check mode
+ hcloud_network_info:
+ check_mode: yes
+ register: hcloud_network
+- name: verify test gather hcloud network info in check mode
+ assert:
+ that:
+ - hcloud_network.hcloud_network_info | selectattr('name','equalto','{{ hcloud_network_name }}') | list | count >= 1
+
+
+- name: test gather hcloud network info with correct label selector
+ hcloud_network_info:
+ label_selector: "key=value"
+ register: hcloud_network
+- name: verify test gather hcloud network with correct label selector
+ assert:
+ that:
+ - hcloud_network.hcloud_network_info | selectattr('name','equalto','{{ hcloud_network_name }}') | list | count >= 1
+
+- name: test gather hcloud network info with wrong label selector
+ hcloud_network_info:
+ label_selector: "key!=value"
+ register: hcloud_network
+- name: verify test gather hcloud network with wrong label selector
+ assert:
+ that:
+ - hcloud_network.hcloud_network_info | list | count == 0
+
+- name: test gather hcloud network info with correct name
+ hcloud_network_info:
+ name: "{{hcloud_network_name}}"
+ register: hcloud_network
+- name: verify test gather hcloud network with correct name
+ assert:
+ that:
+ - hcloud_network.hcloud_network_info | selectattr('name','equalto','{{ hcloud_network_name }}') | list | count == 1
+ - hcloud_network.hcloud_network_info[0].subnetworks | list | count >= 1
+ - hcloud_network.hcloud_network_info[0].routes | list | count >= 1
+
+- name: test gather hcloud network info with wrong name
+ hcloud_network_info:
+ name: "{{hcloud_network_name}}1"
+ register: hcloud_network
+- name: verify test gather hcloud network with wrong name
+ assert:
+ that:
+ - hcloud_network.hcloud_network_info | list | count == 0
+
+- name: test gather hcloud network info with correct id
+ hcloud_network_info:
+ id: "{{main_network.hcloud_network.id}}"
+ register: hcloud_network
+- name: verify test gather hcloud network with correct id
+ assert:
+ that:
+ - hcloud_network.hcloud_network_info | selectattr('name','equalto','{{ hcloud_network_name }}') | list | count == 1
+
+- name: test gather hcloud network info with wrong id
+ hcloud_network_info:
+ name: "4711"
+ register: hcloud_network
+- name: verify test gather hcloud network with wrong id
+ assert:
+ that:
+ - hcloud_network.hcloud_network_info | list | count == 0
+
+- name: cleanup
+ hcloud_network:
+ name: "{{ hcloud_network_name }}"
+ state: absent
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_placement_group/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_placement_group/aliases
new file mode 100644
index 000000000..55ec821a4
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_placement_group/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+shippable/hcloud/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_placement_group/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_placement_group/defaults/main.yml
new file mode 100644
index 000000000..21ce3429a
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_placement_group/defaults/main.yml
@@ -0,0 +1,6 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_prefix: "tests"
+hcloud_placement_group_name: "{{hcloud_prefix}}-i"
+hcloud_server_name: "{{ hcloud_prefix | truncate(45, True, '', 0) }}-i"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_placement_group/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_placement_group/meta/main.yml
new file mode 100644
index 000000000..407c9018a
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_placement_group/meta/main.yml
@@ -0,0 +1,3 @@
+collections:
+ - community.general.ipfilter
+ - hetzner.cloud
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_placement_group/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_placement_group/tasks/main.yml
new file mode 100644
index 000000000..d79aa0c35
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_placement_group/tasks/main.yml
@@ -0,0 +1,169 @@
+# Copyright: (c) 2020, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: setup placement group to be absent
+ hcloud_placement_group:
+ name: "{{ hcloud_placement_group_name }}"
+ state: absent
+
+- name: setup server to be absent
+ hcloud_server:
+ name: "{{ hcloud_server_name }}"
+ state: absent
+
+- name: test missing required parameters on create placement group
+ hcloud_placement_group:
+ register: result
+ ignore_errors: yes
+- name: verify fail test missing required parameters on create placement group
+ assert:
+ that:
+ - result is failed
+ - 'result.msg == "one of the following is required: id, name"'
+
+- name: test create placement group with check mode
+ hcloud_placement_group:
+ name: "{{ hcloud_placement_group_name }}"
+ type: spread
+ register: result
+ check_mode: yes
+- name: test create placement group with check mode
+ assert:
+ that:
+ - result is changed
+
+- name: test create placement group
+ hcloud_placement_group:
+ name: "{{ hcloud_placement_group_name }}"
+ type: spread
+ labels:
+ key: value
+ my-label: label
+ register: placement_group
+- name: verify create placement group
+ assert:
+ that:
+ - placement_group is changed
+ - placement_group.hcloud_placement_group.name == "{{ hcloud_placement_group_name }}"
+ - placement_group.hcloud_placement_group.type == "spread"
+ - placement_group.hcloud_placement_group.servers | list | count == 0
+
+- name: test create placement group idempotence
+ hcloud_placement_group:
+ name: "{{ hcloud_placement_group_name }}"
+ type: spread
+ labels:
+ key: value
+ my-label: label
+ register: result
+- name: verify create placement group idempotence
+ assert:
+ that:
+ - result is not changed
+
+- name: test create server with placement group
+ hcloud_server:
+ name: "{{ hcloud_server_name }}"
+ server_type: cpx11
+ placement_group: "{{ hcloud_placement_group_name }}"
+ image: "ubuntu-20.04"
+ ssh_keys:
+ - ci@ansible.hetzner.cloud
+ state: present
+ register: server
+- name: verify create server with placement group
+ assert:
+ that:
+ - server is changed
+ - server.hcloud_server.placement_group == "{{ hcloud_placement_group_name }}"
+
+- name: test remove server from placement group
+ hcloud_server:
+ name: "{{ hcloud_server_name }}"
+ placement_group: null
+ state: present
+ register: result
+- name: verify remove server from placement group
+ assert:
+ that:
+ - result is changed
+ - result.hcloud_server.placement_group == None
+
+- name: test add server to placement group
+ hcloud_server:
+ name: "{{ hcloud_server_name }}"
+ placement_group: "{{ hcloud_placement_group_name }}"
+ force: True
+ state: present
+ register: result
+- name: verify add server to placement group
+ assert:
+ that:
+ - result is changed
+ - result.hcloud_server.placement_group == "{{ hcloud_placement_group_name }}"
+ - result.hcloud_server.status == "running"
+
+- name: test add server to placement group idempotence
+ hcloud_server:
+ name: "{{ hcloud_server_name }}"
+ placement_group: "{{ hcloud_placement_group_name }}"
+ force: True
+ state: present
+ register: result
+- name: verify add server to placement group idempotence
+ assert:
+ that:
+ - result is not changed
+ - result.hcloud_server.placement_group == "{{ hcloud_placement_group_name }}"
+ - result.hcloud_server.status == "running"
+
+- name: test update placement group with check mode
+ hcloud_placement_group:
+ id: "{{ placement_group.hcloud_placement_group.id }}"
+ name: "changed-{{ hcloud_placement_group_name }}"
+ register: result
+ check_mode: yes
+- name: verify update placement group with check mode
+ assert:
+ that:
+ - result is changed
+
+- name: test update placement group
+ hcloud_placement_group:
+ id: "{{ placement_group.hcloud_placement_group.id }}"
+ name: "changed-{{ hcloud_placement_group_name }}"
+ labels:
+ key: value
+ register: result
+- name: verify update placement group
+ assert:
+ that:
+ - result is changed
+ - result.hcloud_placement_group.name == "changed-{{ hcloud_placement_group_name }}"
+
+- name: test update placement group idempotence
+ hcloud_placement_group:
+ id: "{{ placement_group.hcloud_placement_group.id }}"
+ name: "changed-{{ hcloud_placement_group_name }}"
+ labels:
+ key: value
+ register: result
+- name: verify update placement group idempotence
+ assert:
+ that:
+ - result is not changed
+
+- name: absent server
+ hcloud_server:
+ id: "{{ server.hcloud_server.id }}"
+ state: absent
+
+- name: absent placement group
+ hcloud_placement_group:
+ id: "{{ placement_group.hcloud_placement_group.id }}"
+ state: absent
+ register: result
+- name: verify absent placement group
+ assert:
+ that:
+ - result is success
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_primary_ip/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_primary_ip/aliases
new file mode 100644
index 000000000..55ec821a4
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_primary_ip/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+shippable/hcloud/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_primary_ip/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_primary_ip/defaults/main.yml
new file mode 100644
index 000000000..98aa28eea
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_primary_ip/defaults/main.yml
@@ -0,0 +1,6 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_prefix: "tests"
+hcloud_primary_ip_name: "{{hcloud_prefix}}-i"
+hcloud_server_name: "{{ hcloud_prefix | truncate(45, True, '', 0) }}-fip-t"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_primary_ip/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_primary_ip/meta/main.yml
new file mode 100644
index 000000000..407c9018a
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_primary_ip/meta/main.yml
@@ -0,0 +1,3 @@
+collections:
+ - community.general.ipfilter
+ - hetzner.cloud
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_primary_ip/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_primary_ip/tasks/main.yml
new file mode 100644
index 000000000..d4efc606b
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_primary_ip/tasks/main.yml
@@ -0,0 +1,243 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: test create Primary IP with check mode
+ hcloud_primary_ip:
+ name: "{{ hcloud_primary_ip_name }}"
+ type: ipv4
+ datacenter: "fsn1-dc14"
+ register: primaryIP
+ check_mode: yes
+- name: verify test create Primary IP with check mode
+ assert:
+ that:
+ - primaryIP is changed
+
+- name: test create Primary IP
+ hcloud_primary_ip:
+ name: "{{ hcloud_primary_ip_name }}"
+ type: ipv4
+ datacenter: "fsn1-dc14"
+ register: primaryIP
+- name: verify test create Primary IP
+ assert:
+ that:
+ - primaryIP is changed
+ - primaryIP.hcloud_primary_ip.name ==hcloud_primary_ip_name
+ - primaryIP.hcloud_primary_ip.datacenter == "fsn1-dc14"
+
+- name: test create Primary IP idempotency
+ hcloud_primary_ip:
+ name: "{{ hcloud_primary_ip_name }}"
+ type: ipv4
+ datacenter: "fsn1-dc14"
+ register: primaryIP
+- name: verify test create Primary IP idempotency
+ assert:
+ that:
+ - primaryIP is not changed
+
+- name: test update Primary IP
+ hcloud_primary_ip:
+ name: "{{ hcloud_primary_ip_name }}"
+ type: ipv4
+ datacenter: "fsn1-dc14"
+ labels:
+ key: value
+ register: primaryIP
+- name: verify test update Primary IP
+ assert:
+ that:
+ - primaryIP is changed
+
+- name: test update Primary IP idempotency
+ hcloud_primary_ip:
+ name: "{{ hcloud_primary_ip_name }}"
+ type: ipv4
+ datacenter: "fsn1-dc14"
+ labels:
+ key: value
+ register: primaryIP
+- name: verify test update Primary IP idempotency
+ assert:
+ that:
+ - primaryIP is not changed
+
+- name: test update Primary IP with same labels
+ hcloud_primary_ip:
+ name: "{{ hcloud_primary_ip_name }}"
+ type: ipv4
+ datacenter: "fsn1-dc14"
+ labels:
+ key: value
+ register: primaryIP
+- name: verify test update Primary IP with same labels
+ assert:
+ that:
+ - primaryIP is not changed
+
+- name: test update Primary IP with other labels
+ hcloud_primary_ip:
+ name: "{{ hcloud_primary_ip_name }}"
+ type: ipv4
+ datacenter: "fsn1-dc14"
+ labels:
+ key: value
+ other: label
+ register: primaryIP
+- name: verify test update Primary IP with other labels
+ assert:
+ that:
+ - primaryIP is changed
+
+- name: test update Primary IP with other labels in different order
+ hcloud_primary_ip:
+ name: "{{ hcloud_primary_ip_name }}"
+ type: ipv4
+ datacenter: "fsn1-dc14"
+ labels:
+ other: label
+ key: value
+ register: primaryIP
+- name: verify test update Primary IP with other labels in different order
+ assert:
+ that:
+ - primaryIP is not changed
+
+- name: test update Primary IP delete protection
+ hcloud_primary_ip:
+ name: "{{ hcloud_primary_ip_name }}"
+ type: ipv4
+ delete_protection: true
+ register: primaryIP
+- name: verify update Primary IP delete protection
+ assert:
+ that:
+ - primaryIP is changed
+ - primaryIP.hcloud_primary_ip.delete_protection is sameas true
+
+- name: test update Primary IP delete protection idempotency
+ hcloud_primary_ip:
+ name: "{{ hcloud_primary_ip_name }}"
+ type: ipv4
+ delete_protection: true
+ register: primaryIP
+- name: verify update Primary IP delete protection idempotency
+ assert:
+ that:
+ - primaryIP is not changed
+ - primaryIP.hcloud_primary_ip.delete_protection is sameas true
+
+- name: test Primary IP without delete protection set to be idempotent
+ hcloud_primary_ip:
+ name: "{{ hcloud_primary_ip_name }}"
+ type: ipv4
+ register: primaryIP
+- name: verify Primary IP without delete protection set to be idempotent
+ assert:
+ that:
+ - primaryIP is not changed
+ - primaryIP.hcloud_primary_ip.delete_protection is sameas true
+
+- name: test delete Primary IP fails if it is protected
+ hcloud_primary_ip:
+ name: "{{ hcloud_primary_ip_name }}"
+ state: "absent"
+ register: result
+ ignore_errors: yes
+- name: verify test delete primary ip
+ assert:
+ that:
+ - result is failed
+ - 'result.msg == "Primary IP deletion is protected"'
+
+- name: test update Primary IP delete protection
+ hcloud_primary_ip:
+ name: "{{ hcloud_primary_ip_name }}"
+ type: ipv4
+ delete_protection: false
+ register: primaryIP
+- name: verify update Primary IP delete protection
+ assert:
+ that:
+ - primaryIP is changed
+ - primaryIP.hcloud_primary_ip.delete_protection is sameas false
+
+- name: test delete primary ip
+ hcloud_primary_ip:
+ name: "{{ hcloud_primary_ip_name }}"
+ state: "absent"
+ register: result
+- name: verify test delete primary ip
+ assert:
+ that:
+ - result is changed
+
+- name: test create ipv6 primary ip
+ hcloud_primary_ip:
+ name: "{{ hcloud_primary_ip_name }}"
+ type: ipv6
+ datacenter: "fsn1-dc14"
+ state: "present"
+ register: result
+- name: verify test create ipv6 primary ip
+ assert:
+ that:
+ - result is changed
+
+- name: test delete ipv6 primary ip
+ hcloud_primary_ip:
+ name: "{{ hcloud_primary_ip_name }}"
+ state: "absent"
+ register: result
+- name: verify test delete ipv6 primary ip
+ assert:
+ that:
+ - result is changed
+
+- name: test create Primary IP with delete protection
+ hcloud_primary_ip:
+ name: "{{ hcloud_primary_ip_name }}"
+ type: ipv4
+ datacenter: fsn1-dc14
+ delete_protection: true
+ register: primaryIP
+- name: verify create Primary IP with delete protection
+ assert:
+ that:
+ - primaryIP is changed
+ - primaryIP.hcloud_primary_ip.delete_protection is sameas true
+
+- name: test delete Primary IP fails if it is protected
+ hcloud_primary_ip:
+ name: "{{ hcloud_primary_ip_name }}"
+ state: "absent"
+ register: result
+ ignore_errors: yes
+- name: verify test delete primary ip
+ assert:
+ that:
+ - result is failed
+ - 'result.msg == "Primary IP deletion is protected"'
+
+- name: test update Primary IP delete protection
+ hcloud_primary_ip:
+ name: "{{ hcloud_primary_ip_name }}"
+ type: ipv4
+ delete_protection: false
+ register: primaryIP
+- name: verify update Primary IP delete protection
+ assert:
+ that:
+ - primaryIP is changed
+ - primaryIP.hcloud_primary_ip.delete_protection is sameas false
+
+- name: test delete primary ip
+ hcloud_primary_ip:
+ name: "{{ hcloud_primary_ip_name }}"
+ state: "absent"
+ register: result
+- name: verify test delete primary ip
+ assert:
+ that:
+ - result is changed
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/aliases
new file mode 100644
index 000000000..18dc30b6c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+shippable/hcloud/group1
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/defaults/main.yml
new file mode 100644
index 000000000..50117a8a5
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/defaults/main.yml
@@ -0,0 +1,8 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_prefix: "tests"
+hcloud_server_name: "{{ hcloud_prefix | truncate(45, True, '', 0) }}"
+hcloud_floating_ip_name: "{{hcloud_prefix}}"
+hcloud_primary_ip_name: "{{hcloud_prefix}}"
+hcloud_load_balancer_name: "{{hcloud_prefix}}"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/meta/main.yml
new file mode 100644
index 000000000..67d54d732
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/meta/main.yml
@@ -0,0 +1,3 @@
+collections:
+ - ansible.netcommon
+ - hetzner.cloud
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/tasks/main.yml
new file mode 100644
index 000000000..dddbac0d0
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_rdns/tasks/main.yml
@@ -0,0 +1,224 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: setup
+ hcloud_server:
+ name: "{{ hcloud_server_name }}"
+ server_type: cx11
+ image: "ubuntu-22.04"
+ ssh_keys:
+ - ci@ansible.hetzner.cloud
+ state: present
+ register: setup
+- name: verify setup
+ assert:
+ that:
+ - setup is success
+
+- name: setup Floating IP
+ hcloud_floating_ip:
+ name: "{{ hcloud_floating_ip_name }}"
+ type: ipv4
+ home_location: "fsn1"
+ register: floatingIP
+- name: verify setup Floating IP
+ assert:
+ that:
+ - floatingIP is success
+
+- name: setup Load Balancer
+ hcloud_load_balancer:
+ name: "{{ hcloud_load_balancer_name}}"
+ load_balancer_type: lb11
+ network_zone: eu-central
+ state: present
+ register: load_balancer
+- name: verify setup
+ assert:
+ that:
+ - load_balancer is success
+
+- name: setup Primary IP
+ hcloud_primary_ip:
+ name: "{{ hcloud_primary_ip_name }}"
+ type: ipv4
+ datacenter: "fsn1-dc14"
+ register: primaryIP
+- name: verify setup Primary IP
+ assert:
+ that:
+ - primaryIP is success
+
+- name: test missing required parameter
+ hcloud_rdns:
+ state: present
+ register: result
+ ignore_errors: yes
+- name: verify fail test missing required parameters
+ assert:
+ that:
+ - result is failed
+ - 'result.msg == "missing required arguments: ip_address"'
+- name: test fail on not existing resource
+ hcloud_rdns:
+ server: "not-existing"
+ ip_address: "127.0.0.1"
+ state: present
+ register: result
+ ignore_errors: yes
+- name: verify fail on not existing resou
+ assert:
+ that:
+ - result is failed
+ - 'result.msg == "The selected server does not exist"'
+- name: test create rdns
+ hcloud_rdns:
+ server: "{{ hcloud_server_name }}"
+ ip_address: "{{ setup.hcloud_server.ipv6 | ansible.netcommon.ipaddr('next_usable') }}"
+ dns_ptr: "example.com"
+ state: present
+ register: rdns
+- name: verify create rdns
+ assert:
+ that:
+ - rdns is changed
+ - rdns.hcloud_rdns.server == "{{ hcloud_server_name }}"
+ - rdns.hcloud_rdns.ip_address == "{{ setup.hcloud_server.ipv6 | ansible.netcommon.ipaddr('next_usable') }}"
+ - rdns.hcloud_rdns.dns_ptr == "example.com"
+
+- name: test create rdns idempotency
+ hcloud_rdns:
+ server: "{{ hcloud_server_name }}"
+ ip_address: "{{ setup.hcloud_server.ipv6 | ansible.netcommon.ipaddr('next_usable') }}"
+ dns_ptr: "example.com"
+ state: present
+ register: result
+- name: verify create rdns idempotency
+ assert:
+ that:
+ - result is not changed
+
+- name: test absent rdns
+ hcloud_rdns:
+ server: "{{ hcloud_server_name }}"
+ ip_address: "{{ setup.hcloud_server.ipv6 | ansible.netcommon.ipaddr('next_usable') }}"
+ state: absent
+ register: result
+- name: verify test absent rdns
+ assert:
+ that:
+ - result is changed
+
+- name: test update rdns
+ hcloud_rdns:
+ server: "{{ hcloud_server_name }}"
+ ip_address: "{{ setup.hcloud_server.ipv4_address }}"
+ dns_ptr: "example.com"
+ state: present
+ register: rdns
+- name: verify update rdns
+ assert:
+ that:
+ - rdns is changed
+ - rdns.hcloud_rdns.server == "{{ hcloud_server_name }}"
+ - rdns.hcloud_rdns.ip_address == "{{ setup.hcloud_server.ipv4_address }}"
+ - rdns.hcloud_rdns.dns_ptr == "example.com"
+
+- name: test reset rdns
+ hcloud_rdns:
+ server: "{{ hcloud_server_name }}"
+ ip_address: "{{ setup.hcloud_server.ipv4_address }}"
+ state: present
+ register: rdns
+- name: verify reset rdns
+ assert:
+ that:
+ - rdns is changed
+ - rdns.hcloud_rdns.server == "{{ hcloud_server_name }}"
+ - rdns.hcloud_rdns.ip_address == "{{ setup.hcloud_server.ipv4_address }}"
+ - rdns.hcloud_rdns.dns_ptr != "example.com"
+
+- name: test create rdns with floating IP
+ hcloud_rdns:
+ floating_ip: "{{ hcloud_floating_ip_name }}"
+ ip_address: "{{ floatingIP.hcloud_floating_ip.ip}}"
+ dns_ptr: "example.com"
+ state: present
+ register: rdns
+- name: verify create rdns
+ assert:
+ that:
+ - rdns is changed
+ - rdns.hcloud_rdns.floating_ip == "{{ hcloud_floating_ip_name }}"
+ - rdns.hcloud_rdns.ip_address == "{{ floatingIP.hcloud_floating_ip.ip}}"
+ - rdns.hcloud_rdns.dns_ptr == "example.com"
+
+- name: test create rdns with primary IP
+ hcloud_rdns:
+ primary_ip: "{{ hcloud_primary_ip_name }}"
+ ip_address: "{{ primaryIP.hcloud_primary_ip.ip}}"
+ dns_ptr: "example.com"
+ state: present
+ register: rdns
+- name: verify create rdns
+ assert:
+ that:
+ - rdns is changed
+ - rdns.hcloud_rdns.primary_ip == "{{ hcloud_primary_ip_name }}"
+ - rdns.hcloud_rdns.ip_address == "{{ primaryIP.hcloud_primary_ip.ip}}"
+ - rdns.hcloud_rdns.dns_ptr == "example.com"
+
+- name: test create rdns with load balancer
+ hcloud_rdns:
+ load_balancer: "{{ hcloud_load_balancer_name }}"
+ ip_address: "{{ load_balancer.hcloud_load_balancer.ipv4_address }}"
+ dns_ptr: "example.com"
+ state: present
+ register: rdns
+- name: verify create rdns with load balancer
+ assert:
+ that:
+ - rdns is changed
+ - rdns.hcloud_rdns.load_balancer == "{{ hcloud_load_balancer_name }}"
+ - rdns.hcloud_rdns.ip_address == "{{ load_balancer.hcloud_load_balancer.ipv4_address }}"
+ - rdns.hcloud_rdns.dns_ptr == "example.com"
+
+- name: cleanup
+ hcloud_server:
+ name: "{{ hcloud_server_name }}"
+ state: absent
+ register: result
+- name: verify cleanup
+ assert:
+ that:
+ - result is success
+
+- name: cleanup
+ hcloud_floating_ip:
+ name: "{{ hcloud_floating_ip_name }}"
+ state: absent
+ register: result
+- name: verify cleanup
+ assert:
+ that:
+ - result is success
+
+- name: cleanup
+ hcloud_primary_ip:
+ name: "{{ hcloud_primary_ip_name }}"
+ state: absent
+ register: result
+- name: verify cleanup
+ assert:
+ that:
+ - result is success
+
+- name: cleanup
+ hcloud_load_balancer:
+ name: "{{ hcloud_load_balancer_name }}"
+ state: absent
+ register: result
+- name: verify cleanup
+ assert:
+ that:
+ - result is success
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/aliases
new file mode 100644
index 000000000..18dc30b6c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+shippable/hcloud/group1
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/defaults/main.yml
new file mode 100644
index 000000000..c93c7495e
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/defaults/main.yml
@@ -0,0 +1,5 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_prefix: "tests"
+hcloud_network_name: "{{hcloud_prefix}}-ro"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/meta/main.yml
new file mode 100644
index 000000000..67d54d732
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/meta/main.yml
@@ -0,0 +1,3 @@
+collections:
+ - ansible.netcommon
+ - hetzner.cloud
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/tasks/main.yml
new file mode 100644
index 000000000..7d816bf5c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_route/tasks/main.yml
@@ -0,0 +1,99 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: setup
+ hcloud_network:
+ name: "{{ hcloud_network_name }}"
+ ip_range: "10.0.0.0/8"
+ state: present
+ register: network
+- name: verify setup
+ assert:
+ that:
+ - network is success
+
+- name: test missing required parameters on create route
+ hcloud_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/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/aliases
new file mode 100644
index 000000000..18dc30b6c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+shippable/hcloud/group1
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/defaults/main.yml
new file mode 100644
index 000000000..4e1c4dc45
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/defaults/main.yml
@@ -0,0 +1,8 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_prefix: "tests"
+hcloud_server_name: "{{ hcloud_prefix | truncate(45, True, '', 0) }}-i"
+hcloud_firewall_name: "{{hcloud_prefix}}-i"
+hcloud_primary_ip_name: "{{hcloud_prefix}}-i"
+hcloud_network_name: "{{hcloud_prefix}}-i"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/meta/main.yml
new file mode 100644
index 000000000..407c9018a
--- /dev/null
+++ b/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/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/basic.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/basic.yml
new file mode 100644
index 000000000..ac609fc6c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/basic.yml
@@ -0,0 +1,615 @@
+- name: test create server with check mode
+ hcloud_server:
+ name: "{{ hcloud_server_name }}"
+ server_type: cx11
+ image: ubuntu-20.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-20.04
+ enable_ipv6: False
+ 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 backups are not accidentally disabled
+ hcloud_server:
+ name: "{{ hcloud_server_name }}"
+ # Make sure that backups are not disabled because a partial server object without "backups" was supplied somewhere
+ # to update some unrelated properties.
+ # Regression test for https://github.com/ansible-collections/hetzner.hcloud/pull/196
+ # backups: true
+ state: stopped
+ register: result
+- name: verify backups are not accidentally disabled
+ assert:
+ that:
+ - result is not changed
+ - result.hcloud_server.backup_window != ""
+
+- name: test rebuild server
+ hcloud_server:
+ name: "{{ hcloud_server_name }}"
+ image: ubuntu-20.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-20.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-20.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-20.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: 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: 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-20.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: test create server with labels
+ hcloud_server:
+ name: "{{ hcloud_server_name}}"
+ server_type: cx11
+ image: "ubuntu-20.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-20.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-20.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-20.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: cleanup 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/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/firewalls.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/firewalls.yml
new file mode 100644
index 000000000..18fa89e25
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/firewalls.yml
@@ -0,0 +1,105 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: test add not existing firewall should fail
+ hcloud_server:
+ name: "{{ hcloud_server_name }}"
+ firewalls:
+ - not-existing
+ state: present
+ ignore_errors: yes
+ register: result
+- name: verify add not existing firewall should fail
+ assert:
+ that:
+ - result is failed
+ - 'result.msg == "firewall not-existing was not found"'
+- name: setup create firewalls
+ hcloud_firewall:
+ name: "{{ item }}"
+ rules:
+ - direction: in
+ protocol: icmp
+ source_ips:
+ - 0.0.0.0/0
+ - ::/0
+ with_items:
+ - "{{ hcloud_firewall_name }}"
+ - "{{ hcloud_firewall_name }}2"
+
+- name: test create server with firewalls
+ hcloud_server:
+ name: "{{ hcloud_server_name }}"
+ server_type: cpx11
+ firewalls:
+ - "{{ hcloud_firewall_name }}"
+ image: "ubuntu-20.04"
+ ssh_keys:
+ - ci@ansible.hetzner.cloud
+ state: present
+ register: result
+- name: verify test create server with firewalls
+ assert:
+ that:
+ - result is changed
+
+- name: test create server with firewalls idempotence
+ hcloud_server:
+ name: "{{ hcloud_server_name }}"
+ server_type: cpx11
+ firewalls:
+ - "{{ hcloud_firewall_name }}"
+ image: "ubuntu-20.04"
+ ssh_keys:
+ - ci@ansible.hetzner.cloud
+ state: present
+ register: result
+- name: verify test create server with firewalls idempotence
+ assert:
+ that:
+ - result is not changed
+
+- name: test update server with firewalls
+ hcloud_server:
+ name: "{{ hcloud_server_name }}"
+ server_type: cpx11
+ firewalls:
+ - "{{ hcloud_firewall_name }}2"
+ image: "ubuntu-20.04"
+ ssh_keys:
+ - ci@ansible.hetzner.cloud
+ state: present
+ register: result
+- name: verify test update server with firewalls
+ assert:
+ that:
+ - result is changed
+
+- name: test update server with firewalls idempotence
+ hcloud_server:
+ name: "{{ hcloud_server_name }}"
+ server_type: cpx11
+ firewalls:
+ - "{{ hcloud_firewall_name }}2"
+ image: "ubuntu-20.04"
+ ssh_keys:
+ - ci@ansible.hetzner.cloud
+ state: present
+ register: result
+- name: verify test update server with firewalls idempotence
+ assert:
+ that:
+ - result is not changed
+
+- name: cleanup server with firewalls
+ hcloud_server:
+ name: "{{ hcloud_server_name }}"
+ state: absent
+
+- name: cleanup test create firewall
+ hcloud_firewall:
+ name: "{{ item }}"
+ state: absent
+ with_items:
+ - "{{ hcloud_firewall_name }}"
+ - "{{ hcloud_firewall_name }}2"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/main.yml
new file mode 100644
index 000000000..209d9bd48
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/main.yml
@@ -0,0 +1,8 @@
+# Copyright: (c) 2022, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+#- ansible.builtin.include_tasks: validation.yml
+- ansible.builtin.include_tasks: basic.yml
+#- ansible.builtin.include_tasks: firewalls.yml
+- ansible.builtin.include_tasks: primary_ips.yml
+- ansible.builtin.include_tasks: private_network_only.yml
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/primary_ips.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/primary_ips.yml
new file mode 100644
index 000000000..000c294de
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/primary_ips.yml
@@ -0,0 +1,82 @@
+# Copyright: (c) 2022, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: setup create primary ipv4
+ hcloud_primary_ip:
+ name: "{{ hcloud_primary_ip_name }}v4"
+ type: ipv4
+ datacenter: "fsn1-dc14"
+ register: primaryIPv4
+
+- name: setup create second primary ipv4
+ hcloud_primary_ip:
+ name: "{{ hcloud_primary_ip_name }}v42"
+ type: ipv4
+ datacenter: "fsn1-dc14"
+ register: secondPrimaryIPv4
+
+- name: setup create primary ipv6
+ hcloud_primary_ip:
+ name: "{{ hcloud_primary_ip_name }}v6"
+ type: ipv6
+ datacenter: "fsn1-dc14"
+ register: primaryIPv6
+
+- name: test create server with primary ips
+ hcloud_server:
+ name: "{{ hcloud_server_name }}"
+ server_type: cpx11
+ datacenter: "fsn1-dc14"
+ image: "ubuntu-20.04"
+ ipv4: "{{primaryIPv4.hcloud_primary_ip.id}}"
+ ipv6: "{{primaryIPv6.hcloud_primary_ip.id}}"
+ ssh_keys:
+ - ci@ansible.hetzner.cloud
+ state: stopped
+ register: result
+- name: verify test create server with primary ips
+ assert:
+ that:
+ - result is changed
+
+- name: test update server with primary ips
+ hcloud_server:
+ name: "{{ hcloud_server_name }}"
+ server_type: cpx11
+ datacenter: "fsn1-dc14"
+ image: "ubuntu-20.04"
+ ipv4: "{{secondPrimaryIPv4.hcloud_primary_ip.id}}"
+ ipv6: ""
+ enable_ipv6: no
+ ssh_keys:
+ - ci@ansible.hetzner.cloud
+ state: stopped
+ register: result
+- name: verify test create server with primary ips
+ assert:
+ that:
+ - result is changed
+
+- name: cleanup server with primary ips
+ hcloud_server:
+ name: "{{ hcloud_server_name }}"
+ state: absent
+
+- name: cleanup test create primary ips
+ hcloud_primary_ip:
+ name: "{{ hcloud_server_name }}v4"
+ state: absent
+- name: cleanup test create primary ips
+ hcloud_primary_ip:
+ name: "{{ hcloud_server_name }}v42"
+ state: absent
+ until: result is not failed
+ retries: 5
+ delay: 2
+- name: cleanup test create primary ips
+ hcloud_primary_ip:
+ name: "{{ hcloud_server_name }}v6"
+ state: absent
+ until: result is not failed
+ retries: 5
+ delay: 2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/private_network_only.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/private_network_only.yml
new file mode 100644
index 000000000..a56832873
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/private_network_only.yml
@@ -0,0 +1,135 @@
+# Copyright: (c) 2022, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: setup network 1 to be absent
+ hcloud_network:
+ name: "{{ hcloud_network_name }}-1"
+ state: absent
+
+- name: setup network 2 to be absent
+ hcloud_network:
+ name: "{{ hcloud_network_name }}-2"
+ state: absent
+
+- name: setup server to be absent
+ hcloud_server:
+ name: "{{ hcloud_server_name }}"
+ state: absent
+
+- name: setup create network
+ hcloud_network:
+ name: "{{ hcloud_network_name }}-1"
+ ip_range: 192.168.0.0/23
+ register: primaryNetwork
+
+- name: setup create network subnet 1
+ hcloud_subnetwork:
+ network: "{{ hcloud_network_name }}-1"
+ ip_range: 192.168.0.0/24
+ network_zone: eu-central
+ type: cloud
+ state: present
+
+- name: setup create network subnet 2
+ hcloud_subnetwork:
+ network: "{{ hcloud_network_name }}-1"
+ ip_range: 192.168.1.0/24
+ network_zone: eu-central
+ type: cloud
+ state: present
+
+- name: setup create secondary network
+ hcloud_network:
+ name: "{{ hcloud_network_name }}-2"
+ ip_range: 192.168.2.0/23
+ register: secondaryNetwork
+
+- name: setup create secondary network subnet 1
+ hcloud_subnetwork:
+ network: "{{ hcloud_network_name }}-2"
+ ip_range: 192.168.2.0/24
+ network_zone: eu-central
+ type: cloud
+ state: present
+
+- name: setup create secondary network subnet 2
+ hcloud_subnetwork:
+ network: "{{ hcloud_network_name }}-2"
+ ip_range: 192.168.3.0/24
+ network_zone: eu-central
+ type: cloud
+ state: present
+
+- name: test create server with primary network and no internet
+ hcloud_server:
+ name: "{{ hcloud_server_name }}"
+ server_type: cpx11
+ datacenter: "fsn1-dc14"
+ image: "ubuntu-20.04"
+ enable_ipv4: no
+ enable_ipv6: no
+ private_networks:
+ - "{{ primaryNetwork.hcloud_network.name }}"
+ ssh_keys:
+ - ci@ansible.hetzner.cloud
+ state: stopped
+ register: result
+- name: verify test create server with primary network
+ assert:
+ that:
+ - result is changed
+
+- name: test update server by adding secondary network
+ hcloud_server:
+ name: "{{ hcloud_server_name }}"
+ server_type: cpx11
+ datacenter: "fsn1-dc14"
+ image: "ubuntu-20.04"
+ enable_ipv4: no
+ enable_ipv6: no
+ private_networks:
+ - "{{ primaryNetwork.hcloud_network.name }}"
+ - "{{ secondaryNetwork.hcloud_network.id }}"
+ ssh_keys:
+ - ci@ansible.hetzner.cloud
+ state: stopped
+ register: result
+- name: verify test update server by adding secondary network
+ assert:
+ that:
+ - result is changed
+
+- name: test update server idem
+ hcloud_server:
+ name: "{{ hcloud_server_name }}"
+ server_type: cpx11
+ datacenter: "fsn1-dc14"
+ image: "ubuntu-20.04"
+ enable_ipv4: no
+ enable_ipv6: no
+ private_networks:
+ - "{{ primaryNetwork.hcloud_network.name }}"
+ - "{{ secondaryNetwork.hcloud_network.id }}"
+ ssh_keys:
+ - ci@ansible.hetzner.cloud
+ state: stopped
+ register: result
+- name: verify test update server idem
+ assert:
+ that:
+ - result is not changed
+
+- name: cleanup server
+ hcloud_server:
+ name: "{{ hcloud_server_name }}"
+ state: absent
+- name: cleanup networks
+ hcloud_network:
+ name: "{{ item }}"
+ state: absent
+ with_items:
+ - "{{ primaryNetwork.hcloud_network.name }}"
+ - "{{ secondaryNetwork.hcloud_network.id }}"
+ until: result is not failed
+ retries: 5
+ delay: 2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/validation.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/validation.yml
new file mode 100644
index 000000000..f507e87cf
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server/tasks/validation.yml
@@ -0,0 +1,51 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: setup
+ hcloud_server:
+ name: "{{ hcloud_server_name }}"
+ 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 not existing server type
+ hcloud_server:
+ name: "{{ hcloud_server_name }}"
+ server_type: not-existing-server-type
+ image: ubuntu-20.04
+ state: present
+ register: result
+ ignore_errors: yes
+- name: verify fail test create server with not existing server type
+ assert:
+ that:
+ - result is failed
+ - 'result.msg == "server_type not-existing-server-type was not found"'
+
+- name: test create server with not existing image
+ hcloud_server:
+ name: "{{ hcloud_server_name }}"
+ server_type: cx11
+ image: my-not-existing-image-20.04
+ state: present
+ register: result
+ ignore_errors: yes
+- name: verify fail test create server with not existing image
+ assert:
+ that:
+ - result is failed
+ - 'result.msg == "Image my-not-existing-image-20.04 was not found"'
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/aliases
new file mode 100644
index 000000000..55ec821a4
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+shippable/hcloud/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/defaults/main.yml
new file mode 100644
index 000000000..aa27d6452
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/defaults/main.yml
@@ -0,0 +1,5 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_prefix: "tests"
+hcloud_server_name: "{{ hcloud_prefix | truncate(45, True, '', 0) }}-ii"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/meta/main.yml
new file mode 100644
index 000000000..407c9018a
--- /dev/null
+++ b/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/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/tasks/main.yml
new file mode 100644
index 000000000..b425b4127
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_info/tasks/main.yml
@@ -0,0 +1,128 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: setup ensure server is absent
+ hcloud_server:
+ name: "{{ hcloud_server_name }}"
+ state: absent
+ register: result
+
+- name: create server
+ hcloud_server:
+ name: "{{ hcloud_server_name }}"
+ server_type: cx11
+ image: ubuntu-22.04
+ state: started
+ labels:
+ key: value
+ register: main_server
+- name: verify create server
+ assert:
+ that:
+ - main_server is changed
+ - main_server.hcloud_server.name == "{{ hcloud_server_name }}"
+ - main_server.hcloud_server.server_type == "cx11"
+ - main_server.hcloud_server.status == "running"
+ - main_server.root_password != ""
+
+
+- name: test gather hcloud server infos in check mode
+ hcloud_server_info:
+ register: server
+ check_mode: yes
+
+- name: verify test gather hcloud server infos in check mode
+ assert:
+ that:
+ - server.hcloud_server_info|selectattr('name','equalto','{{ hcloud_server_name }}') | list | count == 1
+
+
+- name: test gather hcloud server infos with correct label selector
+ hcloud_server_info:
+ label_selector: "key=value"
+ register: server
+- name: verify test gather hcloud server infos with correct label selector
+ assert:
+ that:
+ - server.hcloud_server_info|selectattr('name','equalto','{{ hcloud_server_name }}') | list | count == 1
+
+- name: test gather hcloud server infos with wrong label selector
+ hcloud_server_info:
+ label_selector: "key!=value"
+ register: server
+- name: verify test gather hcloud server infos with wrong label selector
+ assert:
+ that:
+ - server.hcloud_server_info | list | count == 0
+
+- name: test gather hcloud server infos with correct name
+ hcloud_server_info:
+ name: "{{hcloud_server_name}}"
+ register: server
+- name: verify test gather hcloud server infos with correct name
+ assert:
+ that:
+ - server.hcloud_server_info|selectattr('name','equalto','{{ hcloud_server_name }}') | list | count == 1
+
+- name: test gather hcloud server infos with wrong name
+ hcloud_server_info:
+ name: "{{hcloud_server_name}}1"
+ register: server
+- name: verify test gather hcloud server infos with wrong name
+ assert:
+ that:
+ - server.hcloud_server_info | list | count == 0
+
+- name: test gather hcloud server infos with correct id
+ hcloud_server_info:
+ id: "{{main_server.hcloud_server.id}}"
+ register: server
+- name: verify test gather hcloud server infos with correct id
+ assert:
+ that:
+ - server.hcloud_server_info|selectattr('name','equalto','{{ hcloud_server_name }}') | list | count == 1
+
+- name: test gather hcloud server infos with wrong id
+ hcloud_server_info:
+ name: "4711"
+ register: server
+- name: verify test gather hcloud server infos with wrong id
+ assert:
+ that:
+ - server.hcloud_server_info | list | count == 0
+
+- name: cleanup
+ hcloud_server:
+ name: "{{ hcloud_server_name }}"
+ state: absent
+
+- name: create server without ips
+ hcloud_server:
+ name: "{{ hcloud_server_name }}"
+ server_type: cx11
+ image: ubuntu-22.04
+ state: stopped
+ labels:
+ key: value
+ enable_ipv4: no
+ enable_ipv6: no
+ register: main_server
+- name: verify create server
+ assert:
+ that:
+ - main_server is changed
+ - main_server.hcloud_server.name == "{{ hcloud_server_name }}"
+ - main_server.hcloud_server.server_type == "cx11"
+ - main_server.root_password != ""
+- name: test gather hcloud server infos with correct id
+ hcloud_server_info:
+ id: "{{main_server.hcloud_server.id}}"
+ register: server
+- name: verify test gather hcloud server infos with correct id
+ assert:
+ that:
+ - server.hcloud_server_info|selectattr('name','equalto','{{ hcloud_server_name }}') | list | count == 1
+- name: cleanup
+ hcloud_server:
+ name: "{{ hcloud_server_name }}"
+ state: absent
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/aliases
new file mode 100644
index 000000000..7f17468b0
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/aliases
@@ -0,0 +1,3 @@
+cloud/hcloud
+shippable/hcloud/group2
+disabled
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/defaults/main.yml
new file mode 100644
index 000000000..2e020c495
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/defaults/main.yml
@@ -0,0 +1,6 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_prefix: "tests"
+hcloud_network_name: "{{hcloud_prefix}}-sn"
+hcloud_server_name: "{{ hcloud_prefix | truncate(45, True, '', 0) }}-sn"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/meta/main.yml
new file mode 100644
index 000000000..407c9018a
--- /dev/null
+++ b/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/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/tasks/main.yml
new file mode 100644
index 000000000..754018a66
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_network/tasks/main.yml
@@ -0,0 +1,222 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: setup 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/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/aliases
new file mode 100644
index 000000000..55ec821a4
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+shippable/hcloud/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/defaults/main.yml
new file mode 100644
index 000000000..05502aa91
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/defaults/main.yml
@@ -0,0 +1,5 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_server_type_name: "cx11"
+hcloud_server_type_id: 1
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/meta/main.yml
new file mode 100644
index 000000000..407c9018a
--- /dev/null
+++ b/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/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/tasks/main.yml
new file mode 100644
index 000000000..3c1fce8c0
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_server_type_info/tasks/main.yml
@@ -0,0 +1,38 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: test gather hcloud server type infos
+ hcloud_server_type_info:
+ register: hcloud_server_types
+- name: verify test gather hcloud server type infos
+ assert:
+ that:
+ - hcloud_server_types.hcloud_server_type_info| list | count > 2
+
+- name: test gather hcloud server type infos in check mode
+ hcloud_server_type_info:
+ check_mode: yes
+ register: hcloud_server_types
+
+- name: verify test gather hcloud server type infos in check mode
+ assert:
+ that:
+ - hcloud_server_types.hcloud_server_type_info| list | count > 2
+
+- name: test gather hcloud server type infos with name
+ hcloud_server_type_info:
+ name: "{{hcloud_server_type_name}}"
+ register: hcloud_server_types
+- name: verify test gather hcloud server type with name
+ assert:
+ that:
+ - hcloud_server_types.hcloud_server_type_info|selectattr('name','equalto','{{ hcloud_server_type_name }}') | list | count == 1
+
+- name: test gather hcloud server type infos with correct id
+ hcloud_server_type_info:
+ id: "{{hcloud_server_type_id}}"
+ register: hcloud_server_types
+- name: verify test gather hcloud server type with correct id
+ assert:
+ that:
+ - hcloud_server_types.hcloud_server_type_info|selectattr('name','equalto','{{ hcloud_server_type_name }}') | list | count == 1
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/aliases
new file mode 100644
index 000000000..55ec821a4
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+shippable/hcloud/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/defaults/main.yml
new file mode 100644
index 000000000..cee1d4691
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/defaults/main.yml
@@ -0,0 +1,11 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_prefix: "tests"
+hcloud_server_name: "{{ hcloud_prefix | truncate(45, True, '', 0) }}"
+hcloud_ssh_key_name: "{{hcloud_prefix}}"
+hcloud_ssh_key_public_key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDnaTPfKaX1QKcRLOfr34buVLh5FhJAThI9NYB0xNdXsMd4Y0zLyyCQzHbx4eWCVZxym/s6csWSeLaAhO1GOHeAw3hQFMqf1oTBx6Y8g0pKpeotKPa/PDSUzdZF9Lc+DadtpQd8kFVHAu1Kd3zoEUnk1u6kP7I4qu4Z/6F9qBDF+M3aobiPVxdS7GwaVRW3nZu+FcQDLiBiNOjuRDyjHcDfEUkoh2SOu25RrFtGPzFu5mGmBJwotKpWAocLGfHzyn/fAHxgw3jKZVH/t+XWQFnl82Ie8yE3Z1EZ7oDkNRqFQT9AdXEQOLycTTYTQMJZpgeFTv3sAo6lPRCusiFmmLcf ci@ansible.hetzner.cloud"
+hcloud_ssh_key_fingerprint: "56:89:c4:d6:a7:4a:79:82:f4:c2:58:9c:e1:d2:2d:4e"
+
+hcloud_doubled_ssh_key_public_key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC1AiuN3UMQKzOs4tNudmlDSkSebC+savc6CivoHGflUKeli7nKb5pKgGiqH+zeWZc+8+flUa2BxsJWmi7d1nGJ++W4BnzmqW78ApelpJnGtuX8IKNcq/trhVTQyaShPiLluoBs7bXyyZpAKNGkk3jHrgwwYD/QQDN0CJnQUM18fjH5CUes2vmaG/kkhn7ctuVHDOvDcEy8KdBX3fYyrtXw5GgWDC5borG6yT1f3E9AXfRPL9OQjMTeC+G4FHscJAZjNnYav+jLrQLdV1xJ0JgbjRyBgTAfBszx9oKIjzCUPvpj4npju0WFGu10pIh0w7bluMoVn1tS6Y3gxE/Cepwt ci@ansible.hetzner.cloud"
+hcloud_doubled_ssh_key_fingerprint: "f9:33:40:ff:77:f3:3e:85:f2:9e:8f:98:71:fd:a0:58"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/meta/main.yml
new file mode 100644
index 000000000..5dcc0725d
--- /dev/null
+++ b/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/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/tasks/main.yml
new file mode 100644
index 000000000..9208e143d
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key/tasks/main.yml
@@ -0,0 +1,156 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: test missing required parameters 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-20.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 sshkey
+ assert:
+ that:
+ - result is success
+
+- name: test fail cleanly on double created ssh key
+ hcloud_ssh_key:
+ name: "{{ hcloud_ssh_key_name }}othername"
+ public_key: "{{ hcloud_doubled_ssh_key_public_key }}"
+ register: result
+ ignore_errors: yes
+- name: verify failed correctly
+ assert:
+ that:
+ - result is failed
+ - 'result.msg == "SSH key with the same fingerprint already exists"'
+
+- name: cleanup
+ hcloud_server:
+ name: "{{ hcloud_server_name }}"
+ state: absent
+ register: result
+- name: verify cleanup
+ assert:
+ that:
+ - result is success
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/aliases
new file mode 100644
index 000000000..55ec821a4
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+shippable/hcloud/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/defaults/main.yml
new file mode 100644
index 000000000..15188e181
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/defaults/main.yml
@@ -0,0 +1,5 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_prefix: "tests"
+hcloud_ssh_key_name: "{{hcloud_prefix}}-f"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/meta/main.yml
new file mode 100644
index 000000000..5dcc0725d
--- /dev/null
+++ b/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/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/tasks/main.yml
new file mode 100644
index 000000000..87cbd2626
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_ssh_key_info/tasks/main.yml
@@ -0,0 +1,68 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+
+- name: setup ensure ssh key is absent
+ hcloud_ssh_key:
+ name: "{{ hcloud_ssh_key_name }}"
+ state: absent
+ register: result
+
+- name: setup test ssh_key
+ hcloud_ssh_key:
+ name: "{{hcloud_ssh_key_name}}"
+ public_key: "{{ key_material }}"
+ labels:
+ key: value
+ register: result
+- name: verify create test ssh_key
+ assert:
+ that:
+ - result is changed
+ - result.hcloud_ssh_key.public_key == "{{ key_material }}"
+
+- name: test gather hcloud ssh key infos in check mode
+ hcloud_ssh_key_info:
+ register: hcloud_ssh_key
+ check_mode: yes
+- name: verify test gather hcloud ssh key infos in check mode
+ assert:
+ that:
+ - hcloud_ssh_key.hcloud_ssh_key_info| list | count >= 1
+
+- name: test gather hcloud ssh key infos
+ hcloud_ssh_key_info:
+ register: hcloud_ssh_key
+ check_mode: yes
+- name: verify test gather hcloud ssh key infos
+ assert:
+ that:
+ - hcloud_ssh_key.hcloud_ssh_key_info| list | count >= 1
+
+- name: test gather hcloud ssh key infos with correct label selector
+ hcloud_ssh_key_info:
+ label_selector: "key=value"
+ register: hcloud_ssh_key
+- name: verify test gather hcloud ssh key infos with correct label selector
+ assert:
+ that:
+ - hcloud_ssh_key.hcloud_ssh_key_info|selectattr('name','equalto','{{ hcloud_ssh_key_name }}') | list | count == 1
+
+- name: test gather hcloud ssh key infos with wrong label selector
+ hcloud_ssh_key_info:
+ label_selector: "key!=value"
+ register: hcloud_ssh_key
+- name: verify test gather hcloud ssh key infos with wrong label selector
+ assert:
+ that:
+ - hcloud_ssh_key.hcloud_ssh_key_info | list | count == 0
+
+- name: cleanup
+ hcloud_ssh_key:
+ name: "{{hcloud_ssh_key_name}}"
+ state: absent
+ register: result
+- name: verify cleanup
+ assert:
+ that:
+ - result is success
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/aliases
new file mode 100644
index 000000000..af1d98c3d
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+shippable/hcloud/group3
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/defaults/main.yml
new file mode 100644
index 000000000..79f0d8783
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/defaults/main.yml
@@ -0,0 +1,6 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_prefix: "tests"
+hcloud_network_name: "{{hcloud_prefix}}-s"
+hetzner_vswitch_id: 15311
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/meta/main.yml
new file mode 100644
index 000000000..407c9018a
--- /dev/null
+++ b/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/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/tasks/main.yml
new file mode 100644
index 000000000..0453f9d13
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_subnetwork/tasks/main.yml
@@ -0,0 +1,125 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: setup
+ hcloud_network:
+ name: "{{ hcloud_network_name }}"
+ ip_range: "10.0.0.0/8"
+ state: present
+ register: network
+- name: verify setup
+ assert:
+ that:
+ - network is success
+
+- name: test missing required parameters on create route
+ hcloud_subnetwork:
+ network: "{{ hcloud_network_name }}"
+ state: present
+ register: result
+ ignore_errors: yes
+- name: verify fail test missing required parameters on create route
+ assert:
+ that:
+ - result is failed
+ - 'result.msg == "missing required arguments: ip_range, network_zone, type"'
+
+- name: test create subnetwork with checkmode
+ hcloud_subnetwork:
+ network: "{{ hcloud_network_name }}"
+ ip_range: "10.0.0.0/16"
+ type: "server"
+ network_zone: "eu-central"
+ state: present
+ register: result
+ check_mode: yes
+- name: verify test create subnetwork with checkmode
+ assert:
+ that:
+ - result is changed
+
+- name: test create subnetwork
+ hcloud_subnetwork:
+ network: "{{ hcloud_network_name }}"
+ ip_range: "10.0.0.0/16"
+ type: "cloud"
+ network_zone: "eu-central"
+ state: present
+ register: subnet
+- name: verify create subnetwork
+ assert:
+ that:
+ - subnet is changed
+ - subnet.hcloud_subnetwork.network == "{{ hcloud_network_name }}"
+ - subnet.hcloud_subnetwork.ip_range == "10.0.0.0/16"
+ - subnet.hcloud_subnetwork.type == "cloud"
+ - subnet.hcloud_subnetwork.network_zone == "eu-central"
+
+- name: test create subnetwork idempotency
+ hcloud_subnetwork:
+ network: "{{ hcloud_network_name }}"
+ ip_range: "10.0.0.0/16"
+ type: "cloud"
+ network_zone: "eu-central"
+ state: present
+ register: result
+- name: verify create subnetwork idempotency
+ assert:
+ that:
+ - result is not changed
+
+- name: test absent subnetwork
+ hcloud_subnetwork:
+ network: "{{ hcloud_network_name }}"
+ ip_range: "10.0.0.0/16"
+ type: "cloud"
+ network_zone: "eu-central"
+ state: absent
+ register: result
+- name: verify test absent subnetwork
+ assert:
+ that:
+ - result is changed
+
+- name: test vswitch subnetwork
+ hcloud_subnetwork:
+ network: "{{ hcloud_network_name }}"
+ ip_range: "10.0.0.0/16"
+ type: "vswitch"
+ network_zone: "eu-central"
+ vswitch_id: "{{ hetzner_vswitch_id }}"
+ state: present
+ register: subnet
+- name: verify test vswitch subnetwork
+ assert:
+ that:
+ - subnet is changed
+ - subnet.hcloud_subnetwork.network == "{{ hcloud_network_name }}"
+ - subnet.hcloud_subnetwork.ip_range == "10.0.0.0/16"
+ - subnet.hcloud_subnetwork.type == "vswitch"
+ - subnet.hcloud_subnetwork.network_zone == "eu-central"
+ - subnet.hcloud_subnetwork.vswitch_id == hetzner_vswitch_id
+
+- name: test absent subnetwork
+ hcloud_subnetwork:
+ network: "{{ hcloud_network_name }}"
+ ip_range: "10.0.0.0/16"
+ type: "vswitch"
+ network_zone: "eu-central"
+ vswitch_id: "{{ hetzner_vswitch_id }}"
+ state: absent
+ register: subnet
+- name: verify test absent subnetwork
+ assert:
+ that:
+ - result is changed
+
+- name: cleanup
+ hcloud_network:
+ name: "{{hcloud_network_name}}"
+ state: absent
+ register: result
+- name: verify cleanup
+ assert:
+ that:
+ - result is success
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/aliases
new file mode 100644
index 000000000..55ec821a4
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+shippable/hcloud/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/defaults/main.yml
new file mode 100644
index 000000000..ff16ce28f
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/defaults/main.yml
@@ -0,0 +1,6 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_prefix: "tests"
+hcloud_volume_name: "{{ hcloud_prefix | truncate(60, True, '', 0) }}-i"
+hcloud_server_name: "{{ hcloud_prefix | truncate(45, True, '', 0) }}-vs"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/meta/main.yml
new file mode 100644
index 000000000..407c9018a
--- /dev/null
+++ b/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/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/tasks/main.yml
new file mode 100644
index 000000000..f763a52f2
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume/tasks/main.yml
@@ -0,0 +1,289 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: setup 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/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/aliases b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/aliases
new file mode 100644
index 000000000..55ec821a4
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/aliases
@@ -0,0 +1,2 @@
+cloud/hcloud
+shippable/hcloud/group2
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/defaults/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/defaults/main.yml
new file mode 100644
index 000000000..52c468eeb
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/defaults/main.yml
@@ -0,0 +1,5 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+hcloud_prefix: "tests"
+hcloud_volume_name: "{{ hcloud_prefix | truncate(60, True, '', 0) }}-i"
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/meta/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/meta/main.yml
new file mode 100644
index 000000000..407c9018a
--- /dev/null
+++ b/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/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/tasks/main.yml
new file mode 100644
index 000000000..ecea7ad31
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/hcloud_volume_info/tasks/main.yml
@@ -0,0 +1,101 @@
+# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+---
+- name: setup ensure volume is absent
+ hcloud_volume:
+ name: "{{ hcloud_volume_name }}"
+ state: absent
+ register: result
+
+- name: setup volume
+ hcloud_volume:
+ name: "{{hcloud_volume_name}}"
+ size: 10
+ location: "fsn1"
+ labels:
+ key: value
+ register: main_volume
+- name: verify setup volume
+ assert:
+ that:
+ - main_volume is changed
+
+- name: test gather hcloud volume infos in check mode
+ hcloud_volume_info:
+ register: hcloud_volume
+ check_mode: yes
+
+- name: verify test gather hcloud volume infos in check mode
+ vars:
+ volume: "{{ hcloud_volume.hcloud_volume_info|selectattr('name','equalto',hcloud_volume_name) | first }}"
+ assert:
+ that:
+ - hcloud_volume.hcloud_volume_info|selectattr('name','equalto','{{ hcloud_volume_name }}') | list | count == 1
+ - volume.name == "{{hcloud_volume_name}}"
+ - volume.location == "fsn1"
+ - volume.size == 10
+ - volume.linux_device is defined
+
+- name: test gather hcloud volume infos with correct label selector
+ hcloud_volume_info:
+ label_selector: "key=value"
+ register: hcloud_volume
+- name: verify test gather hcloud volume infos with correct label selector
+ assert:
+ that:
+ - hcloud_volume.hcloud_volume_info|selectattr('name','equalto','{{ hcloud_volume_name }}') | list | count == 1
+
+- name: test gather hcloud volume infos with wrong label selector
+ hcloud_volume_info:
+ label_selector: "key!=value"
+ register: hcloud_volume
+- name: verify test gather hcloud volume infos with wrong label selector
+ assert:
+ that:
+ - hcloud_volume.hcloud_volume_info | list | count == 0
+
+- name: test gather hcloud volume infos with correct name
+ hcloud_volume_info:
+ name: "{{hcloud_volume_name}}"
+ register: hcloud_volume
+- name: verify test gather hcloud volume infos with correct name
+ assert:
+ that:
+ - hcloud_volume.hcloud_volume_info|selectattr('name','equalto','{{ hcloud_volume_name }}') | list | count == 1
+
+- name: test gather hcloud volume infos with wrong name
+ hcloud_volume_info:
+ name: "{{hcloud_volume_name}}1"
+ register: hcloud_volume
+- name: verify test gather hcloud volume infos with wrong name
+ assert:
+ that:
+ - hcloud_volume.hcloud_volume_info | list | count == 0
+
+- name: test gather hcloud volume facts with correct id
+ hcloud_volume_info:
+ id: "{{main_volume.hcloud_volume.id}}"
+ register: hcloud_volume
+- name: verify test gather hcloud volume with correct id
+ assert:
+ that:
+ - hcloud_volume.hcloud_volume_info|selectattr('name','equalto','{{ hcloud_volume_name }}') | list | count == 1
+
+- name: test gather hcloud volume infos with wrong id
+ hcloud_volume_info:
+ name: "4711"
+ register: hcloud_volume
+- name: verify test gather hcloud volume infos with wrong id
+ assert:
+ that:
+ - hcloud_volume.hcloud_volume_info | list | count == 0
+
+- name: cleanup
+ hcloud_volume:
+ name: "{{ hcloud_volume_name }}"
+ state: absent
+ register: result
+- name: verify cleanup
+ assert:
+ that:
+ - result is success
diff --git a/ansible_collections/hetzner/hcloud/tests/integration/targets/setup_selfsigned_certificate/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/setup_selfsigned_certificate/tasks/main.yml
new file mode 100644
index 000000000..27defe44c
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/setup_selfsigned_certificate/tasks/main.yml
@@ -0,0 +1,27 @@
+# Copyright: (c) 2020, Hetzner Cloud GmbH <info@hetzner-cloud.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: create 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/ansible_collections/hetzner/hcloud/tests/integration/targets/setup_sshkey/tasks/main.yml b/ansible_collections/hetzner/hcloud/tests/integration/targets/setup_sshkey/tasks/main.yml
new file mode 100644
index 000000000..18c571b67
--- /dev/null
+++ b/ansible_collections/hetzner/hcloud/tests/integration/targets/setup_sshkey/tasks/main.yml
@@ -0,0 +1,55 @@
+# (c) 2014, James Laska <jlaska@ansible.com>
+
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+
+- name: create a temp file
+ tempfile:
+ state: file
+ register: sshkey_file
+ tags:
+ - prepare
+
+- name: generate sshkey
+ shell: echo 'y' | ssh-keygen -P '' -f {{ sshkey_file.path }}
+ tags:
+ - prepare
+
+- name: create another temp file
+ tempfile:
+ state: file
+ register: another_sshkey_file
+ tags:
+ - prepare
+
+- name: generate another_sshkey
+ shell: echo 'y' | ssh-keygen -P '' -f {{ another_sshkey_file.path }}
+ tags:
+ - prepare
+
+- name: record fingerprint
+ shell: openssl rsa -in {{ sshkey_file.path }} -pubout -outform DER 2>/dev/null | openssl md5 -c
+ register: fingerprint
+ tags:
+ - prepare
+
+- name: set facts for future roles
+ set_fact:
+ sshkey: '{{ sshkey_file.path }}'
+ key_material: "{{ lookup('file', sshkey_file.path ~ '.pub') }}"
+ another_key_material: "{{ lookup('file', another_sshkey_file.path ~ '.pub') }}"
+ fingerprint: '{{ fingerprint.stdout.split()[1] }}'
+ tags:
+ - prepare