mirror of
https://github.com/ansible-collections/hetzner.hcloud
synced 2024-11-10 06:34:13 +00:00
test: implement integration testing framework (#239)
Fixes #203 The namespace used to differentiate the resources between CI pipelines, CI stages or even between test targets was broken and resulted in conflicting resource names. This PR ensure the resources names don't collide with each other by making sure we use the entire hcloud_prefix value as md5sum, and by including the target role names inside the resource names. Create a setup/teardown framework to handle testing resources used by the tests. To simplify the review process, additional changes such as splitting the setup/teardown task in the prepare.yml and cleanup.yml files will be done in future PRs (many files were renamed, and git will not preserve the file history after the PR squash). * chore: move integrations targets files * test: create integration common files * test: fix resources name namespace using the magic hcloud_ns * test: simplify requirements install * test: rename hcloud_server test taskfiles
This commit is contained in:
parent
7d8c3f34b5
commit
c5e0d429c5
151 changed files with 5774 additions and 4435 deletions
|
@ -61,3 +61,11 @@ repos:
|
|||
entry: python3 scripts/vendor.py
|
||||
pass_filenames: false
|
||||
files: ^scripts/vendor.py$
|
||||
|
||||
- id: check-integration-test-files
|
||||
name: check integration test files
|
||||
description: Ensure the integration test files are in sync
|
||||
language: system
|
||||
entry: scripts/integration-test-files.sh
|
||||
pass_filenames: false
|
||||
files: ^(scripts/integration-test-files.sh$|tests/integration)
|
||||
|
|
25
scripts/integration-test-files.sh
Executable file
25
scripts/integration-test-files.sh
Executable file
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Sync the integration test files from the template to all the integrations targets.
|
||||
|
||||
integration_targets="tests/integration/targets/hcloud_"
|
||||
integration_common="tests/integration/common"
|
||||
|
||||
# banner
|
||||
banner() {
|
||||
echo "#"
|
||||
echo "# DO NOT EDIT THIS FILE! Please edit the files in $integration_common instead."
|
||||
echo "#"
|
||||
}
|
||||
|
||||
# copy_file <src> <dest>
|
||||
copy_file() {
|
||||
mkdir -p "$(dirname "$2")"
|
||||
banner > "$2"
|
||||
cat "$1" >> "$2"
|
||||
}
|
||||
|
||||
for target in "$integration_targets"*; do
|
||||
copy_file "$integration_common"/defaults/main/common.yml "$target"/defaults/main/common.yml
|
||||
copy_file "$integration_common"/tasks/main.yml "$target"/tasks/main.yml
|
||||
done
|
9
tests/integration/common/defaults/main/common.yml
Normal file
9
tests/integration/common/defaults/main/common.yml
Normal file
|
@ -0,0 +1,9 @@
|
|||
---
|
||||
# Azure Pipelines will configure this value to something similar to
|
||||
# "azp-84824-1-hetzner-2-13-test-2-13-hcloud-3-9-1-default-i"
|
||||
hcloud_prefix: "tests"
|
||||
|
||||
# Used to namespace resources created by concurrent test pipelines/targets
|
||||
hcloud_run_ns: "{{ hcloud_prefix | md5 }}"
|
||||
hcloud_role_ns: "{{ role_name | split('_') | map('first') | join() }}"
|
||||
hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
|
27
tests/integration/common/tasks/main.yml
Normal file
27
tests/integration/common/tasks/main.yml
Normal file
|
@ -0,0 +1,27 @@
|
|||
---
|
||||
- name: Check if cleanup.yml exists
|
||||
stat:
|
||||
path: "{{ role_path }}/tasks/cleanup.yml"
|
||||
register: cleanup_file
|
||||
|
||||
- name: Check if prepare.yml exists
|
||||
stat:
|
||||
path: "{{ role_path }}/tasks/prepare.yml"
|
||||
register: prepare_file
|
||||
|
||||
- name: Include cleanup tasks
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when: cleanup_file.stat.exists
|
||||
|
||||
- name: Include prepare tasks
|
||||
ansible.builtin.include_tasks: prepare.yml
|
||||
when: prepare_file.stat.exists
|
||||
|
||||
- block:
|
||||
- name: Include test tasks
|
||||
ansible.builtin.include_tasks: test.yml
|
||||
|
||||
always:
|
||||
- name: Include cleanup tasks
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when: cleanup_file.stat.exists
|
|
@ -1,6 +0,0 @@
|
|||
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
hcloud_prefix: "tests"
|
||||
hcloud_certificate_name: "{{hcloud_prefix}}-integration"
|
||||
hcloud_dns_test_domain: "{{hcloud_prefix | truncate(19, False, 'ans')}}-{{100 | random }}.hc-certs.de"
|
|
@ -0,0 +1,12 @@
|
|||
#
|
||||
# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead.
|
||||
#
|
||||
---
|
||||
# Azure Pipelines will configure this value to something similar to
|
||||
# "azp-84824-1-hetzner-2-13-test-2-13-hcloud-3-9-1-default-i"
|
||||
hcloud_prefix: "tests"
|
||||
|
||||
# Used to namespace resources created by concurrent test pipelines/targets
|
||||
hcloud_run_ns: "{{ hcloud_prefix | md5 }}"
|
||||
hcloud_role_ns: "{{ role_name | split('_') | map('first') | join() }}"
|
||||
hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
|
|
@ -0,0 +1,5 @@
|
|||
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
hcloud_certificate_name: "{{ hcloud_ns }}"
|
||||
hcloud_dns_test_domain: "{{ hcloud_ns }}-{{ 100 | random }}.hc-certs.de"
|
|
@ -1,155 +1,30 @@
|
|||
# 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)
|
||||
#
|
||||
# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead.
|
||||
#
|
||||
---
|
||||
- name: test missing required parameters on create certificate
|
||||
hetzner.hcloud.hcloud_certificate:
|
||||
name: "{{ hcloud_certificate_name }}"
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- name: verify fail test missing required parameters on create certificate
|
||||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
- 'result.msg == "missing required arguments: certificate, private_key"'
|
||||
- name: Check if cleanup.yml exists
|
||||
stat:
|
||||
path: "{{ role_path }}/tasks/cleanup.yml"
|
||||
register: cleanup_file
|
||||
|
||||
- name: test create certificate with check mode
|
||||
hetzner.hcloud.hcloud_certificate:
|
||||
name: "{{ hcloud_certificate_name }}"
|
||||
certificate: "{{ certificate_example_com }}"
|
||||
private_key: "{{ certificate_example_com_key }}"
|
||||
register: result
|
||||
check_mode: true
|
||||
- name: test create certificate with check mode
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
- name: Check if prepare.yml exists
|
||||
stat:
|
||||
path: "{{ role_path }}/tasks/prepare.yml"
|
||||
register: prepare_file
|
||||
|
||||
- name: test create certificate
|
||||
hetzner.hcloud.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: Include cleanup tasks
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when: cleanup_file.stat.exists
|
||||
|
||||
- name: test create certificate idempotence
|
||||
hetzner.hcloud.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: Include prepare tasks
|
||||
ansible.builtin.include_tasks: prepare.yml
|
||||
when: prepare_file.stat.exists
|
||||
|
||||
- name: test update certificate with check mode
|
||||
hetzner.hcloud.hcloud_certificate:
|
||||
id: "{{ certificate.hcloud_certificate.id }}"
|
||||
name: "changed-{{ hcloud_certificate_name }}"
|
||||
register: result
|
||||
check_mode: true
|
||||
- name: test create certificate with check mode
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
- block:
|
||||
- name: Include test tasks
|
||||
ansible.builtin.include_tasks: test.yml
|
||||
|
||||
- name: test update certificate
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_certificate:
|
||||
id: "{{ result.hcloud_certificate.id }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify absent certificate
|
||||
assert:
|
||||
that:
|
||||
- result is success
|
||||
always:
|
||||
- name: Include cleanup tasks
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when: cleanup_file.stat.exists
|
||||
|
|
155
tests/integration/targets/hcloud_certificate/tasks/test.yml
Normal file
155
tests/integration/targets/hcloud_certificate/tasks/test.yml
Normal file
|
@ -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
|
||||
hetzner.hcloud.hcloud_certificate:
|
||||
name: "{{ hcloud_certificate_name }}"
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- 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
|
||||
hetzner.hcloud.hcloud_certificate:
|
||||
name: "{{ hcloud_certificate_name }}"
|
||||
certificate: "{{ certificate_example_com }}"
|
||||
private_key: "{{ certificate_example_com_key }}"
|
||||
register: result
|
||||
check_mode: true
|
||||
- name: test create certificate with check mode
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: test create certificate
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_certificate:
|
||||
id: "{{ certificate.hcloud_certificate.id }}"
|
||||
name: "changed-{{ hcloud_certificate_name }}"
|
||||
register: result
|
||||
check_mode: true
|
||||
- name: test create certificate with check mode
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: test update certificate
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_certificate:
|
||||
id: "{{ result.hcloud_certificate.id }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify absent certificate
|
||||
assert:
|
||||
that:
|
||||
- result is success
|
|
@ -0,0 +1,12 @@
|
|||
#
|
||||
# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead.
|
||||
#
|
||||
---
|
||||
# Azure Pipelines will configure this value to something similar to
|
||||
# "azp-84824-1-hetzner-2-13-test-2-13-hcloud-3-9-1-default-i"
|
||||
hcloud_prefix: "tests"
|
||||
|
||||
# Used to namespace resources created by concurrent test pipelines/targets
|
||||
hcloud_run_ns: "{{ hcloud_prefix | md5 }}"
|
||||
hcloud_role_ns: "{{ role_name | split('_') | map('first') | join() }}"
|
||||
hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
|
|
@ -1,5 +1,4 @@
|
|||
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
hcloud_prefix: "tests"
|
||||
hcloud_certificate_name: "always-there-cert"
|
|
@ -1,65 +1,30 @@
|
|||
# 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)
|
||||
#
|
||||
# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead.
|
||||
#
|
||||
---
|
||||
- name: create certificate
|
||||
hetzner.hcloud.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: Check if cleanup.yml exists
|
||||
stat:
|
||||
path: "{{ role_path }}/tasks/cleanup.yml"
|
||||
register: cleanup_file
|
||||
|
||||
- name: test gather hcloud certificate infos in check mode
|
||||
hetzner.hcloud.hcloud_certificate_info:
|
||||
register: hcloud_certificate
|
||||
check_mode: true
|
||||
- name: verify test gather hcloud certificate infos in check mode
|
||||
assert:
|
||||
that:
|
||||
- hcloud_certificate.hcloud_certificate_info| list | count >= 1
|
||||
- name: Check if prepare.yml exists
|
||||
stat:
|
||||
path: "{{ role_path }}/tasks/prepare.yml"
|
||||
register: prepare_file
|
||||
|
||||
- name: test gather hcloud certificate infos
|
||||
hetzner.hcloud.hcloud_certificate_info:
|
||||
register: hcloud_certificate
|
||||
check_mode: true
|
||||
- name: verify test gather hcloud certificate infos
|
||||
assert:
|
||||
that:
|
||||
- hcloud_certificate.hcloud_certificate_info| list | count >= 1
|
||||
- name: Include cleanup tasks
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when: cleanup_file.stat.exists
|
||||
|
||||
- name: test gather hcloud certificate infos with correct label selector
|
||||
hetzner.hcloud.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: Include prepare tasks
|
||||
ansible.builtin.include_tasks: prepare.yml
|
||||
when: prepare_file.stat.exists
|
||||
|
||||
- name: test gather hcloud certificate infos with wrong label selector
|
||||
hetzner.hcloud.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
|
||||
- block:
|
||||
- name: Include test tasks
|
||||
ansible.builtin.include_tasks: test.yml
|
||||
|
||||
- name: absent certificate
|
||||
hetzner.hcloud.hcloud_certificate:
|
||||
id: "{{ certificate.hcloud_certificate.id }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify absent certificate
|
||||
assert:
|
||||
that:
|
||||
- result is success
|
||||
always:
|
||||
- name: Include cleanup tasks
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when: cleanup_file.stat.exists
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
# 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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_certificate_info:
|
||||
register: hcloud_certificate
|
||||
check_mode: true
|
||||
- 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
|
||||
hetzner.hcloud.hcloud_certificate_info:
|
||||
register: hcloud_certificate
|
||||
check_mode: true
|
||||
- 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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_certificate:
|
||||
id: "{{ certificate.hcloud_certificate.id }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify absent certificate
|
||||
assert:
|
||||
that:
|
||||
- result is success
|
|
@ -0,0 +1,12 @@
|
|||
#
|
||||
# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead.
|
||||
#
|
||||
---
|
||||
# Azure Pipelines will configure this value to something similar to
|
||||
# "azp-84824-1-hetzner-2-13-test-2-13-hcloud-3-9-1-default-i"
|
||||
hcloud_prefix: "tests"
|
||||
|
||||
# Used to namespace resources created by concurrent test pipelines/targets
|
||||
hcloud_run_ns: "{{ hcloud_prefix | md5 }}"
|
||||
hcloud_role_ns: "{{ role_name | split('_') | map('first') | join() }}"
|
||||
hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
|
|
@ -1,39 +1,30 @@
|
|||
# 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)
|
||||
#
|
||||
# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead.
|
||||
#
|
||||
---
|
||||
- name: test gather hcloud datacenter infos
|
||||
hetzner.hcloud.hcloud_datacenter_info:
|
||||
register: hcloud_datacenters
|
||||
- name: Check if cleanup.yml exists
|
||||
stat:
|
||||
path: "{{ role_path }}/tasks/cleanup.yml"
|
||||
register: cleanup_file
|
||||
|
||||
- name: verify test gather hcloud datacenter infos
|
||||
assert:
|
||||
that:
|
||||
- hcloud_datacenters.hcloud_datacenter_info| list | count >= 5
|
||||
- name: Check if prepare.yml exists
|
||||
stat:
|
||||
path: "{{ role_path }}/tasks/prepare.yml"
|
||||
register: prepare_file
|
||||
|
||||
- name: test gather hcloud datacenter infos in check mode
|
||||
hetzner.hcloud.hcloud_datacenter_info:
|
||||
register: hcloud_datacenters
|
||||
check_mode: true
|
||||
- name: Include cleanup tasks
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when: cleanup_file.stat.exists
|
||||
|
||||
- name: verify test gather hcloud datacenter infos in check mode
|
||||
assert:
|
||||
that:
|
||||
- hcloud_datacenters.hcloud_datacenter_info| list | count >= 5
|
||||
- name: Include prepare tasks
|
||||
ansible.builtin.include_tasks: prepare.yml
|
||||
when: prepare_file.stat.exists
|
||||
|
||||
- name: test gather hcloud datacenter infos with correct name
|
||||
hetzner.hcloud.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
|
||||
- block:
|
||||
- name: Include test tasks
|
||||
ansible.builtin.include_tasks: test.yml
|
||||
|
||||
- name: test gather hcloud datacenter infos with correct id
|
||||
hetzner.hcloud.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
|
||||
always:
|
||||
- name: Include cleanup tasks
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when: cleanup_file.stat.exists
|
||||
|
|
|
@ -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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_datacenter_info:
|
||||
register: hcloud_datacenters
|
||||
check_mode: true
|
||||
|
||||
- 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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
|
@ -0,0 +1,12 @@
|
|||
#
|
||||
# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead.
|
||||
#
|
||||
---
|
||||
# Azure Pipelines will configure this value to something similar to
|
||||
# "azp-84824-1-hetzner-2-13-test-2-13-hcloud-3-9-1-default-i"
|
||||
hcloud_prefix: "tests"
|
||||
|
||||
# Used to namespace resources created by concurrent test pipelines/targets
|
||||
hcloud_run_ns: "{{ hcloud_prefix | md5 }}"
|
||||
hcloud_role_ns: "{{ role_name | split('_') | map('first') | join() }}"
|
||||
hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
|
|
@ -1,5 +1,4 @@
|
|||
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
hcloud_prefix: "tests"
|
||||
hcloud_ssh_key_name: "{{hcloud_prefix}}-f"
|
||||
hcloud_firewall_name: "{{ hcloud_ns }}"
|
|
@ -1,210 +1,30 @@
|
|||
# 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)
|
||||
#
|
||||
# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead.
|
||||
#
|
||||
---
|
||||
- name: setup firewall to be absent
|
||||
hetzner.hcloud.hcloud_firewall:
|
||||
name: "{{ hcloud_firewall_name }}"
|
||||
state: absent
|
||||
- name: Check if cleanup.yml exists
|
||||
stat:
|
||||
path: "{{ role_path }}/tasks/cleanup.yml"
|
||||
register: cleanup_file
|
||||
|
||||
- name: test missing required parameters on create firewall
|
||||
hetzner.hcloud.hcloud_firewall:
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- 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: Check if prepare.yml exists
|
||||
stat:
|
||||
path: "{{ role_path }}/tasks/prepare.yml"
|
||||
register: prepare_file
|
||||
|
||||
- name: test create firewall with check mode
|
||||
hetzner.hcloud.hcloud_firewall:
|
||||
name: "{{ hcloud_firewall_name }}"
|
||||
register: result
|
||||
check_mode: true
|
||||
- name: test create firewall with check mode
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
- name: Include cleanup tasks
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when: cleanup_file.stat.exists
|
||||
|
||||
- name: test create firewall
|
||||
hetzner.hcloud.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: Include prepare tasks
|
||||
ansible.builtin.include_tasks: prepare.yml
|
||||
when: prepare_file.stat.exists
|
||||
|
||||
- name: test create firewall idempotence
|
||||
hetzner.hcloud.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
|
||||
- block:
|
||||
- name: Include test tasks
|
||||
ansible.builtin.include_tasks: test.yml
|
||||
|
||||
- name: test update firewall rules
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_firewall:
|
||||
id: "{{ firewall.hcloud_firewall.id }}"
|
||||
name: "changed-{{ hcloud_firewall_name }}"
|
||||
register: result
|
||||
check_mode: true
|
||||
- name: test create firewall with check mode
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: test update firewall
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_firewall:
|
||||
id: "{{ firewall.hcloud_firewall.id }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify absent server
|
||||
assert:
|
||||
that:
|
||||
- result is success
|
||||
always:
|
||||
- name: Include cleanup tasks
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when: cleanup_file.stat.exists
|
||||
|
|
210
tests/integration/targets/hcloud_firewall/tasks/test.yml
Normal file
210
tests/integration/targets/hcloud_firewall/tasks/test.yml
Normal file
|
@ -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
|
||||
hetzner.hcloud.hcloud_firewall:
|
||||
name: "{{ hcloud_firewall_name }}"
|
||||
state: absent
|
||||
|
||||
- name: test missing required parameters on create firewall
|
||||
hetzner.hcloud.hcloud_firewall:
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- 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
|
||||
hetzner.hcloud.hcloud_firewall:
|
||||
name: "{{ hcloud_firewall_name }}"
|
||||
register: result
|
||||
check_mode: true
|
||||
- name: test create firewall with check mode
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: test create firewall
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_firewall:
|
||||
id: "{{ firewall.hcloud_firewall.id }}"
|
||||
name: "changed-{{ hcloud_firewall_name }}"
|
||||
register: result
|
||||
check_mode: true
|
||||
- name: test create firewall with check mode
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: test update firewall
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_firewall:
|
||||
id: "{{ firewall.hcloud_firewall.id }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify absent server
|
||||
assert:
|
||||
that:
|
||||
- result is success
|
|
@ -0,0 +1,12 @@
|
|||
#
|
||||
# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead.
|
||||
#
|
||||
---
|
||||
# Azure Pipelines will configure this value to something similar to
|
||||
# "azp-84824-1-hetzner-2-13-test-2-13-hcloud-3-9-1-default-i"
|
||||
hcloud_prefix: "tests"
|
||||
|
||||
# Used to namespace resources created by concurrent test pipelines/targets
|
||||
hcloud_run_ns: "{{ hcloud_prefix | md5 }}"
|
||||
hcloud_role_ns: "{{ role_name | split('_') | map('first') | join() }}"
|
||||
hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
|
|
@ -0,0 +1,5 @@
|
|||
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
hcloud_floating_ip_name: "{{ hcloud_ns }}"
|
||||
hcloud_server_name: "{{ hcloud_ns }}"
|
|
@ -1,484 +1,30 @@
|
|||
# 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)
|
||||
#
|
||||
# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead.
|
||||
#
|
||||
---
|
||||
- name: setup ensure server is absent
|
||||
hetzner.hcloud.hcloud_server:
|
||||
name: "{{ hcloud_server_name }}"
|
||||
state: absent
|
||||
- name: Check if cleanup.yml exists
|
||||
stat:
|
||||
path: "{{ role_path }}/tasks/cleanup.yml"
|
||||
register: cleanup_file
|
||||
|
||||
- name: setup ensure another server is absent
|
||||
hetzner.hcloud.hcloud_server:
|
||||
name: "{{ hcloud_server_name }}2"
|
||||
state: absent
|
||||
- name: Check if prepare.yml exists
|
||||
stat:
|
||||
path: "{{ role_path }}/tasks/prepare.yml"
|
||||
register: prepare_file
|
||||
|
||||
- name: setup ensure floating ip is absent
|
||||
hetzner.hcloud.hcloud_floating_ip:
|
||||
name: "{{ hcloud_floating_ip_name }}"
|
||||
state: absent
|
||||
- name: Include cleanup tasks
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when: cleanup_file.stat.exists
|
||||
|
||||
- name: setup server
|
||||
hetzner.hcloud.hcloud_server:
|
||||
name: "{{ hcloud_server_name }}"
|
||||
server_type: cx11
|
||||
image: ubuntu-22.04
|
||||
state: started
|
||||
location: "fsn1"
|
||||
register: main_server
|
||||
- name: verify setup server
|
||||
assert:
|
||||
that:
|
||||
- main_server is changed
|
||||
- name: Include prepare tasks
|
||||
ansible.builtin.include_tasks: prepare.yml
|
||||
when: prepare_file.stat.exists
|
||||
|
||||
- name: setup another server
|
||||
hetzner.hcloud.hcloud_server:
|
||||
name: "{{ hcloud_server_name }}2"
|
||||
server_type: cx11
|
||||
image: ubuntu-22.04
|
||||
state: started
|
||||
register: main_server2
|
||||
- name: verify setup another server
|
||||
assert:
|
||||
that:
|
||||
- main_server2 is changed
|
||||
- block:
|
||||
- name: Include test tasks
|
||||
ansible.builtin.include_tasks: test.yml
|
||||
|
||||
- name: test missing type parameter on create Floating IP
|
||||
hetzner.hcloud.hcloud_floating_ip:
|
||||
name: "{{ hcloud_floating_ip_name }}"
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- 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
|
||||
hetzner.hcloud.hcloud_floating_ip:
|
||||
name: "{{ hcloud_floating_ip_name }}"
|
||||
type: ipv4
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- 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
|
||||
hetzner.hcloud.hcloud_floating_ip:
|
||||
type: ipv4
|
||||
home_location: "fsn1"
|
||||
state: "absent"
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- name: verify fail test missing type parameter on delete Floating IP
|
||||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
- 'result.msg == "one of the following is required: id, name"'
|
||||
|
||||
- name: test invalid type
|
||||
hetzner.hcloud.hcloud_floating_ip:
|
||||
name: "{{ hcloud_floating_ip_name }}"
|
||||
type: ipv5
|
||||
home_location: "fsn1"
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- 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
|
||||
hetzner.hcloud.hcloud_floating_ip:
|
||||
name: "{{ hcloud_floating_ip_name }}"
|
||||
type: ipv4
|
||||
home_location: "abc"
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- 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
|
||||
hetzner.hcloud.hcloud_floating_ip:
|
||||
name: "{{ hcloud_floating_ip_name }}"
|
||||
description: "Web Server"
|
||||
type: ipv4
|
||||
home_location: "fsn1"
|
||||
register: floatingIP
|
||||
check_mode: true
|
||||
- name: verify test create Floating IP with check mode
|
||||
assert:
|
||||
that:
|
||||
- floatingIP is changed
|
||||
|
||||
- name: test create Floating IP
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_floating_ip:
|
||||
name: "{{ hcloud_floating_ip_name }}"
|
||||
description: "changed-description"
|
||||
type: ipv4
|
||||
home_location: "fsn1"
|
||||
check_mode: true
|
||||
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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_floating_ip:
|
||||
name: "{{ hcloud_floating_ip_name }}"
|
||||
description: "changed-description"
|
||||
type: ipv4
|
||||
server: "{{ main_server.hcloud_server.name }}"
|
||||
check_mode: true
|
||||
register: floatingIP
|
||||
- name: verify test assign Floating IP with checkmode
|
||||
assert:
|
||||
that:
|
||||
- floatingIP is changed
|
||||
- floatingIP.hcloud_floating_ip.server != "{{ main_server.hcloud_server.name }}"
|
||||
|
||||
- name: test assign Floating IP
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_floating_ip:
|
||||
name: "{{ hcloud_floating_ip_name }}"
|
||||
type: ipv4
|
||||
force: true
|
||||
server: "{{ main_server2.hcloud_server.name }}"
|
||||
register: floatingIP
|
||||
- name: verify test already assigned Floating IP assign with force
|
||||
assert:
|
||||
that:
|
||||
- floatingIP is changed
|
||||
- floatingIP.hcloud_floating_ip.server == "{{ main_server2.hcloud_server.name }}"
|
||||
|
||||
- name: test update Floating IP delete protection
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_floating_ip:
|
||||
name: "{{ hcloud_floating_ip_name }}"
|
||||
state: "absent"
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- 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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_server:
|
||||
name: "{{ hcloud_server_name }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify cleanup
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
- name: cleanup another server
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_floating_ip:
|
||||
name: "{{ hcloud_floating_ip_name }}"
|
||||
state: "absent"
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- 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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_floating_ip:
|
||||
name: "{{ hcloud_floating_ip_name }}"
|
||||
state: "absent"
|
||||
register: result
|
||||
- name: verify test delete floating ip
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
always:
|
||||
- name: Include cleanup tasks
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when: cleanup_file.stat.exists
|
||||
|
|
484
tests/integration/targets/hcloud_floating_ip/tasks/test.yml
Normal file
484
tests/integration/targets/hcloud_floating_ip/tasks/test.yml
Normal file
|
@ -0,0 +1,484 @@
|
|||
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
- name: setup ensure server is absent
|
||||
hetzner.hcloud.hcloud_server:
|
||||
name: "{{ hcloud_server_name }}"
|
||||
state: absent
|
||||
|
||||
- name: setup ensure another server is absent
|
||||
hetzner.hcloud.hcloud_server:
|
||||
name: "{{ hcloud_server_name }}2"
|
||||
state: absent
|
||||
|
||||
- name: setup ensure floating ip is absent
|
||||
hetzner.hcloud.hcloud_floating_ip:
|
||||
name: "{{ hcloud_floating_ip_name }}"
|
||||
state: absent
|
||||
|
||||
- name: setup server
|
||||
hetzner.hcloud.hcloud_server:
|
||||
name: "{{ hcloud_server_name }}"
|
||||
server_type: cx11
|
||||
image: ubuntu-22.04
|
||||
state: started
|
||||
location: "fsn1"
|
||||
register: main_server
|
||||
- name: verify setup server
|
||||
assert:
|
||||
that:
|
||||
- main_server is changed
|
||||
|
||||
- name: setup another server
|
||||
hetzner.hcloud.hcloud_server:
|
||||
name: "{{ hcloud_server_name }}2"
|
||||
server_type: cx11
|
||||
image: ubuntu-22.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
|
||||
hetzner.hcloud.hcloud_floating_ip:
|
||||
name: "{{ hcloud_floating_ip_name }}"
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- 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
|
||||
hetzner.hcloud.hcloud_floating_ip:
|
||||
name: "{{ hcloud_floating_ip_name }}"
|
||||
type: ipv4
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- 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
|
||||
hetzner.hcloud.hcloud_floating_ip:
|
||||
type: ipv4
|
||||
home_location: "fsn1"
|
||||
state: "absent"
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- name: verify fail test missing type parameter on delete Floating IP
|
||||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
- 'result.msg == "one of the following is required: id, name"'
|
||||
|
||||
- name: test invalid type
|
||||
hetzner.hcloud.hcloud_floating_ip:
|
||||
name: "{{ hcloud_floating_ip_name }}"
|
||||
type: ipv5
|
||||
home_location: "fsn1"
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- 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
|
||||
hetzner.hcloud.hcloud_floating_ip:
|
||||
name: "{{ hcloud_floating_ip_name }}"
|
||||
type: ipv4
|
||||
home_location: "abc"
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- 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
|
||||
hetzner.hcloud.hcloud_floating_ip:
|
||||
name: "{{ hcloud_floating_ip_name }}"
|
||||
description: "Web Server"
|
||||
type: ipv4
|
||||
home_location: "fsn1"
|
||||
register: floatingIP
|
||||
check_mode: true
|
||||
- name: verify test create Floating IP with check mode
|
||||
assert:
|
||||
that:
|
||||
- floatingIP is changed
|
||||
|
||||
- name: test create Floating IP
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_floating_ip:
|
||||
name: "{{ hcloud_floating_ip_name }}"
|
||||
description: "changed-description"
|
||||
type: ipv4
|
||||
home_location: "fsn1"
|
||||
check_mode: true
|
||||
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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_floating_ip:
|
||||
name: "{{ hcloud_floating_ip_name }}"
|
||||
description: "changed-description"
|
||||
type: ipv4
|
||||
server: "{{ main_server.hcloud_server.name }}"
|
||||
check_mode: true
|
||||
register: floatingIP
|
||||
- name: verify test assign Floating IP with checkmode
|
||||
assert:
|
||||
that:
|
||||
- floatingIP is changed
|
||||
- floatingIP.hcloud_floating_ip.server != "{{ main_server.hcloud_server.name }}"
|
||||
|
||||
- name: test assign Floating IP
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_floating_ip:
|
||||
name: "{{ hcloud_floating_ip_name }}"
|
||||
type: ipv4
|
||||
force: true
|
||||
server: "{{ main_server2.hcloud_server.name }}"
|
||||
register: floatingIP
|
||||
- name: verify test already assigned Floating IP assign with force
|
||||
assert:
|
||||
that:
|
||||
- floatingIP is changed
|
||||
- floatingIP.hcloud_floating_ip.server == "{{ main_server2.hcloud_server.name }}"
|
||||
|
||||
- name: test update Floating IP delete protection
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_floating_ip:
|
||||
name: "{{ hcloud_floating_ip_name }}"
|
||||
state: "absent"
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- 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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_server:
|
||||
name: "{{ hcloud_server_name }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify cleanup
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
- name: cleanup another server
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_floating_ip:
|
||||
name: "{{ hcloud_floating_ip_name }}"
|
||||
state: "absent"
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- 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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_floating_ip:
|
||||
name: "{{ hcloud_floating_ip_name }}"
|
||||
state: "absent"
|
||||
register: result
|
||||
- name: verify test delete floating ip
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
|
@ -0,0 +1,12 @@
|
|||
#
|
||||
# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead.
|
||||
#
|
||||
---
|
||||
# Azure Pipelines will configure this value to something similar to
|
||||
# "azp-84824-1-hetzner-2-13-test-2-13-hcloud-3-9-1-default-i"
|
||||
hcloud_prefix: "tests"
|
||||
|
||||
# Used to namespace resources created by concurrent test pipelines/targets
|
||||
hcloud_run_ns: "{{ hcloud_prefix | md5 }}"
|
||||
hcloud_role_ns: "{{ role_name | split('_') | map('first') | join() }}"
|
||||
hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
|
|
@ -1,5 +1,4 @@
|
|||
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
hcloud_prefix: "tests"
|
||||
hcloud_network_name: "{{hcloud_prefix}}-ro"
|
||||
hcloud_floating_ip_name: "{{ hcloud_ns }}"
|
|
@ -1,86 +1,30 @@
|
|||
# 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)
|
||||
#
|
||||
# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead.
|
||||
#
|
||||
---
|
||||
- name: setup ensure floating ip is absent
|
||||
hetzner.hcloud.hcloud_floating_ip:
|
||||
name: "{{ hcloud_floating_ip_name }}"
|
||||
state: absent
|
||||
- name: Check if cleanup.yml exists
|
||||
stat:
|
||||
path: "{{ role_path }}/tasks/cleanup.yml"
|
||||
register: cleanup_file
|
||||
|
||||
- name: setup floating ip
|
||||
hetzner.hcloud.hcloud_floating_ip:
|
||||
name: "{{ hcloud_floating_ip_name }}"
|
||||
home_location: "fsn1"
|
||||
type: ipv4
|
||||
labels:
|
||||
key: value
|
||||
register: test_floating_ip
|
||||
- name: Check if prepare.yml exists
|
||||
stat:
|
||||
path: "{{ role_path }}/tasks/prepare.yml"
|
||||
register: prepare_file
|
||||
|
||||
- name: verify setup floating ip
|
||||
assert:
|
||||
that:
|
||||
- test_floating_ip is changed
|
||||
- name: Include cleanup tasks
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when: cleanup_file.stat.exists
|
||||
|
||||
- name: test gather hcloud floating ip infos
|
||||
hetzner.hcloud.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: Include prepare tasks
|
||||
ansible.builtin.include_tasks: prepare.yml
|
||||
when: prepare_file.stat.exists
|
||||
|
||||
- name: test gather hcloud floating ip infos in check mode
|
||||
hetzner.hcloud.hcloud_floating_ip_info:
|
||||
check_mode: true
|
||||
register: hcloud_floating_ips
|
||||
- block:
|
||||
- name: Include test tasks
|
||||
ansible.builtin.include_tasks: test.yml
|
||||
|
||||
- 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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_floating_ip_info:
|
||||
id: "{{test_floating_ip.hcloud_floating_ip.id}}1"
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- name: verify test gather hcloud floating ip with wrong id
|
||||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
|
||||
- name: cleanup
|
||||
hetzner.hcloud.hcloud_floating_ip:
|
||||
id: "{{ test_floating_ip.hcloud_floating_ip.id }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify cleanup
|
||||
assert:
|
||||
that:
|
||||
- result is success
|
||||
always:
|
||||
- name: Include cleanup tasks
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when: cleanup_file.stat.exists
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
- name: setup ensure floating ip is absent
|
||||
hetzner.hcloud.hcloud_floating_ip:
|
||||
name: "{{ hcloud_floating_ip_name }}"
|
||||
state: absent
|
||||
|
||||
- name: setup floating ip
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_floating_ip_info:
|
||||
check_mode: true
|
||||
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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_floating_ip_info:
|
||||
id: "{{test_floating_ip.hcloud_floating_ip.id}}1"
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- name: verify test gather hcloud floating ip with wrong id
|
||||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
|
||||
- name: cleanup
|
||||
hetzner.hcloud.hcloud_floating_ip:
|
||||
id: "{{ test_floating_ip.hcloud_floating_ip.id }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify cleanup
|
||||
assert:
|
||||
that:
|
||||
- result is success
|
|
@ -0,0 +1,12 @@
|
|||
#
|
||||
# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead.
|
||||
#
|
||||
---
|
||||
# Azure Pipelines will configure this value to something similar to
|
||||
# "azp-84824-1-hetzner-2-13-test-2-13-hcloud-3-9-1-default-i"
|
||||
hcloud_prefix: "tests"
|
||||
|
||||
# Used to namespace resources created by concurrent test pipelines/targets
|
||||
hcloud_run_ns: "{{ hcloud_prefix | md5 }}"
|
||||
hcloud_role_ns: "{{ role_name | split('_') | map('first') | join() }}"
|
||||
hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
|
|
@ -1,7 +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_test_image_name: "always-there-snapshot"
|
||||
hcloud_test_image_id: 10164049
|
||||
hcloud_test_image_name_os: "ubuntu-22.04"
|
|
@ -1,92 +1,30 @@
|
|||
# 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)
|
||||
#
|
||||
# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead.
|
||||
#
|
||||
---
|
||||
- name: test gather hcloud image infos with type system
|
||||
hetzner.hcloud.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: Check if cleanup.yml exists
|
||||
stat:
|
||||
path: "{{ role_path }}/tasks/cleanup.yml"
|
||||
register: cleanup_file
|
||||
|
||||
- name: test gather hcloud image infos in check mode
|
||||
hetzner.hcloud.hcloud_image_info:
|
||||
check_mode: true
|
||||
register: hcloud_images
|
||||
- name: Check if prepare.yml exists
|
||||
stat:
|
||||
path: "{{ role_path }}/tasks/prepare.yml"
|
||||
register: prepare_file
|
||||
|
||||
- name: verify test gather hcloud image infos in check mode
|
||||
assert:
|
||||
that:
|
||||
- hcloud_images.hcloud_image_info| list | count > 2
|
||||
- name: Include cleanup tasks
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when: cleanup_file.stat.exists
|
||||
|
||||
- name: test gather hcloud image infos with correct label selector
|
||||
hetzner.hcloud.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: Include prepare tasks
|
||||
ansible.builtin.include_tasks: prepare.yml
|
||||
when: prepare_file.stat.exists
|
||||
|
||||
- name: test gather hcloud image infos with wrong label selector
|
||||
hetzner.hcloud.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
|
||||
- block:
|
||||
- name: Include test tasks
|
||||
ansible.builtin.include_tasks: test.yml
|
||||
|
||||
- name: test gather hcloud image infos with correct id
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_image_info:
|
||||
id: "{{hcloud_test_image_id}}1"
|
||||
type: snapshot
|
||||
ignore_errors: true
|
||||
register: result
|
||||
- name: verify test gather hcloud image with wrong id
|
||||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
|
||||
- name: test gather hcloud image infos with name
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
always:
|
||||
- name: Include cleanup tasks
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when: cleanup_file.stat.exists
|
||||
|
|
92
tests/integration/targets/hcloud_image_info/tasks/test.yml
Normal file
92
tests/integration/targets/hcloud_image_info/tasks/test.yml
Normal file
|
@ -0,0 +1,92 @@
|
|||
# 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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_image_info:
|
||||
check_mode: true
|
||||
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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_image_info:
|
||||
id: "{{hcloud_test_image_id}}1"
|
||||
type: snapshot
|
||||
ignore_errors: true
|
||||
register: result
|
||||
- name: verify test gather hcloud image with wrong id
|
||||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
|
||||
- name: test gather hcloud image infos with name
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
|
@ -0,0 +1,12 @@
|
|||
#
|
||||
# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead.
|
||||
#
|
||||
---
|
||||
# Azure Pipelines will configure this value to something similar to
|
||||
# "azp-84824-1-hetzner-2-13-test-2-13-hcloud-3-9-1-default-i"
|
||||
hcloud_prefix: "tests"
|
||||
|
||||
# Used to namespace resources created by concurrent test pipelines/targets
|
||||
hcloud_run_ns: "{{ hcloud_prefix | md5 }}"
|
||||
hcloud_role_ns: "{{ role_name | split('_') | map('first') | join() }}"
|
||||
hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
|
|
@ -1,7 +1,6 @@
|
|||
# Copyright: (c) 2023, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
hcloud_prefix: "tests"
|
||||
hcloud_iso_id: 551
|
||||
hcloud_iso_name: systemrescuecd-x86-5.2.2.iso
|
||||
hcloud_iso_type: public
|
|
@ -1,54 +1,30 @@
|
|||
# Copyright: (c) 2023, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
#
|
||||
# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead.
|
||||
#
|
||||
---
|
||||
- name: test gather hcloud iso infos with correct id
|
||||
hetzner.hcloud.hcloud_iso_info:
|
||||
id: "{{ hcloud_iso_id }}"
|
||||
register: hcloud_iso
|
||||
- name: verify test gather hcloud image with correct id
|
||||
assert:
|
||||
that:
|
||||
- hcloud_iso.hcloud_iso_info | list | count == 1
|
||||
- hcloud_iso.hcloud_iso_info[0].id == "{{ hcloud_iso_id }}"
|
||||
- hcloud_iso.hcloud_iso_info[0].name == "{{ hcloud_iso_name }}"
|
||||
- hcloud_iso.hcloud_iso_info[0].architecture == "{{ hcloud_iso_architecture }}"
|
||||
- hcloud_iso.hcloud_iso_info[0].type == "{{ hcloud_iso_type }}"
|
||||
- name: Check if cleanup.yml exists
|
||||
stat:
|
||||
path: "{{ role_path }}/tasks/cleanup.yml"
|
||||
register: cleanup_file
|
||||
|
||||
- name: test gather hcloud iso infos with wrong id
|
||||
hetzner.hcloud.hcloud_iso_info:
|
||||
id: "{{ hcloud_iso_id }}1"
|
||||
ignore_errors: true
|
||||
register: result
|
||||
- name: verify test gather hcloud image with wrong id
|
||||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
- name: Check if prepare.yml exists
|
||||
stat:
|
||||
path: "{{ role_path }}/tasks/prepare.yml"
|
||||
register: prepare_file
|
||||
|
||||
- name: test gather hcloud iso infos with name
|
||||
hetzner.hcloud.hcloud_iso_info:
|
||||
name: "{{ hcloud_iso_name }}"
|
||||
register: hcloud_iso
|
||||
- name: verify test gather hcloud iso infos with name
|
||||
assert:
|
||||
that:
|
||||
- hcloud_iso.hcloud_iso_info | list | count == 1
|
||||
- name: Include cleanup tasks
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when: cleanup_file.stat.exists
|
||||
|
||||
- name: test list hcloud iso infos with architecture
|
||||
hetzner.hcloud.hcloud_iso_info:
|
||||
architecture: arm
|
||||
register: hcloud_iso
|
||||
- name: verify test list hcloud iso infos with architecture
|
||||
assert:
|
||||
that:
|
||||
- hcloud_iso.hcloud_iso_info | list | count > 2
|
||||
- hcloud_iso.hcloud_iso_info | selectattr('architecture','equalto','x86') | list | count == 0
|
||||
- hcloud_iso.hcloud_iso_info | selectattr('architecture','equalto','arm') | list | count > 2
|
||||
- name: Include prepare tasks
|
||||
ansible.builtin.include_tasks: prepare.yml
|
||||
when: prepare_file.stat.exists
|
||||
|
||||
- name: test list hcloud iso infos in check mode
|
||||
hetzner.hcloud.hcloud_iso_info:
|
||||
check_mode: true
|
||||
register: hcloud_iso
|
||||
- name: verify test list hcloud iso infos in check mode
|
||||
assert:
|
||||
that:
|
||||
- hcloud_iso.hcloud_iso_info| list | count > 2
|
||||
- block:
|
||||
- name: Include test tasks
|
||||
ansible.builtin.include_tasks: test.yml
|
||||
|
||||
always:
|
||||
- name: Include cleanup tasks
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when: cleanup_file.stat.exists
|
||||
|
|
54
tests/integration/targets/hcloud_iso_info/tasks/test.yml
Normal file
54
tests/integration/targets/hcloud_iso_info/tasks/test.yml
Normal file
|
@ -0,0 +1,54 @@
|
|||
# Copyright: (c) 2023, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
- name: test gather hcloud iso infos with correct id
|
||||
hetzner.hcloud.hcloud_iso_info:
|
||||
id: "{{ hcloud_iso_id }}"
|
||||
register: hcloud_iso
|
||||
- name: verify test gather hcloud image with correct id
|
||||
assert:
|
||||
that:
|
||||
- hcloud_iso.hcloud_iso_info | list | count == 1
|
||||
- hcloud_iso.hcloud_iso_info[0].id == "{{ hcloud_iso_id }}"
|
||||
- hcloud_iso.hcloud_iso_info[0].name == "{{ hcloud_iso_name }}"
|
||||
- hcloud_iso.hcloud_iso_info[0].architecture == "{{ hcloud_iso_architecture }}"
|
||||
- hcloud_iso.hcloud_iso_info[0].type == "{{ hcloud_iso_type }}"
|
||||
|
||||
- name: test gather hcloud iso infos with wrong id
|
||||
hetzner.hcloud.hcloud_iso_info:
|
||||
id: "{{ hcloud_iso_id }}1"
|
||||
ignore_errors: true
|
||||
register: result
|
||||
- name: verify test gather hcloud image with wrong id
|
||||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
|
||||
- name: test gather hcloud iso infos with name
|
||||
hetzner.hcloud.hcloud_iso_info:
|
||||
name: "{{ hcloud_iso_name }}"
|
||||
register: hcloud_iso
|
||||
- name: verify test gather hcloud iso infos with name
|
||||
assert:
|
||||
that:
|
||||
- hcloud_iso.hcloud_iso_info | list | count == 1
|
||||
|
||||
- name: test list hcloud iso infos with architecture
|
||||
hetzner.hcloud.hcloud_iso_info:
|
||||
architecture: arm
|
||||
register: hcloud_iso
|
||||
- name: verify test list hcloud iso infos with architecture
|
||||
assert:
|
||||
that:
|
||||
- hcloud_iso.hcloud_iso_info | list | count > 2
|
||||
- hcloud_iso.hcloud_iso_info | selectattr('architecture','equalto','x86') | list | count == 0
|
||||
- hcloud_iso.hcloud_iso_info | selectattr('architecture','equalto','arm') | list | count > 2
|
||||
|
||||
- name: test list hcloud iso infos in check mode
|
||||
hetzner.hcloud.hcloud_iso_info:
|
||||
check_mode: true
|
||||
register: hcloud_iso
|
||||
- name: verify test list hcloud iso infos in check mode
|
||||
assert:
|
||||
that:
|
||||
- hcloud_iso.hcloud_iso_info| list | count > 2
|
|
@ -0,0 +1,12 @@
|
|||
#
|
||||
# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead.
|
||||
#
|
||||
---
|
||||
# Azure Pipelines will configure this value to something similar to
|
||||
# "azp-84824-1-hetzner-2-13-test-2-13-hcloud-3-9-1-default-i"
|
||||
hcloud_prefix: "tests"
|
||||
|
||||
# Used to namespace resources created by concurrent test pipelines/targets
|
||||
hcloud_run_ns: "{{ hcloud_prefix | md5 }}"
|
||||
hcloud_role_ns: "{{ role_name | split('_') | map('first') | join() }}"
|
||||
hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
|
|
@ -1,5 +1,4 @@
|
|||
# Copyright: (c) 2020, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
hcloud_prefix: "tests"
|
||||
hcloud_load_balancer_name: "{{hcloud_prefix}}-i"
|
||||
hcloud_load_balancer_name: "{{ hcloud_ns }}"
|
|
@ -1,247 +1,30 @@
|
|||
# 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)
|
||||
#
|
||||
# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead.
|
||||
#
|
||||
---
|
||||
- name: setup
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_load_balancer:
|
||||
name: "{{ hcloud_load_balancer_name }}"
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- 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: Check if cleanup.yml exists
|
||||
stat:
|
||||
path: "{{ role_path }}/tasks/cleanup.yml"
|
||||
register: cleanup_file
|
||||
|
||||
- name: test create Load Balancer with check mode
|
||||
hetzner.hcloud.hcloud_load_balancer:
|
||||
name: "{{ hcloud_load_balancer_name }}"
|
||||
load_balancer_type: lb11
|
||||
network_zone: eu-central
|
||||
state: present
|
||||
register: result
|
||||
check_mode: true
|
||||
- name: test create Load Balancer with check mode
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
- name: Check if prepare.yml exists
|
||||
stat:
|
||||
path: "{{ role_path }}/tasks/prepare.yml"
|
||||
register: prepare_file
|
||||
|
||||
- name: test create Load Balancer
|
||||
hetzner.hcloud.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: Include cleanup tasks
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when: cleanup_file.stat.exists
|
||||
|
||||
- name: test create Load Balancer idempotence
|
||||
hetzner.hcloud.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: Include prepare tasks
|
||||
ansible.builtin.include_tasks: prepare.yml
|
||||
when: prepare_file.stat.exists
|
||||
|
||||
- name: test change Load Balancer type
|
||||
hetzner.hcloud.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"
|
||||
- block:
|
||||
- name: Include test tasks
|
||||
ansible.builtin.include_tasks: test.yml
|
||||
|
||||
- name: test Load Balancer without type set to be idempotent
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_load_balancer:
|
||||
name: "{{hcloud_load_balancer_name}}"
|
||||
state: absent
|
||||
ignore_errors: true
|
||||
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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_load_balancer:
|
||||
name: "{{ hcloud_load_balancer_name }}"
|
||||
state: "absent"
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- 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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_load_balancer:
|
||||
name: "{{ hcloud_load_balancer_name }}"
|
||||
state: "absent"
|
||||
register: result
|
||||
- name: verify test delete Load Balancer
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
always:
|
||||
- name: Include cleanup tasks
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when: cleanup_file.stat.exists
|
||||
|
|
247
tests/integration/targets/hcloud_load_balancer/tasks/test.yml
Normal file
247
tests/integration/targets/hcloud_load_balancer/tasks/test.yml
Normal file
|
@ -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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_load_balancer:
|
||||
name: "{{ hcloud_load_balancer_name }}"
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- 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
|
||||
hetzner.hcloud.hcloud_load_balancer:
|
||||
name: "{{ hcloud_load_balancer_name }}"
|
||||
load_balancer_type: lb11
|
||||
network_zone: eu-central
|
||||
state: present
|
||||
register: result
|
||||
check_mode: true
|
||||
- name: test create Load Balancer with check mode
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: test create Load Balancer
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_load_balancer:
|
||||
name: "{{hcloud_load_balancer_name}}"
|
||||
state: absent
|
||||
ignore_errors: true
|
||||
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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_load_balancer:
|
||||
name: "{{ hcloud_load_balancer_name }}"
|
||||
state: "absent"
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- 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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_load_balancer:
|
||||
name: "{{ hcloud_load_balancer_name }}"
|
||||
state: "absent"
|
||||
register: result
|
||||
- name: verify test delete Load Balancer
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
|
@ -1,6 +0,0 @@
|
|||
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
hcloud_prefix: "tests"
|
||||
hcloud_load_balancer_name: "{{hcloud_prefix}}-i"
|
||||
hcloud_server_name: "{{ hcloud_prefix | truncate(45, True, '', 0) }}-lb-i"
|
|
@ -0,0 +1,12 @@
|
|||
#
|
||||
# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead.
|
||||
#
|
||||
---
|
||||
# Azure Pipelines will configure this value to something similar to
|
||||
# "azp-84824-1-hetzner-2-13-test-2-13-hcloud-3-9-1-default-i"
|
||||
hcloud_prefix: "tests"
|
||||
|
||||
# Used to namespace resources created by concurrent test pipelines/targets
|
||||
hcloud_run_ns: "{{ hcloud_prefix | md5 }}"
|
||||
hcloud_role_ns: "{{ role_name | split('_') | map('first') | join() }}"
|
||||
hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
|
|
@ -0,0 +1,5 @@
|
|||
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
hcloud_load_balancer_name: "{{ hcloud_ns }}"
|
||||
hcloud_server_name: "{{ hcloud_ns }}"
|
|
@ -1,127 +1,30 @@
|
|||
# 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)
|
||||
#
|
||||
# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead.
|
||||
#
|
||||
---
|
||||
- name: setup ensure Load Balancer is absent
|
||||
hetzner.hcloud.hcloud_load_balancer:
|
||||
name: "{{ hcloud_load_balancer_name }}"
|
||||
state: absent
|
||||
- name: setup server
|
||||
hetzner.hcloud.hcloud_server:
|
||||
name: "{{hcloud_server_name}}"
|
||||
server_type: cx11
|
||||
image: ubuntu-22.04
|
||||
state: started
|
||||
register: server
|
||||
- name: verify setup server
|
||||
assert:
|
||||
that:
|
||||
- server is success
|
||||
- name: setup Load Balancer
|
||||
hetzner.hcloud.hcloud_load_balancer:
|
||||
name: "{{ hcloud_load_balancer_name }}"
|
||||
load_balancer_type: lb11
|
||||
network_zone: eu-central
|
||||
labels:
|
||||
key: value
|
||||
register: test_load_balancer
|
||||
- name: Check if cleanup.yml exists
|
||||
stat:
|
||||
path: "{{ role_path }}/tasks/cleanup.yml"
|
||||
register: cleanup_file
|
||||
|
||||
- name: verify setup Load Balancer
|
||||
assert:
|
||||
that:
|
||||
- test_load_balancer is changed
|
||||
- name: Check if prepare.yml exists
|
||||
stat:
|
||||
path: "{{ role_path }}/tasks/prepare.yml"
|
||||
register: prepare_file
|
||||
|
||||
- name: test create load_balancer target
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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: Include cleanup tasks
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when: cleanup_file.stat.exists
|
||||
|
||||
- name: test gather hcloud Load Balancer infos
|
||||
hetzner.hcloud.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: Include prepare tasks
|
||||
ansible.builtin.include_tasks: prepare.yml
|
||||
when: prepare_file.stat.exists
|
||||
|
||||
- name: test gather hcloud Load Balancer infos in check mode
|
||||
hetzner.hcloud.hcloud_load_balancer_info:
|
||||
check_mode: true
|
||||
register: hcloud_load_balancers
|
||||
- block:
|
||||
- name: Include test tasks
|
||||
ansible.builtin.include_tasks: test.yml
|
||||
|
||||
- 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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_load_balancer_info:
|
||||
id: "{{test_load_balancer.hcloud_load_balancer.id}}1"
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- name: verify test gather hcloud Load Balancer with wrong id
|
||||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
|
||||
- name: cleanup
|
||||
hetzner.hcloud.hcloud_load_balancer:
|
||||
id: "{{ test_load_balancer.hcloud_load_balancer.id }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify cleanup
|
||||
assert:
|
||||
that:
|
||||
- result is success
|
||||
always:
|
||||
- name: Include cleanup tasks
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when: cleanup_file.stat.exists
|
||||
|
|
|
@ -0,0 +1,127 @@
|
|||
# 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
|
||||
hetzner.hcloud.hcloud_load_balancer:
|
||||
name: "{{ hcloud_load_balancer_name }}"
|
||||
state: absent
|
||||
- name: setup server
|
||||
hetzner.hcloud.hcloud_server:
|
||||
name: "{{hcloud_server_name}}"
|
||||
server_type: cx11
|
||||
image: ubuntu-22.04
|
||||
state: started
|
||||
register: server
|
||||
- name: verify setup server
|
||||
assert:
|
||||
that:
|
||||
- server is success
|
||||
- name: setup Load Balancer
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_load_balancer_info:
|
||||
check_mode: true
|
||||
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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_load_balancer_info:
|
||||
id: "{{test_load_balancer.hcloud_load_balancer.id}}1"
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- name: verify test gather hcloud Load Balancer with wrong id
|
||||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
|
||||
- name: cleanup
|
||||
hetzner.hcloud.hcloud_load_balancer:
|
||||
id: "{{ test_load_balancer.hcloud_load_balancer.id }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify cleanup
|
||||
assert:
|
||||
that:
|
||||
- result is success
|
|
@ -1,6 +0,0 @@
|
|||
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
hcloud_prefix: "tests"
|
||||
hcloud_network_name: "{{hcloud_prefix}}-lb-n"
|
||||
hcloud_load_balancer_name: "{{hcloud_prefix}}-lb-n"
|
|
@ -0,0 +1,12 @@
|
|||
#
|
||||
# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead.
|
||||
#
|
||||
---
|
||||
# Azure Pipelines will configure this value to something similar to
|
||||
# "azp-84824-1-hetzner-2-13-test-2-13-hcloud-3-9-1-default-i"
|
||||
hcloud_prefix: "tests"
|
||||
|
||||
# Used to namespace resources created by concurrent test pipelines/targets
|
||||
hcloud_run_ns: "{{ hcloud_prefix | md5 }}"
|
||||
hcloud_role_ns: "{{ role_name | split('_') | map('first') | join() }}"
|
||||
hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
|
|
@ -0,0 +1,5 @@
|
|||
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
hcloud_network_name: "{{ hcloud_ns }}"
|
||||
hcloud_load_balancer_name: "{{ hcloud_ns }}"
|
|
@ -1,181 +1,30 @@
|
|||
# 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)
|
||||
#
|
||||
# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead.
|
||||
#
|
||||
---
|
||||
- name: setup network
|
||||
hetzner.hcloud.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: Check if cleanup.yml exists
|
||||
stat:
|
||||
path: "{{ role_path }}/tasks/cleanup.yml"
|
||||
register: cleanup_file
|
||||
|
||||
- name: setup subnetwork
|
||||
hetzner.hcloud.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: Check if prepare.yml exists
|
||||
stat:
|
||||
path: "{{ role_path }}/tasks/prepare.yml"
|
||||
register: prepare_file
|
||||
|
||||
- name: setup load_balancer
|
||||
hetzner.hcloud.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: Include cleanup tasks
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when: cleanup_file.stat.exists
|
||||
|
||||
- name: test missing required parameters on create load_balancer network
|
||||
hetzner.hcloud.hcloud_load_balancer_network:
|
||||
state: present
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- name: verify fail test missing required parameters on create load_balancer network
|
||||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
- '"missing required arguments:" in result.msg'
|
||||
- name: Include prepare tasks
|
||||
ansible.builtin.include_tasks: prepare.yml
|
||||
when: prepare_file.stat.exists
|
||||
|
||||
- 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'"
|
||||
- block:
|
||||
- name: Include test tasks
|
||||
ansible.builtin.include_tasks: test.yml
|
||||
|
||||
- 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
|
||||
hetzner.hcloud.hcloud_load_balancer_network:
|
||||
network: "{{ hcloud_network_name }}"
|
||||
load_balancer: "{{hcloud_load_balancer_name}}"
|
||||
state: present
|
||||
register: result
|
||||
check_mode: true
|
||||
- name: verify test create load_balancer network with checkmode
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: test create load_balancer network
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_network:
|
||||
name: "{{hcloud_network_name}}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify cleanup
|
||||
assert:
|
||||
that:
|
||||
- result is success
|
||||
always:
|
||||
- name: Include cleanup tasks
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when: cleanup_file.stat.exists
|
||||
|
|
|
@ -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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_load_balancer_network:
|
||||
state: present
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- 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
|
||||
hetzner.hcloud.hcloud_load_balancer_network:
|
||||
network: "{{ hcloud_network_name }}"
|
||||
load_balancer: "{{hcloud_load_balancer_name}}"
|
||||
state: present
|
||||
register: result
|
||||
check_mode: true
|
||||
- name: verify test create load_balancer network with checkmode
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: test create load_balancer network
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_network:
|
||||
name: "{{hcloud_network_name}}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify cleanup
|
||||
assert:
|
||||
that:
|
||||
- result is success
|
|
@ -0,0 +1,12 @@
|
|||
#
|
||||
# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead.
|
||||
#
|
||||
---
|
||||
# Azure Pipelines will configure this value to something similar to
|
||||
# "azp-84824-1-hetzner-2-13-test-2-13-hcloud-3-9-1-default-i"
|
||||
hcloud_prefix: "tests"
|
||||
|
||||
# Used to namespace resources created by concurrent test pipelines/targets
|
||||
hcloud_run_ns: "{{ hcloud_prefix | md5 }}"
|
||||
hcloud_role_ns: "{{ role_name | split('_') | map('first') | join() }}"
|
||||
hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
|
|
@ -0,0 +1,4 @@
|
|||
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
hcloud_load_balancer_name: "{{ hcloud_ns }}"
|
|
@ -1,126 +1,30 @@
|
|||
# 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)
|
||||
#
|
||||
# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead.
|
||||
#
|
||||
---
|
||||
- name: setup load_balancer
|
||||
hetzner.hcloud.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: Check if cleanup.yml exists
|
||||
stat:
|
||||
path: "{{ role_path }}/tasks/cleanup.yml"
|
||||
register: cleanup_file
|
||||
|
||||
- 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: Check if prepare.yml exists
|
||||
stat:
|
||||
path: "{{ role_path }}/tasks/prepare.yml"
|
||||
register: prepare_file
|
||||
|
||||
- name: test create load_balancer service with checkmode
|
||||
hetzner.hcloud.hcloud_load_balancer_service:
|
||||
load_balancer: "{{hcloud_load_balancer_name}}"
|
||||
protocol: "http"
|
||||
listen_port: 80
|
||||
state: present
|
||||
register: result
|
||||
check_mode: true
|
||||
- name: verify test create load_balancer service with checkmode
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
- name: Include cleanup tasks
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when: cleanup_file.stat.exists
|
||||
|
||||
- name: test create load_balancer service
|
||||
hetzner.hcloud.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: Include prepare tasks
|
||||
ansible.builtin.include_tasks: prepare.yml
|
||||
when: prepare_file.stat.exists
|
||||
|
||||
- name: test create load_balancer service idempotency
|
||||
hetzner.hcloud.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
|
||||
- block:
|
||||
- name: Include test tasks
|
||||
ansible.builtin.include_tasks: test.yml
|
||||
|
||||
- name: test update load_balancer service
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_load_balancer_service:
|
||||
load_balancer: "{{hcloud_load_balancer_name}}"
|
||||
protocol: "http"
|
||||
listen_port: 80
|
||||
http:
|
||||
cookie_name: "Test"
|
||||
sticky_sessions: true
|
||||
state: present
|
||||
register: load_balancer_service
|
||||
- name: verify create load_balancer service
|
||||
assert:
|
||||
that:
|
||||
- load_balancer_service is changed
|
||||
- load_balancer_service.hcloud_load_balancer_service.protocol == "http"
|
||||
- load_balancer_service.hcloud_load_balancer_service.listen_port == 80
|
||||
- load_balancer_service.hcloud_load_balancer_service.destination_port == 80
|
||||
- load_balancer_service.hcloud_load_balancer_service.proxyprotocol is sameas false
|
||||
|
||||
- name: cleanup load_balancer
|
||||
hetzner.hcloud.hcloud_load_balancer:
|
||||
name: "{{ hcloud_load_balancer_name }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify cleanup load_balancer
|
||||
assert:
|
||||
that:
|
||||
- result is success
|
||||
always:
|
||||
- name: Include cleanup tasks
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when: cleanup_file.stat.exists
|
||||
|
|
|
@ -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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_load_balancer_service:
|
||||
load_balancer: "{{hcloud_load_balancer_name}}"
|
||||
protocol: "http"
|
||||
listen_port: 80
|
||||
state: present
|
||||
register: result
|
||||
check_mode: true
|
||||
- name: verify test create load_balancer service with checkmode
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: test create load_balancer service
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_load_balancer_service:
|
||||
load_balancer: "{{hcloud_load_balancer_name}}"
|
||||
protocol: "http"
|
||||
listen_port: 80
|
||||
http:
|
||||
cookie_name: "Test"
|
||||
sticky_sessions: true
|
||||
state: present
|
||||
register: load_balancer_service
|
||||
- name: verify create load_balancer service
|
||||
assert:
|
||||
that:
|
||||
- load_balancer_service is changed
|
||||
- load_balancer_service.hcloud_load_balancer_service.protocol == "http"
|
||||
- load_balancer_service.hcloud_load_balancer_service.listen_port == 80
|
||||
- load_balancer_service.hcloud_load_balancer_service.destination_port == 80
|
||||
- load_balancer_service.hcloud_load_balancer_service.proxyprotocol is sameas false
|
||||
|
||||
- name: cleanup load_balancer
|
||||
hetzner.hcloud.hcloud_load_balancer:
|
||||
name: "{{ hcloud_load_balancer_name }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify cleanup load_balancer
|
||||
assert:
|
||||
that:
|
||||
- result is success
|
|
@ -1,7 +0,0 @@
|
|||
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
hcloud_prefix: "tests"
|
||||
hcloud_server_name: "{{ hcloud_prefix | truncate(45, True, '', 0) }}-lb-t"
|
||||
hcloud_load_balancer_name: "{{hcloud_prefix}}-lb-target"
|
||||
hcloud_testing_ip: "176.9.59.39"
|
|
@ -0,0 +1,12 @@
|
|||
#
|
||||
# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead.
|
||||
#
|
||||
---
|
||||
# Azure Pipelines will configure this value to something similar to
|
||||
# "azp-84824-1-hetzner-2-13-test-2-13-hcloud-3-9-1-default-i"
|
||||
hcloud_prefix: "tests"
|
||||
|
||||
# Used to namespace resources created by concurrent test pipelines/targets
|
||||
hcloud_run_ns: "{{ hcloud_prefix | md5 }}"
|
||||
hcloud_role_ns: "{{ role_name | split('_') | map('first') | join() }}"
|
||||
hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
|
|
@ -0,0 +1,6 @@
|
|||
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
hcloud_server_name: "{{ hcloud_ns }}"
|
||||
hcloud_load_balancer_name: "{{ hcloud_ns }}"
|
||||
hcloud_testing_ip: "176.9.59.39"
|
|
@ -1,154 +1,30 @@
|
|||
# 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)
|
||||
#
|
||||
# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead.
|
||||
#
|
||||
---
|
||||
- name: setup server
|
||||
hetzner.hcloud.hcloud_server:
|
||||
name: "{{hcloud_server_name}}"
|
||||
server_type: cx11
|
||||
image: ubuntu-22.04
|
||||
state: started
|
||||
location: "fsn1"
|
||||
register: server
|
||||
- name: verify setup server
|
||||
assert:
|
||||
that:
|
||||
- server is success
|
||||
- name: Check if cleanup.yml exists
|
||||
stat:
|
||||
path: "{{ role_path }}/tasks/cleanup.yml"
|
||||
register: cleanup_file
|
||||
|
||||
- name: setup load_balancer
|
||||
hetzner.hcloud.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: Check if prepare.yml exists
|
||||
stat:
|
||||
path: "{{ role_path }}/tasks/prepare.yml"
|
||||
register: prepare_file
|
||||
|
||||
- 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: Include cleanup tasks
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when: cleanup_file.stat.exists
|
||||
|
||||
- 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: Include prepare tasks
|
||||
ansible.builtin.include_tasks: prepare.yml
|
||||
when: prepare_file.stat.exists
|
||||
|
||||
- name: test create load_balancer target with checkmode
|
||||
hetzner.hcloud.hcloud_load_balancer_target:
|
||||
type: "server"
|
||||
load_balancer: "{{hcloud_load_balancer_name}}"
|
||||
server: "{{hcloud_server_name}}"
|
||||
state: present
|
||||
register: result
|
||||
check_mode: true
|
||||
- name: verify test create load_balancer target with checkmode
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
- block:
|
||||
- name: Include test tasks
|
||||
ansible.builtin.include_tasks: test.yml
|
||||
|
||||
- name: test create load_balancer target
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_load_balancer:
|
||||
name: "{{ hcloud_load_balancer_name }}"
|
||||
state: absent
|
||||
register: result
|
||||
until: result is not failed
|
||||
retries: 5
|
||||
delay: 2
|
||||
|
||||
- name: cleanup
|
||||
hetzner.hcloud.hcloud_server:
|
||||
name: "{{hcloud_server_name}}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify cleanup
|
||||
assert:
|
||||
that:
|
||||
- result is success
|
||||
always:
|
||||
- name: Include cleanup tasks
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when: cleanup_file.stat.exists
|
||||
|
|
|
@ -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
|
||||
hetzner.hcloud.hcloud_server:
|
||||
name: "{{hcloud_server_name}}"
|
||||
server_type: cx11
|
||||
image: ubuntu-22.04
|
||||
state: started
|
||||
location: "fsn1"
|
||||
register: server
|
||||
- name: verify setup server
|
||||
assert:
|
||||
that:
|
||||
- server is success
|
||||
|
||||
- name: setup load_balancer
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_load_balancer_target:
|
||||
type: "server"
|
||||
load_balancer: "{{hcloud_load_balancer_name}}"
|
||||
server: "{{hcloud_server_name}}"
|
||||
state: present
|
||||
register: result
|
||||
check_mode: true
|
||||
- name: verify test create load_balancer target with checkmode
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: test create load_balancer target
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_load_balancer:
|
||||
name: "{{ hcloud_load_balancer_name }}"
|
||||
state: absent
|
||||
register: result
|
||||
until: result is not failed
|
||||
retries: 5
|
||||
delay: 2
|
||||
|
||||
- name: cleanup
|
||||
hetzner.hcloud.hcloud_server:
|
||||
name: "{{hcloud_server_name}}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify cleanup
|
||||
assert:
|
||||
that:
|
||||
- result is success
|
|
@ -0,0 +1,12 @@
|
|||
#
|
||||
# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead.
|
||||
#
|
||||
---
|
||||
# Azure Pipelines will configure this value to something similar to
|
||||
# "azp-84824-1-hetzner-2-13-test-2-13-hcloud-3-9-1-default-i"
|
||||
hcloud_prefix: "tests"
|
||||
|
||||
# Used to namespace resources created by concurrent test pipelines/targets
|
||||
hcloud_run_ns: "{{ hcloud_prefix | md5 }}"
|
||||
hcloud_role_ns: "{{ role_name | split('_') | map('first') | join() }}"
|
||||
hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
|
|
@ -1,38 +1,30 @@
|
|||
# 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)
|
||||
#
|
||||
# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead.
|
||||
#
|
||||
---
|
||||
- name: test gather hcloud Load Balancer type infos
|
||||
hetzner.hcloud.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: Check if cleanup.yml exists
|
||||
stat:
|
||||
path: "{{ role_path }}/tasks/cleanup.yml"
|
||||
register: cleanup_file
|
||||
|
||||
- name: test gather hcloud Load Balancer type infos in check mode
|
||||
hetzner.hcloud.hcloud_load_balancer_type_info:
|
||||
check_mode: true
|
||||
register: hcloud_load_balancer_types
|
||||
- name: Check if prepare.yml exists
|
||||
stat:
|
||||
path: "{{ role_path }}/tasks/prepare.yml"
|
||||
register: prepare_file
|
||||
|
||||
- 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: Include cleanup tasks
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when: cleanup_file.stat.exists
|
||||
|
||||
- name: test gather hcloud Load Balancer type infos with name
|
||||
hetzner.hcloud.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: Include prepare tasks
|
||||
ansible.builtin.include_tasks: prepare.yml
|
||||
when: prepare_file.stat.exists
|
||||
|
||||
- name: test gather hcloud Load Balancer type infos with correct id
|
||||
hetzner.hcloud.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
|
||||
- block:
|
||||
- name: Include test tasks
|
||||
ansible.builtin.include_tasks: test.yml
|
||||
|
||||
always:
|
||||
- name: Include cleanup tasks
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when: cleanup_file.stat.exists
|
||||
|
|
|
@ -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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_load_balancer_type_info:
|
||||
check_mode: true
|
||||
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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
|
@ -0,0 +1,12 @@
|
|||
#
|
||||
# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead.
|
||||
#
|
||||
---
|
||||
# Azure Pipelines will configure this value to something similar to
|
||||
# "azp-84824-1-hetzner-2-13-test-2-13-hcloud-3-9-1-default-i"
|
||||
hcloud_prefix: "tests"
|
||||
|
||||
# Used to namespace resources created by concurrent test pipelines/targets
|
||||
hcloud_run_ns: "{{ hcloud_prefix | md5 }}"
|
||||
hcloud_role_ns: "{{ role_name | split('_') | map('first') | join() }}"
|
||||
hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
|
|
@ -1,57 +1,30 @@
|
|||
# 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)
|
||||
#
|
||||
# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead.
|
||||
#
|
||||
---
|
||||
- name: test gather hcloud location infos
|
||||
hetzner.hcloud.hcloud_location_info:
|
||||
register: hcloud_location
|
||||
- name: Check if cleanup.yml exists
|
||||
stat:
|
||||
path: "{{ role_path }}/tasks/cleanup.yml"
|
||||
register: cleanup_file
|
||||
|
||||
- name: verify test gather hcloud location infos
|
||||
assert:
|
||||
that:
|
||||
- hcloud_location.hcloud_location_info | list | count >= 5
|
||||
- name: Check if prepare.yml exists
|
||||
stat:
|
||||
path: "{{ role_path }}/tasks/prepare.yml"
|
||||
register: prepare_file
|
||||
|
||||
- name: test gather hcloud location infos in check mode
|
||||
hetzner.hcloud.hcloud_location_info:
|
||||
check_mode: true
|
||||
register: hcloud_location
|
||||
- name: Include cleanup tasks
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when: cleanup_file.stat.exists
|
||||
|
||||
- name: verify test gather hcloud location infos in check mode
|
||||
assert:
|
||||
that:
|
||||
- hcloud_location.hcloud_location_info | list | count >= 5
|
||||
- name: Include prepare tasks
|
||||
ansible.builtin.include_tasks: prepare.yml
|
||||
when: prepare_file.stat.exists
|
||||
|
||||
- name: test gather hcloud location infos with correct name
|
||||
hetzner.hcloud.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
|
||||
- block:
|
||||
- name: Include test tasks
|
||||
ansible.builtin.include_tasks: test.yml
|
||||
|
||||
- name: test gather hcloud location infos with wrong name
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
always:
|
||||
- name: Include cleanup tasks
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when: cleanup_file.stat.exists
|
||||
|
|
|
@ -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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_location_info:
|
||||
check_mode: true
|
||||
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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
|
@ -1,7 +0,0 @@
|
|||
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
hcloud_prefix: "tests"
|
||||
hcloud_network_name: "{{hcloud_prefix}}-i"
|
||||
|
||||
hcloud_network_name_with_vswitch: "{{hcloud_prefix}}-i-vswitch"
|
|
@ -0,0 +1,12 @@
|
|||
#
|
||||
# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead.
|
||||
#
|
||||
---
|
||||
# Azure Pipelines will configure this value to something similar to
|
||||
# "azp-84824-1-hetzner-2-13-test-2-13-hcloud-3-9-1-default-i"
|
||||
hcloud_prefix: "tests"
|
||||
|
||||
# Used to namespace resources created by concurrent test pipelines/targets
|
||||
hcloud_run_ns: "{{ hcloud_prefix | md5 }}"
|
||||
hcloud_role_ns: "{{ role_name | split('_') | map('first') | join() }}"
|
||||
hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
|
|
@ -0,0 +1,5 @@
|
|||
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
hcloud_network_name: "{{ hcloud_ns }}"
|
||||
hcloud_network_name_with_vswitch: "{{ hcloud_ns }}-vswitch"
|
|
@ -1,268 +1,30 @@
|
|||
# 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)
|
||||
#
|
||||
# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead.
|
||||
#
|
||||
---
|
||||
- name: setup ensure network is absent
|
||||
hetzner.hcloud.hcloud_network:
|
||||
name: "{{ item }}"
|
||||
state: absent
|
||||
with_items:
|
||||
- "{{ hcloud_network_name }}"
|
||||
- "{{ hcloud_network_name_with_vswitch }}"
|
||||
- name: Check if cleanup.yml exists
|
||||
stat:
|
||||
path: "{{ role_path }}/tasks/cleanup.yml"
|
||||
register: cleanup_file
|
||||
|
||||
- name: test missing ip_range parameter on create Network
|
||||
hetzner.hcloud.hcloud_network:
|
||||
name: "{{hcloud_network_name}}"
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- name: verify fail missing ip_range parameter on create Network result
|
||||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
- 'result.msg == "missing required arguments: ip_range"'
|
||||
- name: Check if prepare.yml exists
|
||||
stat:
|
||||
path: "{{ role_path }}/tasks/prepare.yml"
|
||||
register: prepare_file
|
||||
|
||||
- name: test create Network with check mode
|
||||
hetzner.hcloud.hcloud_network:
|
||||
name: "{{hcloud_network_name}}"
|
||||
ip_range: "10.0.0.0/16"
|
||||
register: result
|
||||
check_mode: true
|
||||
- name: verify create Network with check mode result
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
- name: Include cleanup tasks
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when: cleanup_file.stat.exists
|
||||
|
||||
- name: test create Network
|
||||
hetzner.hcloud.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: Include prepare tasks
|
||||
ansible.builtin.include_tasks: prepare.yml
|
||||
when: prepare_file.stat.exists
|
||||
|
||||
- name: test create Network idempotence
|
||||
hetzner.hcloud.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
|
||||
- block:
|
||||
- name: Include test tasks
|
||||
ansible.builtin.include_tasks: test.yml
|
||||
|
||||
- name: test create Network with expose_routes_to_vswitch
|
||||
hetzner.hcloud.hcloud_network:
|
||||
name: "{{hcloud_network_name_with_vswitch}}"
|
||||
ip_range: "10.0.0.0/16"
|
||||
expose_routes_to_vswitch: true
|
||||
register: network
|
||||
- name: verify test create Network with vSwitch result
|
||||
assert:
|
||||
that:
|
||||
- network is changed
|
||||
- network.hcloud_network.name == "{{hcloud_network_name_with_vswitch}}"
|
||||
- network.hcloud_network.ip_range == "10.0.0.0/16"
|
||||
- network.hcloud_network.expose_routes_to_vswitch is true
|
||||
|
||||
- name: test create Network with expose_routes_to_vswitch idempotence
|
||||
hetzner.hcloud.hcloud_network:
|
||||
name: "{{hcloud_network_name_with_vswitch}}"
|
||||
ip_range: "10.0.0.0/16"
|
||||
expose_routes_to_vswitch: true
|
||||
register: network
|
||||
- name: verify test create network idempotency
|
||||
assert:
|
||||
that:
|
||||
- network is not changed
|
||||
|
||||
- name: test update Network label
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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 expose_routes_to_vswitch
|
||||
hetzner.hcloud.hcloud_network:
|
||||
name: "{{hcloud_network_name_with_vswitch}}"
|
||||
expose_routes_to_vswitch: false
|
||||
register: network
|
||||
- name: verify test update Network expose_routes_to_vswitch
|
||||
assert:
|
||||
that:
|
||||
- network is changed
|
||||
- network.hcloud_network.expose_routes_to_vswitch is false
|
||||
|
||||
- name: test update Network expose_routes_to_vswitch idempotency
|
||||
hetzner.hcloud.hcloud_network:
|
||||
name: "{{hcloud_network_name_with_vswitch}}"
|
||||
expose_routes_to_vswitch: false
|
||||
register: network
|
||||
- name: verify test update Network expose_routes_to_vswitch idempotency
|
||||
assert:
|
||||
that:
|
||||
- network is not changed
|
||||
|
||||
- name: test update Network delete protection
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_network:
|
||||
name: "{{hcloud_network_name}}"
|
||||
state: absent
|
||||
ignore_errors: true
|
||||
register: result
|
||||
- name: verify delete Network
|
||||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
- 'result.msg == "network deletion is protected"'
|
||||
|
||||
- name: test update Network delete protection
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_network:
|
||||
name: "{{hcloud_network_name}}"
|
||||
state: absent
|
||||
ignore_errors: true
|
||||
register: result
|
||||
- name: verify delete Network
|
||||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
- 'result.msg == "network deletion is protected"'
|
||||
|
||||
- name: test update Network delete protection
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_network:
|
||||
name: "{{hcloud_network_name}}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify delete Network
|
||||
assert:
|
||||
that:
|
||||
- result is success
|
||||
|
||||
- name: test delete Network with expose_routes_to_vswitch
|
||||
hetzner.hcloud.hcloud_network:
|
||||
name: "{{hcloud_network_name_with_vswitch}}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify delete Network with expose_routes_to_vswitch
|
||||
assert:
|
||||
that:
|
||||
- result is success
|
||||
always:
|
||||
- name: Include cleanup tasks
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when: cleanup_file.stat.exists
|
||||
|
|
268
tests/integration/targets/hcloud_network/tasks/test.yml
Normal file
268
tests/integration/targets/hcloud_network/tasks/test.yml
Normal file
|
@ -0,0 +1,268 @@
|
|||
# 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
|
||||
hetzner.hcloud.hcloud_network:
|
||||
name: "{{ item }}"
|
||||
state: absent
|
||||
with_items:
|
||||
- "{{ hcloud_network_name }}"
|
||||
- "{{ hcloud_network_name_with_vswitch }}"
|
||||
|
||||
- name: test missing ip_range parameter on create Network
|
||||
hetzner.hcloud.hcloud_network:
|
||||
name: "{{hcloud_network_name}}"
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- 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
|
||||
hetzner.hcloud.hcloud_network:
|
||||
name: "{{hcloud_network_name}}"
|
||||
ip_range: "10.0.0.0/16"
|
||||
register: result
|
||||
check_mode: true
|
||||
- name: verify create Network with check mode result
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: test create Network
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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 create Network with expose_routes_to_vswitch
|
||||
hetzner.hcloud.hcloud_network:
|
||||
name: "{{hcloud_network_name_with_vswitch}}"
|
||||
ip_range: "10.0.0.0/16"
|
||||
expose_routes_to_vswitch: true
|
||||
register: network
|
||||
- name: verify test create Network with vSwitch result
|
||||
assert:
|
||||
that:
|
||||
- network is changed
|
||||
- network.hcloud_network.name == "{{hcloud_network_name_with_vswitch}}"
|
||||
- network.hcloud_network.ip_range == "10.0.0.0/16"
|
||||
- network.hcloud_network.expose_routes_to_vswitch is true
|
||||
|
||||
- name: test create Network with expose_routes_to_vswitch idempotence
|
||||
hetzner.hcloud.hcloud_network:
|
||||
name: "{{hcloud_network_name_with_vswitch}}"
|
||||
ip_range: "10.0.0.0/16"
|
||||
expose_routes_to_vswitch: true
|
||||
register: network
|
||||
- name: verify test create network idempotency
|
||||
assert:
|
||||
that:
|
||||
- network is not changed
|
||||
|
||||
- name: test update Network label
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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 expose_routes_to_vswitch
|
||||
hetzner.hcloud.hcloud_network:
|
||||
name: "{{hcloud_network_name_with_vswitch}}"
|
||||
expose_routes_to_vswitch: false
|
||||
register: network
|
||||
- name: verify test update Network expose_routes_to_vswitch
|
||||
assert:
|
||||
that:
|
||||
- network is changed
|
||||
- network.hcloud_network.expose_routes_to_vswitch is false
|
||||
|
||||
- name: test update Network expose_routes_to_vswitch idempotency
|
||||
hetzner.hcloud.hcloud_network:
|
||||
name: "{{hcloud_network_name_with_vswitch}}"
|
||||
expose_routes_to_vswitch: false
|
||||
register: network
|
||||
- name: verify test update Network expose_routes_to_vswitch idempotency
|
||||
assert:
|
||||
that:
|
||||
- network is not changed
|
||||
|
||||
- name: test update Network delete protection
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_network:
|
||||
name: "{{hcloud_network_name}}"
|
||||
state: absent
|
||||
ignore_errors: true
|
||||
register: result
|
||||
- name: verify delete Network
|
||||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
- 'result.msg == "network deletion is protected"'
|
||||
|
||||
- name: test update Network delete protection
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_network:
|
||||
name: "{{hcloud_network_name}}"
|
||||
state: absent
|
||||
ignore_errors: true
|
||||
register: result
|
||||
- name: verify delete Network
|
||||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
- 'result.msg == "network deletion is protected"'
|
||||
|
||||
- name: test update Network delete protection
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_network:
|
||||
name: "{{hcloud_network_name}}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify delete Network
|
||||
assert:
|
||||
that:
|
||||
- result is success
|
||||
|
||||
- name: test delete Network with expose_routes_to_vswitch
|
||||
hetzner.hcloud.hcloud_network:
|
||||
name: "{{hcloud_network_name_with_vswitch}}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify delete Network with expose_routes_to_vswitch
|
||||
assert:
|
||||
that:
|
||||
- result is success
|
|
@ -1,5 +0,0 @@
|
|||
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
hcloud_prefix: "tests"
|
||||
hcloud_network_name: "{{hcloud_prefix}}-integration"
|
|
@ -0,0 +1,12 @@
|
|||
#
|
||||
# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead.
|
||||
#
|
||||
---
|
||||
# Azure Pipelines will configure this value to something similar to
|
||||
# "azp-84824-1-hetzner-2-13-test-2-13-hcloud-3-9-1-default-i"
|
||||
hcloud_prefix: "tests"
|
||||
|
||||
# Used to namespace resources created by concurrent test pipelines/targets
|
||||
hcloud_run_ns: "{{ hcloud_prefix | md5 }}"
|
||||
hcloud_role_ns: "{{ role_name | split('_') | map('first') | join() }}"
|
||||
hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
|
|
@ -0,0 +1,4 @@
|
|||
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
hcloud_network_name: "{{ hcloud_ns }}"
|
|
@ -1,116 +1,30 @@
|
|||
# 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)
|
||||
#
|
||||
# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead.
|
||||
#
|
||||
---
|
||||
- name: setup ensure network is absent
|
||||
hetzner.hcloud.hcloud_network:
|
||||
name: "{{ hcloud_network_name }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: Check if cleanup.yml exists
|
||||
stat:
|
||||
path: "{{ role_path }}/tasks/cleanup.yml"
|
||||
register: cleanup_file
|
||||
|
||||
- name: create network
|
||||
hetzner.hcloud.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"
|
||||
- main_network.hcloud_network.expose_routes_to_vswitch is false
|
||||
- name: create subnetwork
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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: Check if prepare.yml exists
|
||||
stat:
|
||||
path: "{{ role_path }}/tasks/prepare.yml"
|
||||
register: prepare_file
|
||||
|
||||
- name: test gather hcloud network info in check mode
|
||||
hetzner.hcloud.hcloud_network_info:
|
||||
check_mode: true
|
||||
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: Include cleanup tasks
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when: cleanup_file.stat.exists
|
||||
|
||||
- name: test gather hcloud network info with correct label selector
|
||||
hetzner.hcloud.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: Include prepare tasks
|
||||
ansible.builtin.include_tasks: prepare.yml
|
||||
when: prepare_file.stat.exists
|
||||
|
||||
- name: test gather hcloud network info with wrong label selector
|
||||
hetzner.hcloud.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
|
||||
- block:
|
||||
- name: Include test tasks
|
||||
ansible.builtin.include_tasks: test.yml
|
||||
|
||||
- name: test gather hcloud network info with correct name
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_network:
|
||||
name: "{{ hcloud_network_name }}"
|
||||
state: absent
|
||||
always:
|
||||
- name: Include cleanup tasks
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when: cleanup_file.stat.exists
|
||||
|
|
116
tests/integration/targets/hcloud_network_info/tasks/test.yml
Normal file
116
tests/integration/targets/hcloud_network_info/tasks/test.yml
Normal file
|
@ -0,0 +1,116 @@
|
|||
# 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
|
||||
hetzner.hcloud.hcloud_network:
|
||||
name: "{{ hcloud_network_name }}"
|
||||
state: absent
|
||||
register: result
|
||||
|
||||
- name: create network
|
||||
hetzner.hcloud.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"
|
||||
- main_network.hcloud_network.expose_routes_to_vswitch is false
|
||||
- name: create subnetwork
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_network_info:
|
||||
check_mode: true
|
||||
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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_network:
|
||||
name: "{{ hcloud_network_name }}"
|
||||
state: absent
|
|
@ -1,6 +0,0 @@
|
|||
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
hcloud_prefix: "tests"
|
||||
hcloud_placement_group_name: "{{hcloud_prefix}}-i"
|
||||
hcloud_server_name: "{{ hcloud_prefix | truncate(45, True, '', 0) }}-i"
|
|
@ -0,0 +1,12 @@
|
|||
#
|
||||
# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead.
|
||||
#
|
||||
---
|
||||
# Azure Pipelines will configure this value to something similar to
|
||||
# "azp-84824-1-hetzner-2-13-test-2-13-hcloud-3-9-1-default-i"
|
||||
hcloud_prefix: "tests"
|
||||
|
||||
# Used to namespace resources created by concurrent test pipelines/targets
|
||||
hcloud_run_ns: "{{ hcloud_prefix | md5 }}"
|
||||
hcloud_role_ns: "{{ role_name | split('_') | map('first') | join() }}"
|
||||
hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
|
|
@ -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_placement_group_name: "{{ hcloud_ns }}"
|
||||
hcloud_server_name: "{{ hcloud_ns }}"
|
|
@ -1,169 +1,30 @@
|
|||
# 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)
|
||||
#
|
||||
# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead.
|
||||
#
|
||||
---
|
||||
- name: setup placement group to be absent
|
||||
hetzner.hcloud.hcloud_placement_group:
|
||||
name: "{{ hcloud_placement_group_name }}"
|
||||
state: absent
|
||||
- name: Check if cleanup.yml exists
|
||||
stat:
|
||||
path: "{{ role_path }}/tasks/cleanup.yml"
|
||||
register: cleanup_file
|
||||
|
||||
- name: setup server to be absent
|
||||
hetzner.hcloud.hcloud_server:
|
||||
name: "{{ hcloud_server_name }}"
|
||||
state: absent
|
||||
- name: Check if prepare.yml exists
|
||||
stat:
|
||||
path: "{{ role_path }}/tasks/prepare.yml"
|
||||
register: prepare_file
|
||||
|
||||
- name: test missing required parameters on create placement group
|
||||
hetzner.hcloud.hcloud_placement_group:
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- 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: Include cleanup tasks
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when: cleanup_file.stat.exists
|
||||
|
||||
- name: test create placement group with check mode
|
||||
hetzner.hcloud.hcloud_placement_group:
|
||||
name: "{{ hcloud_placement_group_name }}"
|
||||
type: spread
|
||||
register: result
|
||||
check_mode: true
|
||||
- name: test create placement group with check mode
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
- name: Include prepare tasks
|
||||
ansible.builtin.include_tasks: prepare.yml
|
||||
when: prepare_file.stat.exists
|
||||
|
||||
- name: test create placement group
|
||||
hetzner.hcloud.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
|
||||
- block:
|
||||
- name: Include test tasks
|
||||
ansible.builtin.include_tasks: test.yml
|
||||
|
||||
- name: test create placement group idempotence
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_server:
|
||||
name: "{{ hcloud_server_name }}"
|
||||
server_type: cpx11
|
||||
placement_group: "{{ hcloud_placement_group_name }}"
|
||||
image: "ubuntu-22.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_placement_group:
|
||||
id: "{{ placement_group.hcloud_placement_group.id }}"
|
||||
name: "changed-{{ hcloud_placement_group_name }}"
|
||||
register: result
|
||||
check_mode: true
|
||||
- name: verify update placement group with check mode
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: test update placement group
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_server:
|
||||
id: "{{ server.hcloud_server.id }}"
|
||||
state: absent
|
||||
|
||||
- name: absent placement group
|
||||
hetzner.hcloud.hcloud_placement_group:
|
||||
id: "{{ placement_group.hcloud_placement_group.id }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify absent placement group
|
||||
assert:
|
||||
that:
|
||||
- result is success
|
||||
always:
|
||||
- name: Include cleanup tasks
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when: cleanup_file.stat.exists
|
||||
|
|
169
tests/integration/targets/hcloud_placement_group/tasks/test.yml
Normal file
169
tests/integration/targets/hcloud_placement_group/tasks/test.yml
Normal file
|
@ -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
|
||||
hetzner.hcloud.hcloud_placement_group:
|
||||
name: "{{ hcloud_placement_group_name }}"
|
||||
state: absent
|
||||
|
||||
- name: setup server to be absent
|
||||
hetzner.hcloud.hcloud_server:
|
||||
name: "{{ hcloud_server_name }}"
|
||||
state: absent
|
||||
|
||||
- name: test missing required parameters on create placement group
|
||||
hetzner.hcloud.hcloud_placement_group:
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- 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
|
||||
hetzner.hcloud.hcloud_placement_group:
|
||||
name: "{{ hcloud_placement_group_name }}"
|
||||
type: spread
|
||||
register: result
|
||||
check_mode: true
|
||||
- name: test create placement group with check mode
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: test create placement group
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_server:
|
||||
name: "{{ hcloud_server_name }}"
|
||||
server_type: cpx11
|
||||
placement_group: "{{ hcloud_placement_group_name }}"
|
||||
image: "ubuntu-22.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_placement_group:
|
||||
id: "{{ placement_group.hcloud_placement_group.id }}"
|
||||
name: "changed-{{ hcloud_placement_group_name }}"
|
||||
register: result
|
||||
check_mode: true
|
||||
- name: verify update placement group with check mode
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: test update placement group
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_server:
|
||||
id: "{{ server.hcloud_server.id }}"
|
||||
state: absent
|
||||
|
||||
- name: absent placement group
|
||||
hetzner.hcloud.hcloud_placement_group:
|
||||
id: "{{ placement_group.hcloud_placement_group.id }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify absent placement group
|
||||
assert:
|
||||
that:
|
||||
- result is success
|
|
@ -1,6 +0,0 @@
|
|||
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
hcloud_prefix: "tests"
|
||||
hcloud_primary_ip_name: "{{hcloud_prefix}}-i"
|
||||
hcloud_server_name: "{{ hcloud_prefix | truncate(45, True, '', 0) }}-fip-t"
|
|
@ -0,0 +1,12 @@
|
|||
#
|
||||
# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead.
|
||||
#
|
||||
---
|
||||
# Azure Pipelines will configure this value to something similar to
|
||||
# "azp-84824-1-hetzner-2-13-test-2-13-hcloud-3-9-1-default-i"
|
||||
hcloud_prefix: "tests"
|
||||
|
||||
# Used to namespace resources created by concurrent test pipelines/targets
|
||||
hcloud_run_ns: "{{ hcloud_prefix | md5 }}"
|
||||
hcloud_role_ns: "{{ role_name | split('_') | map('first') | join() }}"
|
||||
hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
|
|
@ -1,5 +1,5 @@
|
|||
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
hcloud_prefix: "tests"
|
||||
hcloud_load_balancer_name: "{{hcloud_prefix}}-lb-target"
|
||||
hcloud_primary_ip_name: "{{ hcloud_ns }}"
|
||||
hcloud_server_name: "{{ hcloud_ns }}"
|
|
@ -1,248 +1,30 @@
|
|||
# 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)
|
||||
#
|
||||
# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead.
|
||||
#
|
||||
---
|
||||
- name: setup ensure primary ip is absent
|
||||
hetzner.hcloud.hcloud_primary_ip:
|
||||
name: "{{ hcloud_primary_ip_name }}"
|
||||
state: absent
|
||||
- name: Check if cleanup.yml exists
|
||||
stat:
|
||||
path: "{{ role_path }}/tasks/cleanup.yml"
|
||||
register: cleanup_file
|
||||
|
||||
- name: test create Primary IP with check mode
|
||||
hetzner.hcloud.hcloud_primary_ip:
|
||||
name: "{{ hcloud_primary_ip_name }}"
|
||||
type: ipv4
|
||||
datacenter: "fsn1-dc14"
|
||||
register: primaryIP
|
||||
check_mode: true
|
||||
- name: verify test create Primary IP with check mode
|
||||
assert:
|
||||
that:
|
||||
- primaryIP is changed
|
||||
- name: Check if prepare.yml exists
|
||||
stat:
|
||||
path: "{{ role_path }}/tasks/prepare.yml"
|
||||
register: prepare_file
|
||||
|
||||
- name: test create Primary IP
|
||||
hetzner.hcloud.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: Include cleanup tasks
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when: cleanup_file.stat.exists
|
||||
|
||||
- name: test create Primary IP idempotency
|
||||
hetzner.hcloud.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: Include prepare tasks
|
||||
ansible.builtin.include_tasks: prepare.yml
|
||||
when: prepare_file.stat.exists
|
||||
|
||||
- name: test update Primary IP
|
||||
hetzner.hcloud.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
|
||||
- block:
|
||||
- name: Include test tasks
|
||||
ansible.builtin.include_tasks: test.yml
|
||||
|
||||
- name: test update Primary IP idempotency
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_primary_ip:
|
||||
name: "{{ hcloud_primary_ip_name }}"
|
||||
state: "absent"
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- 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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_primary_ip:
|
||||
name: "{{ hcloud_primary_ip_name }}"
|
||||
state: "absent"
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- 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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_primary_ip:
|
||||
name: "{{ hcloud_primary_ip_name }}"
|
||||
state: "absent"
|
||||
register: result
|
||||
- name: verify test delete primary ip
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
always:
|
||||
- name: Include cleanup tasks
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when: cleanup_file.stat.exists
|
||||
|
|
248
tests/integration/targets/hcloud_primary_ip/tasks/test.yml
Normal file
248
tests/integration/targets/hcloud_primary_ip/tasks/test.yml
Normal file
|
@ -0,0 +1,248 @@
|
|||
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
- name: setup ensure primary ip is absent
|
||||
hetzner.hcloud.hcloud_primary_ip:
|
||||
name: "{{ hcloud_primary_ip_name }}"
|
||||
state: absent
|
||||
|
||||
- name: test create Primary IP with check mode
|
||||
hetzner.hcloud.hcloud_primary_ip:
|
||||
name: "{{ hcloud_primary_ip_name }}"
|
||||
type: ipv4
|
||||
datacenter: "fsn1-dc14"
|
||||
register: primaryIP
|
||||
check_mode: true
|
||||
- name: verify test create Primary IP with check mode
|
||||
assert:
|
||||
that:
|
||||
- primaryIP is changed
|
||||
|
||||
- name: test create Primary IP
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_primary_ip:
|
||||
name: "{{ hcloud_primary_ip_name }}"
|
||||
state: "absent"
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- 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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_primary_ip:
|
||||
name: "{{ hcloud_primary_ip_name }}"
|
||||
state: "absent"
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- 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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_primary_ip:
|
||||
name: "{{ hcloud_primary_ip_name }}"
|
||||
state: "absent"
|
||||
register: result
|
||||
- name: verify test delete primary ip
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
|
@ -1,5 +0,0 @@
|
|||
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
hcloud_prefix: "tests"
|
||||
hcloud_primary_ip_name: "{{hcloud_prefix}}-i"
|
|
@ -0,0 +1,12 @@
|
|||
#
|
||||
# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead.
|
||||
#
|
||||
---
|
||||
# Azure Pipelines will configure this value to something similar to
|
||||
# "azp-84824-1-hetzner-2-13-test-2-13-hcloud-3-9-1-default-i"
|
||||
hcloud_prefix: "tests"
|
||||
|
||||
# Used to namespace resources created by concurrent test pipelines/targets
|
||||
hcloud_run_ns: "{{ hcloud_prefix | md5 }}"
|
||||
hcloud_role_ns: "{{ role_name | split('_') | map('first') | join() }}"
|
||||
hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
|
|
@ -0,0 +1,4 @@
|
|||
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
hcloud_primary_ip_name: "{{ hcloud_ns }}"
|
|
@ -1,104 +1,30 @@
|
|||
# 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)
|
||||
#
|
||||
# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead.
|
||||
#
|
||||
---
|
||||
- name: setup ensure primary ip is absent
|
||||
hetzner.hcloud.hcloud_primary_ip:
|
||||
name: "{{ hcloud_primary_ip_name }}"
|
||||
state: absent
|
||||
- name: Check if cleanup.yml exists
|
||||
stat:
|
||||
path: "{{ role_path }}/tasks/cleanup.yml"
|
||||
register: cleanup_file
|
||||
|
||||
- name: setup primary ip
|
||||
hetzner.hcloud.hcloud_primary_ip:
|
||||
name: "{{ hcloud_primary_ip_name }}"
|
||||
datacenter: "fsn1-dc14"
|
||||
type: ipv4
|
||||
labels:
|
||||
key: value
|
||||
register: test_primary_ip
|
||||
- name: Check if prepare.yml exists
|
||||
stat:
|
||||
path: "{{ role_path }}/tasks/prepare.yml"
|
||||
register: prepare_file
|
||||
|
||||
- name: verify setup primary ip
|
||||
assert:
|
||||
that:
|
||||
- test_primary_ip is changed
|
||||
- name: Include cleanup tasks
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when: cleanup_file.stat.exists
|
||||
|
||||
- name: test gather hcloud primary ip infos
|
||||
hetzner.hcloud.hcloud_primary_ip_info:
|
||||
register: hcloud_primary_ips
|
||||
- name: verify test gather hcloud primary ip infos
|
||||
assert:
|
||||
that:
|
||||
- hcloud_primary_ips.hcloud_primary_ip_info| list | count >= 1
|
||||
- name: Include prepare tasks
|
||||
ansible.builtin.include_tasks: prepare.yml
|
||||
when: prepare_file.stat.exists
|
||||
|
||||
- name: test gather hcloud primary ip infos in check mode
|
||||
hetzner.hcloud.hcloud_primary_ip_info:
|
||||
check_mode: yes
|
||||
register: hcloud_primary_ips
|
||||
- block:
|
||||
- name: Include test tasks
|
||||
ansible.builtin.include_tasks: test.yml
|
||||
|
||||
- name: verify test gather hcloud primary ip infos in check mode
|
||||
assert:
|
||||
that:
|
||||
- hcloud_primary_ips.hcloud_primary_ip_info| list | count >= 1
|
||||
|
||||
- name: test gather hcloud primary ip infos with correct label selector
|
||||
hetzner.hcloud.hcloud_primary_ip_info:
|
||||
label_selector: "key=value"
|
||||
register: hcloud_primary_ips
|
||||
- name: verify test gather hcloud primary ip with correct label selector
|
||||
assert:
|
||||
that:
|
||||
- hcloud_primary_ips.hcloud_primary_ip_info|selectattr('name','equalto','{{ test_primary_ip.hcloud_primary_ip.name }}') | list | count == 1
|
||||
|
||||
- name: test gather hcloud primary ip infos with wrong label selector
|
||||
hetzner.hcloud.hcloud_primary_ip_info:
|
||||
label_selector: "key!=value"
|
||||
register: hcloud_primary_ips
|
||||
- name: verify test gather hcloud primary ip with wrong label selector
|
||||
assert:
|
||||
that:
|
||||
- hcloud_primary_ips.hcloud_primary_ip_info | list | count == 0
|
||||
|
||||
- name: test gather hcloud primary ip infos with correct name
|
||||
hetzner.hcloud.hcloud_primary_ip_info:
|
||||
name: "{{ hcloud_primary_ip_name }}"
|
||||
register: hcloud_primary_ips
|
||||
- name: verify test gather hcloud primary ip with correct name
|
||||
assert:
|
||||
that:
|
||||
- hcloud_primary_ips.hcloud_primary_ip_info|selectattr('name','equalto','{{ test_primary_ip.hcloud_primary_ip.name }}') | list | count == 1
|
||||
|
||||
- name: test gather hcloud primary ip infos with wrong name
|
||||
hetzner.hcloud.hcloud_primary_ip_info:
|
||||
name: "wrong-name"
|
||||
register: hcloud_primary_ips
|
||||
- name: verify test gather hcloud primary ip with wrong name
|
||||
assert:
|
||||
that:
|
||||
- hcloud_primary_ips.hcloud_primary_ip_info | list | count == 0
|
||||
|
||||
- name: test gather hcloud primary ip infos with correct id
|
||||
hetzner.hcloud.hcloud_primary_ip_info:
|
||||
id: "{{test_primary_ip.hcloud_primary_ip.id}}"
|
||||
register: hcloud_primary_ips
|
||||
- name: verify test gather hcloud primary ip with correct id
|
||||
assert:
|
||||
that:
|
||||
- hcloud_primary_ips.hcloud_primary_ip_info|selectattr('name','equalto','{{ test_primary_ip.hcloud_primary_ip.name }}') | list | count == 1
|
||||
|
||||
- name: test gather hcloud primary ip infos with wrong id
|
||||
hetzner.hcloud.hcloud_primary_ip_info:
|
||||
id: "{{test_primary_ip.hcloud_primary_ip.id}}1"
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- name: verify test gather hcloud primary ip with wrong id
|
||||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
|
||||
- name: cleanup
|
||||
hetzner.hcloud.hcloud_primary_ip:
|
||||
id: "{{ test_primary_ip.hcloud_primary_ip.id }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify cleanup
|
||||
assert:
|
||||
that:
|
||||
- result is success
|
||||
always:
|
||||
- name: Include cleanup tasks
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when: cleanup_file.stat.exists
|
||||
|
|
104
tests/integration/targets/hcloud_primary_ip_info/tasks/test.yml
Normal file
104
tests/integration/targets/hcloud_primary_ip_info/tasks/test.yml
Normal file
|
@ -0,0 +1,104 @@
|
|||
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
- name: setup ensure primary ip is absent
|
||||
hetzner.hcloud.hcloud_primary_ip:
|
||||
name: "{{ hcloud_primary_ip_name }}"
|
||||
state: absent
|
||||
|
||||
- name: setup primary ip
|
||||
hetzner.hcloud.hcloud_primary_ip:
|
||||
name: "{{ hcloud_primary_ip_name }}"
|
||||
datacenter: "fsn1-dc14"
|
||||
type: ipv4
|
||||
labels:
|
||||
key: value
|
||||
register: test_primary_ip
|
||||
|
||||
- name: verify setup primary ip
|
||||
assert:
|
||||
that:
|
||||
- test_primary_ip is changed
|
||||
|
||||
- name: test gather hcloud primary ip infos
|
||||
hetzner.hcloud.hcloud_primary_ip_info:
|
||||
register: hcloud_primary_ips
|
||||
- name: verify test gather hcloud primary ip infos
|
||||
assert:
|
||||
that:
|
||||
- hcloud_primary_ips.hcloud_primary_ip_info| list | count >= 1
|
||||
|
||||
- name: test gather hcloud primary ip infos in check mode
|
||||
hetzner.hcloud.hcloud_primary_ip_info:
|
||||
check_mode: yes
|
||||
register: hcloud_primary_ips
|
||||
|
||||
- name: verify test gather hcloud primary ip infos in check mode
|
||||
assert:
|
||||
that:
|
||||
- hcloud_primary_ips.hcloud_primary_ip_info| list | count >= 1
|
||||
|
||||
- name: test gather hcloud primary ip infos with correct label selector
|
||||
hetzner.hcloud.hcloud_primary_ip_info:
|
||||
label_selector: "key=value"
|
||||
register: hcloud_primary_ips
|
||||
- name: verify test gather hcloud primary ip with correct label selector
|
||||
assert:
|
||||
that:
|
||||
- hcloud_primary_ips.hcloud_primary_ip_info|selectattr('name','equalto','{{ test_primary_ip.hcloud_primary_ip.name }}') | list | count == 1
|
||||
|
||||
- name: test gather hcloud primary ip infos with wrong label selector
|
||||
hetzner.hcloud.hcloud_primary_ip_info:
|
||||
label_selector: "key!=value"
|
||||
register: hcloud_primary_ips
|
||||
- name: verify test gather hcloud primary ip with wrong label selector
|
||||
assert:
|
||||
that:
|
||||
- hcloud_primary_ips.hcloud_primary_ip_info | list | count == 0
|
||||
|
||||
- name: test gather hcloud primary ip infos with correct name
|
||||
hetzner.hcloud.hcloud_primary_ip_info:
|
||||
name: "{{ hcloud_primary_ip_name }}"
|
||||
register: hcloud_primary_ips
|
||||
- name: verify test gather hcloud primary ip with correct name
|
||||
assert:
|
||||
that:
|
||||
- hcloud_primary_ips.hcloud_primary_ip_info|selectattr('name','equalto','{{ test_primary_ip.hcloud_primary_ip.name }}') | list | count == 1
|
||||
|
||||
- name: test gather hcloud primary ip infos with wrong name
|
||||
hetzner.hcloud.hcloud_primary_ip_info:
|
||||
name: "wrong-name"
|
||||
register: hcloud_primary_ips
|
||||
- name: verify test gather hcloud primary ip with wrong name
|
||||
assert:
|
||||
that:
|
||||
- hcloud_primary_ips.hcloud_primary_ip_info | list | count == 0
|
||||
|
||||
- name: test gather hcloud primary ip infos with correct id
|
||||
hetzner.hcloud.hcloud_primary_ip_info:
|
||||
id: "{{test_primary_ip.hcloud_primary_ip.id}}"
|
||||
register: hcloud_primary_ips
|
||||
- name: verify test gather hcloud primary ip with correct id
|
||||
assert:
|
||||
that:
|
||||
- hcloud_primary_ips.hcloud_primary_ip_info|selectattr('name','equalto','{{ test_primary_ip.hcloud_primary_ip.name }}') | list | count == 1
|
||||
|
||||
- name: test gather hcloud primary ip infos with wrong id
|
||||
hetzner.hcloud.hcloud_primary_ip_info:
|
||||
id: "{{test_primary_ip.hcloud_primary_ip.id}}1"
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- name: verify test gather hcloud primary ip with wrong id
|
||||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
|
||||
- name: cleanup
|
||||
hetzner.hcloud.hcloud_primary_ip:
|
||||
id: "{{ test_primary_ip.hcloud_primary_ip.id }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify cleanup
|
||||
assert:
|
||||
that:
|
||||
- result is success
|
|
@ -1,8 +0,0 @@
|
|||
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
hcloud_prefix: "tests"
|
||||
hcloud_server_name: "{{ hcloud_prefix | truncate(45, True, '', 0) }}"
|
||||
hcloud_floating_ip_name: "{{hcloud_prefix}}"
|
||||
hcloud_primary_ip_name: "{{hcloud_prefix}}"
|
||||
hcloud_load_balancer_name: "{{hcloud_prefix}}"
|
|
@ -0,0 +1,12 @@
|
|||
#
|
||||
# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead.
|
||||
#
|
||||
---
|
||||
# Azure Pipelines will configure this value to something similar to
|
||||
# "azp-84824-1-hetzner-2-13-test-2-13-hcloud-3-9-1-default-i"
|
||||
hcloud_prefix: "tests"
|
||||
|
||||
# Used to namespace resources created by concurrent test pipelines/targets
|
||||
hcloud_run_ns: "{{ hcloud_prefix | md5 }}"
|
||||
hcloud_role_ns: "{{ role_name | split('_') | map('first') | join() }}"
|
||||
hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
|
|
@ -0,0 +1,7 @@
|
|||
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
hcloud_server_name: "{{ hcloud_ns }}"
|
||||
hcloud_floating_ip_name: "{{ hcloud_ns }}"
|
||||
hcloud_primary_ip_name: "{{ hcloud_ns }}"
|
||||
hcloud_load_balancer_name: "{{ hcloud_ns }}"
|
|
@ -1,224 +1,30 @@
|
|||
# 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)
|
||||
#
|
||||
# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead.
|
||||
#
|
||||
---
|
||||
- name: setup
|
||||
hetzner.hcloud.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: Check if cleanup.yml exists
|
||||
stat:
|
||||
path: "{{ role_path }}/tasks/cleanup.yml"
|
||||
register: cleanup_file
|
||||
|
||||
- name: setup Floating IP
|
||||
hetzner.hcloud.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: Check if prepare.yml exists
|
||||
stat:
|
||||
path: "{{ role_path }}/tasks/prepare.yml"
|
||||
register: prepare_file
|
||||
|
||||
- name: setup Load Balancer
|
||||
hetzner.hcloud.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: Include cleanup tasks
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when: cleanup_file.stat.exists
|
||||
|
||||
- name: setup Primary IP
|
||||
hetzner.hcloud.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: Include prepare tasks
|
||||
ansible.builtin.include_tasks: prepare.yml
|
||||
when: prepare_file.stat.exists
|
||||
|
||||
- name: test missing required parameter
|
||||
hetzner.hcloud.hcloud_rdns:
|
||||
state: present
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- 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
|
||||
hetzner.hcloud.hcloud_rdns:
|
||||
server: "not-existing"
|
||||
ip_address: "127.0.0.1"
|
||||
state: present
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- name: verify fail on not existing resou
|
||||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
- 'result.msg == "The selected server does not exist"'
|
||||
- name: test create rdns
|
||||
hetzner.hcloud.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"
|
||||
- block:
|
||||
- name: Include test tasks
|
||||
ansible.builtin.include_tasks: test.yml
|
||||
|
||||
- name: test create rdns idempotency
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_server:
|
||||
name: "{{ hcloud_server_name }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify cleanup
|
||||
assert:
|
||||
that:
|
||||
- result is success
|
||||
|
||||
- name: cleanup
|
||||
hetzner.hcloud.hcloud_floating_ip:
|
||||
name: "{{ hcloud_floating_ip_name }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify cleanup
|
||||
assert:
|
||||
that:
|
||||
- result is success
|
||||
|
||||
- name: cleanup
|
||||
hetzner.hcloud.hcloud_primary_ip:
|
||||
name: "{{ hcloud_primary_ip_name }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify cleanup
|
||||
assert:
|
||||
that:
|
||||
- result is success
|
||||
|
||||
- name: cleanup
|
||||
hetzner.hcloud.hcloud_load_balancer:
|
||||
name: "{{ hcloud_load_balancer_name }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify cleanup
|
||||
assert:
|
||||
that:
|
||||
- result is success
|
||||
always:
|
||||
- name: Include cleanup tasks
|
||||
ansible.builtin.include_tasks: cleanup.yml
|
||||
when: cleanup_file.stat.exists
|
||||
|
|
224
tests/integration/targets/hcloud_rdns/tasks/test.yml
Normal file
224
tests/integration/targets/hcloud_rdns/tasks/test.yml
Normal file
|
@ -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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_rdns:
|
||||
state: present
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- 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
|
||||
hetzner.hcloud.hcloud_rdns:
|
||||
server: "not-existing"
|
||||
ip_address: "127.0.0.1"
|
||||
state: present
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- name: verify fail on not existing resou
|
||||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
- 'result.msg == "The selected server does not exist"'
|
||||
- name: test create rdns
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.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
|
||||
hetzner.hcloud.hcloud_server:
|
||||
name: "{{ hcloud_server_name }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify cleanup
|
||||
assert:
|
||||
that:
|
||||
- result is success
|
||||
|
||||
- name: cleanup
|
||||
hetzner.hcloud.hcloud_floating_ip:
|
||||
name: "{{ hcloud_floating_ip_name }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify cleanup
|
||||
assert:
|
||||
that:
|
||||
- result is success
|
||||
|
||||
- name: cleanup
|
||||
hetzner.hcloud.hcloud_primary_ip:
|
||||
name: "{{ hcloud_primary_ip_name }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify cleanup
|
||||
assert:
|
||||
that:
|
||||
- result is success
|
||||
|
||||
- name: cleanup
|
||||
hetzner.hcloud.hcloud_load_balancer:
|
||||
name: "{{ hcloud_load_balancer_name }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify cleanup
|
||||
assert:
|
||||
that:
|
||||
- result is success
|
|
@ -0,0 +1,12 @@
|
|||
#
|
||||
# DO NOT EDIT THIS FILE! Please edit the files in tests/integration/common instead.
|
||||
#
|
||||
---
|
||||
# Azure Pipelines will configure this value to something similar to
|
||||
# "azp-84824-1-hetzner-2-13-test-2-13-hcloud-3-9-1-default-i"
|
||||
hcloud_prefix: "tests"
|
||||
|
||||
# Used to namespace resources created by concurrent test pipelines/targets
|
||||
hcloud_run_ns: "{{ hcloud_prefix | md5 }}"
|
||||
hcloud_role_ns: "{{ role_name | split('_') | map('first') | join() }}"
|
||||
hcloud_ns: "ansible-{{ hcloud_run_ns }}-{{ hcloud_role_ns }}"
|
|
@ -0,0 +1,4 @@
|
|||
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
hcloud_network_name: "{{ hcloud_ns }}"
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue