mirror of
https://github.com/ansible-collections/hetzner.hcloud
synced 2024-11-10 06:34:13 +00:00
test: improve *_info
modules tests (#299)
##### SUMMARY - Implement the new testing framework (prepare.yml/cleanup.yml #239) - Fix some uncovered test scenarios (related to #298). - Structure all the *_info tests using the following structure: ``` gather all [gather all with custom options...] gather all in check mode gather with id gather with name gather with labels [gather with custom option...] ```
This commit is contained in:
parent
e461a890fa
commit
8b24cf2522
33 changed files with 982 additions and 837 deletions
|
@ -6,34 +6,21 @@ exclude_paths:
|
|||
- .github/
|
||||
- changelogs/
|
||||
- tests/integration/targets/hcloud_certificate
|
||||
- tests/integration/targets/hcloud_certificate_info
|
||||
- tests/integration/targets/hcloud_datacenter_info
|
||||
- tests/integration/targets/hcloud_firewall
|
||||
- tests/integration/targets/hcloud_floating_ip
|
||||
- tests/integration/targets/hcloud_floating_ip_info
|
||||
- tests/integration/targets/hcloud_image_info
|
||||
- tests/integration/targets/hcloud_iso_info
|
||||
- tests/integration/targets/hcloud_load_balancer
|
||||
- tests/integration/targets/hcloud_load_balancer_info
|
||||
- tests/integration/targets/hcloud_load_balancer_network
|
||||
- tests/integration/targets/hcloud_load_balancer_service
|
||||
- tests/integration/targets/hcloud_load_balancer_target
|
||||
- tests/integration/targets/hcloud_load_balancer_type_info
|
||||
- tests/integration/targets/hcloud_network
|
||||
- tests/integration/targets/hcloud_network_info
|
||||
- tests/integration/targets/hcloud_placement_group
|
||||
- tests/integration/targets/hcloud_primary_ip
|
||||
- tests/integration/targets/hcloud_primary_ip_info
|
||||
- tests/integration/targets/hcloud_rdns
|
||||
- tests/integration/targets/hcloud_route
|
||||
- tests/integration/targets/hcloud_server
|
||||
- tests/integration/targets/hcloud_server_info
|
||||
- tests/integration/targets/hcloud_server_network
|
||||
- tests/integration/targets/hcloud_server_type_info
|
||||
- tests/integration/targets/hcloud_ssh_key
|
||||
- tests/integration/targets/hcloud_ssh_key_info
|
||||
- tests/integration/targets/hcloud_subnetwork
|
||||
- tests/integration/targets/hcloud_volume
|
||||
- tests/integration/targets/hcloud_volume_info
|
||||
- tests/integration/targets/setup_selfsigned_certificate
|
||||
- tests/integration/targets/setup_ssh_keypair
|
||||
|
|
27
tests/integration/README.md
Normal file
27
tests/integration/README.md
Normal file
|
@ -0,0 +1,27 @@
|
|||
# Integration tests
|
||||
|
||||
This document provides information to work with the integration tests.
|
||||
|
||||
## Guidelines
|
||||
|
||||
A set of guidelines to follow when writing integrations tests.
|
||||
|
||||
### Prepare and cleanup
|
||||
|
||||
The integration tests use a small testing framework that helps to set up and teardown any resources needed or generated by the tests. This small testing framework is located in the `tests/integration/common` directory. The files within the `common` directory are then duplicated and kept in sync in all the integration tests targets (`tests/integration/targets/hcloud_*`).
|
||||
|
||||
- Use a `tasks/prepare.yml` file to set up resources needed during the tests.
|
||||
- Use a `tasks/cleanup.yml` file to teardown resources from the `tasts/prepare.yml` tasks **and** the resources generated by the tests.
|
||||
- Use a `tasks/test.yml` file to defines your tests.
|
||||
- You may explode the tests into multiple `tasks/test-*.yml` files and import them in the `tasks/test.yml` file.
|
||||
- The `tasks/cleanup.yml` file cannot use variables present in the `tasks/prepare.yml` file because cleanup should also run before the prepare tasks.
|
||||
|
||||
### Naming convention
|
||||
|
||||
The integration tests handle a lot of different variables, names, identifier. To reduce this complexity, make sure to use the following naming conventions:
|
||||
|
||||
- Any test resources MUST be registered using the `test_<resource>` variable name (e.g. `test_server` or `test_floating_ip`) and MUST be created and cleaned in the `tasks/prepare.yml` and `tasks/cleanup.yml`. The scope of this variable is the entire target.
|
||||
- In `tasks/prepare.yml`, tasks names MUST start with: `Create test_<resource>` (e.g. `Create test_server` or `Create test_floating_ip`)
|
||||
- In `tasks/cleanup.yml`, tasks names MUST start with: `Cleanup test_<resource>` (e.g. `Cleanup test_server` or `Cleanup test_floating_ip`)
|
||||
- Any fact starting with `_` is scoped to the current file and MUST NOT be used outside of it.
|
||||
- Any test result MUST be registered using the `result` variable name unless it is required in a future test, in that case it MUST use the `<resource>` variable name as prefix.
|
|
@ -1,4 +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_certificate_name: "always-there-cert"
|
||||
hcloud_certificate_name: "{{ hcloud_ns }}"
|
||||
|
|
|
@ -1,38 +1,77 @@
|
|||
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
- name: test gather hcloud certificate infos in check mode
|
||||
- name: Gather hcloud_certificate_info
|
||||
hetzner.hcloud.hcloud_certificate_info:
|
||||
register: hcloud_certificate
|
||||
check_mode: true
|
||||
- name: verify test gather hcloud certificate infos in check mode
|
||||
assert:
|
||||
register: result
|
||||
- name: Verify hcloud_certificate_info
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- hcloud_certificate.hcloud_certificate_info| list | count >= 1
|
||||
- result.hcloud_certificate_info | list | count >= 1
|
||||
|
||||
- name: test gather hcloud certificate infos
|
||||
- name: Gather hcloud_certificate_info in check mode
|
||||
hetzner.hcloud.hcloud_certificate_info:
|
||||
register: hcloud_certificate
|
||||
check_mode: true
|
||||
- name: verify test gather hcloud certificate infos
|
||||
assert:
|
||||
register: result
|
||||
- name: Verify hcloud_certificate_info in check mode
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- hcloud_certificate.hcloud_certificate_info| list | count >= 1
|
||||
- result.hcloud_certificate_info | list | count >= 1
|
||||
|
||||
- name: test gather hcloud certificate infos with correct label selector
|
||||
- name: Gather hcloud_certificate_info with correct id
|
||||
hetzner.hcloud.hcloud_certificate_info:
|
||||
id: "{{ test_certificate.hcloud_certificate.id }}"
|
||||
register: result
|
||||
- name: Verify hcloud_certificate_info with correct id
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_certificate_info | list | count == 1
|
||||
|
||||
- name: Gather hcloud_certificate_info with wrong id
|
||||
hetzner.hcloud.hcloud_certificate_info:
|
||||
id: "{{ test_certificate.hcloud_certificate.id }}4321"
|
||||
ignore_errors: true
|
||||
register: result
|
||||
- name: Verify hcloud_certificate_info with wrong id
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result is failed
|
||||
|
||||
- name: Gather hcloud_certificate_info with correct name
|
||||
hetzner.hcloud.hcloud_certificate_info:
|
||||
name: "{{ hcloud_certificate_name }}"
|
||||
register: result
|
||||
- name: Verify hcloud_certificate_info with correct name
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_certificate_info | list | count == 1
|
||||
|
||||
- name: Gather hcloud_certificate_info with wrong name
|
||||
hetzner.hcloud.hcloud_certificate_info:
|
||||
name: "{{ hcloud_certificate_name }}-invalid"
|
||||
register: result
|
||||
- name: Verify hcloud_certificate_info with wrong name
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_certificate_info | list | count == 0
|
||||
|
||||
- name: Gather hcloud_certificate_info with correct label selector
|
||||
hetzner.hcloud.hcloud_certificate_info:
|
||||
label_selector: "key=value"
|
||||
register: hcloud_certificate
|
||||
- name: verify test gather hcloud certificate infos with correct label selector
|
||||
assert:
|
||||
register: result
|
||||
- name: Verify hcloud_certificate_info with correct label selector
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- hcloud_certificate.hcloud_certificate_info|selectattr('name','equalto','{{ hcloud_certificate_name }}') | list | count == 1
|
||||
- >
|
||||
result.hcloud_certificate_info
|
||||
| selectattr('name', 'equalto', '{{ hcloud_certificate_name }}')
|
||||
| list | count == 1
|
||||
|
||||
- name: test gather hcloud certificate infos with wrong label selector
|
||||
- name: Gather hcloud_certificate_info 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:
|
||||
register: result
|
||||
- name: Verify hcloud_certificate_info with wrong label selector
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- hcloud_certificate.hcloud_certificate_info | list | count == 0
|
||||
- result.hcloud_certificate_info | list | count == 0
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
hcloud_datacenter_name: "fsn1-dc14"
|
||||
hcloud_datacenter_id: 4
|
||||
hcloud_location_name: "fsn1"
|
||||
hcloud_datacenter_name: fsn1-dc14
|
||||
hcloud_location_name: fsn1
|
||||
|
|
|
@ -1,39 +1,58 @@
|
|||
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
- name: test gather hcloud datacenter infos
|
||||
- name: Gather hcloud_datacenter_info
|
||||
hetzner.hcloud.hcloud_datacenter_info:
|
||||
register: hcloud_datacenters
|
||||
|
||||
- name: verify test gather hcloud datacenter infos
|
||||
assert:
|
||||
register: result
|
||||
- name: Verify hcloud_datacenter_info
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- hcloud_datacenters.hcloud_datacenter_info| list | count >= 5
|
||||
- result.hcloud_datacenter_info | list | count >= 5
|
||||
|
||||
- name: test gather hcloud datacenter infos in check mode
|
||||
- name: Gather hcloud_datacenter_info 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:
|
||||
register: result
|
||||
- name: Verify hcloud_datacenter_info in check mode
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- hcloud_datacenters.hcloud_datacenter_info| list | count >= 5
|
||||
- result.hcloud_datacenter_info | list | count >= 5
|
||||
|
||||
- name: test gather hcloud datacenter infos with correct name
|
||||
- name: Gather hcloud_datacenter_info with correct id
|
||||
hetzner.hcloud.hcloud_datacenter_info:
|
||||
name: "{{hcloud_datacenter_name}}"
|
||||
register: hcloud_datacenter
|
||||
- name: verify test gather hcloud datacenter with correct name
|
||||
assert:
|
||||
id: "{{ hcloud_datacenter_id }}"
|
||||
register: result
|
||||
- name: Verify hcloud_datacenter_info with correct id
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- hcloud_datacenter.hcloud_datacenter_info|selectattr('name','equalto','{{ hcloud_datacenter_name }}') |selectattr('location','equalto','{{ hcloud_location_name }}') | list | count == 1
|
||||
- result.hcloud_datacenter_info | list | count == 1
|
||||
- result.hcloud_datacenter_info[0].name == hcloud_datacenter_name
|
||||
- result.hcloud_datacenter_info[0].location == hcloud_location_name
|
||||
|
||||
- name: test gather hcloud datacenter infos with correct id
|
||||
- name: Gather hcloud_datacenter_info with wrong id
|
||||
hetzner.hcloud.hcloud_datacenter_info:
|
||||
id: "{{hcloud_datacenter_id}}"
|
||||
register: hcloud_datacenter
|
||||
- name: verify test gather hcloud datacenter with correct id
|
||||
assert:
|
||||
id: "{{ hcloud_datacenter_id }}4321"
|
||||
ignore_errors: true
|
||||
register: result
|
||||
- name: Verify hcloud_datacenter_info with wrong id
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- hcloud_datacenter.hcloud_datacenter_info|selectattr('name','equalto','{{ hcloud_datacenter_name }}') | list | count == 1
|
||||
- result is failed
|
||||
|
||||
- name: Gather hcloud_datacenter_info with correct name
|
||||
hetzner.hcloud.hcloud_datacenter_info:
|
||||
name: "{{ hcloud_datacenter_name }}"
|
||||
register: result
|
||||
- name: Verify hcloud_datacenter_info with correct name
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_datacenter_info | list | count == 1
|
||||
|
||||
- name: Gather hcloud_datacenter_info with wrong name
|
||||
hetzner.hcloud.hcloud_datacenter_info:
|
||||
name: "{{ hcloud_datacenter_name }}-invalid"
|
||||
register: result
|
||||
- name: Verify hcloud_datacenter_info with wrong name
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_datacenter_info | list | count == 0
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
- name: Cleanup test_floating_ip
|
||||
hetzner.hcloud.hcloud_floating_ip:
|
||||
name: "{{ hcloud_floating_ip_name }}"
|
||||
state: absent
|
|
@ -0,0 +1,9 @@
|
|||
---
|
||||
- name: Create test_floating_ip
|
||||
hetzner.hcloud.hcloud_floating_ip:
|
||||
name: "{{ hcloud_floating_ip_name }}"
|
||||
home_location: fsn1
|
||||
type: ipv4
|
||||
labels:
|
||||
key: value
|
||||
register: test_floating_ip
|
|
@ -1,86 +1,77 @@
|
|||
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
- name: 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
|
||||
- name: Gather hcloud_floating_ip_info
|
||||
hetzner.hcloud.hcloud_floating_ip_info:
|
||||
register: hcloud_floating_ips
|
||||
- name: verify test gather hcloud floating ip infos
|
||||
assert:
|
||||
register: result
|
||||
- name: Verify hcloud_floating_ip_info
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- hcloud_floating_ips.hcloud_floating_ip_info| list | count >= 1
|
||||
- result.hcloud_floating_ip_info | list | count >= 1
|
||||
|
||||
- name: test gather hcloud floating ip infos in check mode
|
||||
- name: Gather hcloud_floating_ip_info 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
|
||||
- name: Verify hcloud_floating_ip_info in check mode
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_floating_ip_info | list | count >= 1
|
||||
|
||||
- name: Gather hcloud_floating_ip_info with correct id
|
||||
hetzner.hcloud.hcloud_floating_ip_info:
|
||||
id: "{{ test_floating_ip.hcloud_floating_ip.id }}"
|
||||
register: result
|
||||
- name: Verify hcloud_floating_ip_info with correct id
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_floating_ip_info | list | count == 1
|
||||
|
||||
- name: Gather hcloud_floating_ip_info with wrong id
|
||||
hetzner.hcloud.hcloud_floating_ip_info:
|
||||
id: "{{ test_floating_ip.hcloud_floating_ip.id }}4321"
|
||||
ignore_errors: true
|
||||
- name: verify test gather hcloud floating ip with wrong id
|
||||
assert:
|
||||
register: result
|
||||
- name: Verify hcloud_floating_ip_info with wrong id
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result is failed
|
||||
|
||||
- name: cleanup
|
||||
hetzner.hcloud.hcloud_floating_ip:
|
||||
id: "{{ test_floating_ip.hcloud_floating_ip.id }}"
|
||||
state: absent
|
||||
# - name: Gather hcloud_floating_ip_info with correct name
|
||||
# hetzner.hcloud.hcloud_floating_ip_info:
|
||||
# name: "{{ hcloud_floating_ip_name }}"
|
||||
# register: result
|
||||
# - name: Verify hcloud_floating_ip_info with correct name
|
||||
# ansible.builtin.assert:
|
||||
# that:
|
||||
# - result.hcloud_floating_ip_info | list | count == 1
|
||||
|
||||
# - name: Gather hcloud_floating_ip_info with wrong name
|
||||
# hetzner.hcloud.hcloud_floating_ip_info:
|
||||
# name: "{{ hcloud_floating_ip_name }}-invalid"
|
||||
# register: result
|
||||
# - name: Verify hcloud_floating_ip_info with wrong name
|
||||
# ansible.builtin.assert:
|
||||
# that:
|
||||
# - result.hcloud_floating_ip_info | list | count == 0
|
||||
|
||||
- name: Gather hcloud_floating_ip_info with correct label selector
|
||||
hetzner.hcloud.hcloud_floating_ip_info:
|
||||
label_selector: "key=value"
|
||||
register: result
|
||||
- name: verify cleanup
|
||||
assert:
|
||||
- name: Verify hcloud_floating_ip_info with correct label selector
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result is success
|
||||
- >
|
||||
result.hcloud_floating_ip_info
|
||||
| selectattr('name', 'equalto', '{{ hcloud_floating_ip_name }}')
|
||||
| list | count == 1
|
||||
|
||||
- name: Gather hcloud_floating_ip_info with wrong label selector
|
||||
hetzner.hcloud.hcloud_floating_ip_info:
|
||||
label_selector: "key!=value"
|
||||
register: result
|
||||
- name: Verify hcloud_floating_ip_info with wrong label selector
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_floating_ip_info | list | count == 0
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
hcloud_test_image_name: "always-there-snapshot"
|
||||
hcloud_test_image_id: 10164049
|
||||
hcloud_test_image_name_os: "ubuntu-22.04"
|
||||
hcloud_snapshot_id: 10164049
|
||||
hcloud_snapshot_name: always-there-snapshot
|
||||
hcloud_image_name: ubuntu-22.04
|
||||
|
|
|
@ -1,92 +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: test gather hcloud image infos with type system
|
||||
- name: Gather hcloud_image_info
|
||||
hetzner.hcloud.hcloud_image_info:
|
||||
register: hcloud_images
|
||||
- name: verify test gather hcloud image infos in check mode
|
||||
assert:
|
||||
register: result
|
||||
- name: Verify hcloud_image_info
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- hcloud_images.hcloud_image_info| list | count > 2
|
||||
- result.hcloud_image_info | list | count >= 3
|
||||
|
||||
- name: test gather hcloud image infos in check mode
|
||||
- name: Gather hcloud_image_info with architecture
|
||||
hetzner.hcloud.hcloud_image_info:
|
||||
architecture: arm
|
||||
register: result
|
||||
- name: Verify hcloud_image_info with architecture
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_image_info | selectattr('architecture', 'equalto', 'x86') | list | count == 0
|
||||
- result.hcloud_image_info | selectattr('architecture', 'equalto', 'arm') | list | count > 2
|
||||
|
||||
- name: Gather hcloud_image_info in check mode
|
||||
hetzner.hcloud.hcloud_image_info:
|
||||
check_mode: true
|
||||
register: hcloud_images
|
||||
|
||||
- name: verify test gather hcloud image infos in check mode
|
||||
assert:
|
||||
register: result
|
||||
- name: Verify hcloud_image_info in check mode
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- hcloud_images.hcloud_image_info| list | count > 2
|
||||
- result.hcloud_image_info | list | count >= 3
|
||||
|
||||
- name: test gather hcloud image infos with correct label selector
|
||||
- name: Gather hcloud_image_info with correct id
|
||||
hetzner.hcloud.hcloud_image_info:
|
||||
label_selector: "key=value"
|
||||
id: "{{ hcloud_snapshot_id }}"
|
||||
type: snapshot
|
||||
register: hcloud_images
|
||||
- name: verify test gather hcloud image with correct label selector
|
||||
assert:
|
||||
register: result
|
||||
- name: Verify hcloud_image_info with correct id
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- hcloud_images.hcloud_image_info|selectattr('description','equalto','{{ hcloud_test_image_name }}') | list | count == 1
|
||||
- result.hcloud_image_info | list | count == 1
|
||||
|
||||
- name: test gather hcloud image infos with wrong label selector
|
||||
- name: Gather hcloud_image_info with wrong id
|
||||
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"
|
||||
id: "{{ hcloud_snapshot_id }}4321"
|
||||
type: snapshot
|
||||
ignore_errors: true
|
||||
register: result
|
||||
- name: verify test gather hcloud image with wrong id
|
||||
assert:
|
||||
- name: Verify hcloud_image_info with wrong id
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result is failed
|
||||
|
||||
- name: test gather hcloud image infos with name
|
||||
- name: Gather hcloud_image_info with correct 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:
|
||||
name: "{{ hcloud_image_name }}"
|
||||
register: result
|
||||
- name: Verify hcloud_image_info with correct name
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- hcloud_images.hcloud_image_info | list | count == 1
|
||||
- hcloud_images.hcloud_image_info[0].architecture == "x86"
|
||||
- result.hcloud_image_info | list | count == 1
|
||||
- result.hcloud_image_info[0].architecture == "x86"
|
||||
|
||||
- name: test gather hcloud image infos with name and architecture
|
||||
- name: Gather hcloud_image_info with wrong name
|
||||
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:
|
||||
name: "{{ hcloud_image_name }}-invalid"
|
||||
register: result
|
||||
- name: Verify hcloud_image_info with wrong name
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- hcloud_images.hcloud_image_info | list | count == 1
|
||||
- hcloud_images.hcloud_image_info[0].architecture == "arm"
|
||||
- result.hcloud_image_info | list | count == 0
|
||||
|
||||
- name: test gather hcloud image infos with architecture
|
||||
- name: Gather hcloud_image_info with correct name and architecture
|
||||
hetzner.hcloud.hcloud_image_info:
|
||||
name: "{{ hcloud_image_name }}"
|
||||
architecture: arm
|
||||
register: hcloud_images
|
||||
- name: verify test gather hcloud image infos with name
|
||||
assert:
|
||||
register: result
|
||||
- name: Verify hcloud_image_info with correct name
|
||||
ansible.builtin.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
|
||||
- result.hcloud_image_info | list | count == 1
|
||||
- result.hcloud_image_info[0].architecture == "arm"
|
||||
|
||||
- name: Gather hcloud_image_info with correct label selector
|
||||
hetzner.hcloud.hcloud_image_info:
|
||||
label_selector: "key=value"
|
||||
type: snapshot
|
||||
register: result
|
||||
- name: Verify hcloud_image_info with correct label selector
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
# Snapshot names are stored in the description field
|
||||
- >
|
||||
result.hcloud_image_info
|
||||
| selectattr('description', 'equalto', '{{ hcloud_snapshot_name }}')
|
||||
| list | count == 1
|
||||
|
||||
- name: Gather hcloud_image_info with wrong label selector
|
||||
hetzner.hcloud.hcloud_image_info:
|
||||
label_selector: "key!=value"
|
||||
type: snapshot
|
||||
register: result
|
||||
- name: Verify hcloud_image_info with wrong label selector
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_image_info | list | count == 0
|
||||
|
|
|
@ -1,54 +1,71 @@
|
|||
# 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
|
||||
- name: Gather hcloud_iso_info
|
||||
hetzner.hcloud.hcloud_iso_info:
|
||||
register: result
|
||||
- name: Verify hcloud_iso_info
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_iso_info | list | count >= 1
|
||||
|
||||
- name: Gather hcloud_iso_info in check mode
|
||||
hetzner.hcloud.hcloud_iso_info:
|
||||
check_mode: true
|
||||
register: result
|
||||
- name: Verify hcloud_iso_info in check mode
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_iso_info | list | count >= 1
|
||||
|
||||
- name: Gather hcloud_iso_info with correct id
|
||||
hetzner.hcloud.hcloud_iso_info:
|
||||
id: "{{ hcloud_iso_id }}"
|
||||
register: hcloud_iso
|
||||
- name: verify test gather hcloud image with correct id
|
||||
assert:
|
||||
register: result
|
||||
- name: Verify hcloud_iso_info with correct id
|
||||
ansible.builtin.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 }}"
|
||||
- result.hcloud_iso_info | list | count == 1
|
||||
- result.hcloud_iso_info[0].id == "{{ hcloud_iso_id }}"
|
||||
- result.hcloud_iso_info[0].name == "{{ hcloud_iso_name }}"
|
||||
- result.hcloud_iso_info[0].architecture == "{{ hcloud_iso_architecture }}"
|
||||
- result.hcloud_iso_info[0].type == "{{ hcloud_iso_type }}"
|
||||
|
||||
- name: test gather hcloud iso infos with wrong id
|
||||
- name: Gather hcloud_iso_info with wrong id
|
||||
hetzner.hcloud.hcloud_iso_info:
|
||||
id: "{{ hcloud_iso_id }}1"
|
||||
id: "{{ hcloud_iso_id }}4321"
|
||||
ignore_errors: true
|
||||
register: result
|
||||
- name: verify test gather hcloud image with wrong id
|
||||
assert:
|
||||
- name: Verify hcloud_iso_info with wrong id
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result is failed
|
||||
|
||||
- name: test gather hcloud iso infos with name
|
||||
- name: Gather hcloud_iso_info with correct name
|
||||
hetzner.hcloud.hcloud_iso_info:
|
||||
name: "{{ hcloud_iso_name }}"
|
||||
register: hcloud_iso
|
||||
- name: verify test gather hcloud iso infos with name
|
||||
assert:
|
||||
register: result
|
||||
- name: Verify hcloud_iso_info with correct name
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- hcloud_iso.hcloud_iso_info | list | count == 1
|
||||
- result.hcloud_iso_info | list | count == 1
|
||||
|
||||
- name: test list hcloud iso infos with architecture
|
||||
- name: Gather hcloud_iso_info with wrong name
|
||||
hetzner.hcloud.hcloud_iso_info:
|
||||
name: "{{ hcloud_iso_name }}-invalid"
|
||||
register: result
|
||||
- name: Verify hcloud_iso_info with wrong name
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_iso_info | list | count == 0
|
||||
|
||||
- name: Gather hcloud_iso_info with architecture
|
||||
hetzner.hcloud.hcloud_iso_info:
|
||||
architecture: arm
|
||||
register: hcloud_iso
|
||||
- name: verify test list hcloud iso infos with architecture
|
||||
assert:
|
||||
register: result
|
||||
- name: Verify hcloud_iso_info with architecture
|
||||
ansible.builtin.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
|
||||
- result.hcloud_iso_info | list | count > 2
|
||||
- result.hcloud_iso_info | selectattr('architecture', 'equalto', 'x86') | list | count == 0
|
||||
- result.hcloud_iso_info | selectattr('architecture', 'equalto', 'arm') | list | count > 2
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
---
|
||||
- name: Cleanup test_load_balancer
|
||||
hetzner.hcloud.hcloud_load_balancer:
|
||||
name: "{{ hcloud_load_balancer_name }}"
|
||||
state: absent
|
||||
|
||||
- name: Cleanup test_server
|
||||
hetzner.hcloud.hcloud_server:
|
||||
name: "{{ hcloud_server_name }}"
|
||||
state: absent
|
|
@ -0,0 +1,33 @@
|
|||
---
|
||||
- name: Create test_server
|
||||
hetzner.hcloud.hcloud_server:
|
||||
name: "{{ hcloud_server_name }}"
|
||||
server_type: cx11
|
||||
image: ubuntu-22.04
|
||||
state: started
|
||||
register: test_server
|
||||
|
||||
- name: Create test_load_balancer
|
||||
hetzner.hcloud.hcloud_load_balancer:
|
||||
name: "{{ hcloud_load_balancer_name }}"
|
||||
load_balancer_type: lb11
|
||||
network_zone: eu-central
|
||||
labels:
|
||||
key: value
|
||||
register: test_load_balancer
|
||||
|
||||
- name: Create test_load_balancer_target
|
||||
hetzner.hcloud.hcloud_load_balancer_target:
|
||||
type: "server"
|
||||
load_balancer: "{{ hcloud_load_balancer_name }}"
|
||||
server: "{{ hcloud_server_name }}"
|
||||
state: present
|
||||
register: test_load_balancer_target
|
||||
|
||||
- name: Create test_load_balancer_service
|
||||
hetzner.hcloud.hcloud_load_balancer_service:
|
||||
load_balancer: "{{ hcloud_load_balancer_name }}"
|
||||
protocol: "http"
|
||||
listen_port: 80
|
||||
state: present
|
||||
register: test_load_balancer_service
|
|
@ -1,127 +1,84 @@
|
|||
# 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
|
||||
- name: Gather hcloud_load_balancer_info
|
||||
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:
|
||||
register: result
|
||||
- name: Verify hcloud_load_balancer_info
|
||||
ansible.builtin.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
|
||||
- result.hcloud_load_balancer_info | list | count >= 1
|
||||
|
||||
- name: test gather hcloud Load Balancer infos in check mode
|
||||
- name: Gather hcloud_load_balancer_info 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
|
||||
- name: Verify hcloud_load_balancer_info in check mode
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_load_balancer_info | list | count >= 1
|
||||
|
||||
- name: Gather hcloud_load_balancer_info with correct id
|
||||
hetzner.hcloud.hcloud_load_balancer_info:
|
||||
id: "{{ test_load_balancer.hcloud_load_balancer.id }}"
|
||||
register: result
|
||||
- name: Verify hcloud_load_balancer_info with correct id
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_load_balancer_info | list | count == 1
|
||||
- result.hcloud_load_balancer_info[0].targets | list | count == 1
|
||||
- result.hcloud_load_balancer_info[0].targets | selectattr('type', 'equalto', 'server') | list | count == 1
|
||||
- result.hcloud_load_balancer_info[0].targets | selectattr('server', 'equalto', '{{ hcloud_server_name }}') | list | count == 1
|
||||
- result.hcloud_load_balancer_info[0].services | list | count == 1
|
||||
- result.hcloud_load_balancer_info[0].services | selectattr('protocol', 'equalto', 'http') | list | count == 1
|
||||
- result.hcloud_load_balancer_info[0].services | selectattr('listen_port', 'equalto', 80) | list | count == 1
|
||||
- result.hcloud_load_balancer_info[0].services | selectattr('destination_port', 'equalto', 80) | list | count == 1
|
||||
|
||||
- name: Gather hcloud_load_balancer_info with wrong id
|
||||
hetzner.hcloud.hcloud_load_balancer_info:
|
||||
id: "{{ test_load_balancer.hcloud_load_balancer.id }}4321"
|
||||
ignore_errors: true
|
||||
- name: verify test gather hcloud Load Balancer with wrong id
|
||||
assert:
|
||||
register: result
|
||||
- name: Verify hcloud_load_balancer_info with wrong id
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result is failed
|
||||
|
||||
- name: cleanup
|
||||
hetzner.hcloud.hcloud_load_balancer:
|
||||
id: "{{ test_load_balancer.hcloud_load_balancer.id }}"
|
||||
state: absent
|
||||
- name: Gather hcloud_load_balancer_info with correct name
|
||||
hetzner.hcloud.hcloud_load_balancer_info:
|
||||
name: "{{ hcloud_load_balancer_name }}"
|
||||
register: result
|
||||
- name: verify cleanup
|
||||
assert:
|
||||
- name: Verify hcloud_load_balancer_info with correct name
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result is success
|
||||
- result.hcloud_load_balancer_info | list | count == 1
|
||||
|
||||
- name: Gather hcloud_load_balancer_info with wrong name
|
||||
hetzner.hcloud.hcloud_load_balancer_info:
|
||||
name: "{{ hcloud_load_balancer_name }}-invalid"
|
||||
register: result
|
||||
- name: Verify hcloud_load_balancer_info with wrong name
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_load_balancer_info | list | count == 0
|
||||
|
||||
- name: Gather hcloud_load_balancer_info with correct label selector
|
||||
hetzner.hcloud.hcloud_load_balancer_info:
|
||||
label_selector: "key=value"
|
||||
register: result
|
||||
- name: Verify hcloud_load_balancer_info with correct label selector
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- >
|
||||
result.hcloud_load_balancer_info
|
||||
| selectattr('name', 'equalto', '{{ hcloud_load_balancer_name }}')
|
||||
| list | count == 1
|
||||
|
||||
- name: Gather hcloud_load_balancer_info with wrong label selector
|
||||
hetzner.hcloud.hcloud_load_balancer_info:
|
||||
label_selector: "key!=value"
|
||||
register: result
|
||||
- name: Verify hcloud_load_balancer_info with wrong label selector
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_load_balancer_info | list | count == 0
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Copyright: (c) 2020, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
hcloud_load_balancer_type_name: "lb11"
|
||||
hcloud_load_balancer_type_id: 1
|
||||
hcloud_load_balancer_type_name: lb11
|
||||
|
|
|
@ -1,38 +1,56 @@
|
|||
# Copyright: (c) 2020, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
- name: test gather hcloud Load Balancer type infos
|
||||
- name: Gather hcloud_load_balancer_type_info
|
||||
hetzner.hcloud.hcloud_load_balancer_type_info:
|
||||
register: hcloud_load_balancer_types
|
||||
- name: verify test gather hcloud Load Balancer type infos
|
||||
assert:
|
||||
register: result
|
||||
- name: Verify hcloud_load_balancer_type_info
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- hcloud_load_balancer_types.hcloud_load_balancer_type_info| list | count >= 1
|
||||
- result.hcloud_load_balancer_type_info | list | count >= 1
|
||||
|
||||
- name: test gather hcloud Load Balancer type infos in check mode
|
||||
- name: Gather hcloud_load_balancer_type_info 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:
|
||||
register: result
|
||||
- name: Verify hcloud_load_balancer_type_info in check mode
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- hcloud_load_balancer_types.hcloud_load_balancer_type_info| list | count >= 1
|
||||
- result.hcloud_load_balancer_type_info | list | count >= 1
|
||||
|
||||
- name: test gather hcloud Load Balancer type infos with name
|
||||
- name: Gather hcloud_load_balancer_type_info with correct id
|
||||
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:
|
||||
id: "{{ hcloud_load_balancer_type_id }}"
|
||||
register: result
|
||||
- name: Verify hcloud_load_balancer_type_info with correct id
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- hcloud_load_balancer_types.hcloud_load_balancer_type_info|selectattr('name','equalto','{{ hcloud_load_balancer_type_name }}') | list | count == 1
|
||||
- result.hcloud_load_balancer_type_info | list | count == 1
|
||||
|
||||
- name: test gather hcloud Load Balancer type infos with correct id
|
||||
- name: Gather hcloud_load_balancer_type_info with wrong 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:
|
||||
id: "{{ hcloud_load_balancer_type_id }}4321"
|
||||
ignore_errors: true
|
||||
register: result
|
||||
- name: Verify hcloud_load_balancer_type_info with wrong id
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- hcloud_load_balancer_types.hcloud_load_balancer_type_info|selectattr('name','equalto','{{ hcloud_load_balancer_type_name }}') | list | count == 1
|
||||
- result is failed
|
||||
|
||||
- name: Gather hcloud_load_balancer_type_info with correct name
|
||||
hetzner.hcloud.hcloud_load_balancer_type_info:
|
||||
name: "{{ hcloud_load_balancer_type_name }}"
|
||||
register: result
|
||||
- name: Verify hcloud_load_balancer_type_info with correct name
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_load_balancer_type_info | list | count == 1
|
||||
|
||||
- name: Gather hcloud_load_balancer_type_info with wrong name
|
||||
hetzner.hcloud.hcloud_load_balancer_type_info:
|
||||
name: "{{ hcloud_load_balancer_type_name }}-invalid"
|
||||
register: result
|
||||
- name: Verify hcloud_load_balancer_type_info with wrong name
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_load_balancer_type_info | list | count == 0
|
||||
|
|
|
@ -18,24 +18,6 @@
|
|||
that:
|
||||
- result.hcloud_location_info | list | count >= 5
|
||||
|
||||
- name: Gather hcloud_location_info with correct name
|
||||
hetzner.hcloud.hcloud_location_info:
|
||||
name: "{{ hcloud_location_name }}"
|
||||
register: result
|
||||
- name: Verify hcloud_location_info with correct name
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_location_info | selectattr('name', 'equalto', '{{ hcloud_location_name }}') | list | count == 1
|
||||
|
||||
- name: Gather hcloud_location_info with wrong name
|
||||
hetzner.hcloud.hcloud_location_info:
|
||||
name: "{{ hcloud_location_name }}1"
|
||||
register: result
|
||||
- name: Verify hcloud_location_info with wrong name
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_location_info | list | count == 0
|
||||
|
||||
- name: Gather hcloud_location_info with correct id
|
||||
hetzner.hcloud.hcloud_location_info:
|
||||
id: "{{ hcloud_location_id }}"
|
||||
|
@ -43,14 +25,32 @@
|
|||
- name: Verify hcloud_location_info with correct id
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_location_info | selectattr('name', 'equalto', '{{ hcloud_location_name }}') | list | count == 1
|
||||
- result.hcloud_location_info | list | count == 1
|
||||
|
||||
- name: Gather hcloud_location_info with wrong id
|
||||
hetzner.hcloud.hcloud_location_info:
|
||||
id: 4711
|
||||
register: result
|
||||
id: "{{ hcloud_location_id }}4321"
|
||||
ignore_errors: true
|
||||
register: result
|
||||
- name: Verify hcloud_location_info with wrong id
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result is failed
|
||||
|
||||
- name: Gather hcloud_location_info with correct name
|
||||
hetzner.hcloud.hcloud_location_info:
|
||||
name: "{{ hcloud_location_name }}"
|
||||
register: result
|
||||
- name: Verify hcloud_location_info with correct name
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_location_info | list | count == 1
|
||||
|
||||
- name: Gather hcloud_location_info with wrong name
|
||||
hetzner.hcloud.hcloud_location_info:
|
||||
name: "{{ hcloud_location_name }}-invalid"
|
||||
register: result
|
||||
- name: Verify hcloud_location_info with wrong name
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_location_info | list | count == 0
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
- name: Cleanup test_network
|
||||
hetzner.hcloud.hcloud_network:
|
||||
name: "{{ hcloud_network_name }}"
|
||||
state: absent
|
|
@ -0,0 +1,23 @@
|
|||
---
|
||||
- name: Create test_network
|
||||
hetzner.hcloud.hcloud_network:
|
||||
name: "{{ hcloud_network_name }}"
|
||||
ip_range: 10.0.0.0/16
|
||||
labels:
|
||||
key: value
|
||||
register: test_network
|
||||
|
||||
- name: Create test_subnetwork
|
||||
hetzner.hcloud.hcloud_subnetwork:
|
||||
network: "{{ hcloud_network_name }}"
|
||||
type: server
|
||||
network_zone: eu-central
|
||||
ip_range: 10.0.1.0/24
|
||||
register: test_subnetwork
|
||||
|
||||
- name: Create test_route
|
||||
hetzner.hcloud.hcloud_route:
|
||||
network: "{{ hcloud_network_name }}"
|
||||
destination: 10.0.3.0/24
|
||||
gateway: 10.0.2.1
|
||||
register: test_route
|
|
@ -1,117 +1,79 @@
|
|||
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
- name: setup ensure network is absent
|
||||
hetzner.hcloud.hcloud_network:
|
||||
name: "{{ hcloud_network_name }}"
|
||||
state: absent
|
||||
- name: Gather hcloud_network_info
|
||||
hetzner.hcloud.hcloud_network_info:
|
||||
register: result
|
||||
- name: Verify hcloud_network_info
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_network_info | list | count >= 1
|
||||
|
||||
- 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
|
||||
- name: 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:
|
||||
register: result
|
||||
- name: Verify hcloud_network_info in check mode
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- hcloud_network.hcloud_network_info | selectattr('name','equalto','{{ hcloud_network_name }}') | list | count >= 1
|
||||
- result.hcloud_network_info | list | count >= 1
|
||||
|
||||
- name: test gather hcloud network info with correct label selector
|
||||
- name: Gather hcloud_network_info with correct id
|
||||
hetzner.hcloud.hcloud_network_info:
|
||||
id: "{{ test_network.hcloud_network.id }}"
|
||||
register: result
|
||||
- name: Verify hcloud_network_info with correct id
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_network_info | list | count == 1
|
||||
- result.hcloud_network_info[0].subnetworks | list | count >= 1
|
||||
- result.hcloud_network_info[0].routes | list | count >= 1
|
||||
|
||||
- name: Gather hcloud_network_info with wrong id
|
||||
hetzner.hcloud.hcloud_network_info:
|
||||
id: "{{ test_network.hcloud_network.id }}4321"
|
||||
ignore_errors: true
|
||||
register: result
|
||||
- name: Verify hcloud_network_info with wrong id
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result is failed
|
||||
|
||||
- name: Gather hcloud_network_info with correct name
|
||||
hetzner.hcloud.hcloud_network_info:
|
||||
name: "{{ hcloud_network_name }}"
|
||||
register: result
|
||||
- name: Verify hcloud_network_info with correct name
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_network_info | list | count == 1
|
||||
|
||||
- name: Gather hcloud_network_info with wrong name
|
||||
hetzner.hcloud.hcloud_network_info:
|
||||
name: "{{ hcloud_network_name }}-invalid"
|
||||
register: result
|
||||
- name: Verify hcloud_network_info with wrong name
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_network_info | list | count == 0
|
||||
|
||||
- name: Gather hcloud_network_info with correct label selector
|
||||
hetzner.hcloud.hcloud_network_info:
|
||||
label_selector: "key=value"
|
||||
register: hcloud_network
|
||||
- name: verify test gather hcloud network with correct label selector
|
||||
assert:
|
||||
register: result
|
||||
- name: Verify hcloud_network_info with correct label selector
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- hcloud_network.hcloud_network_info | selectattr('name','equalto','{{ hcloud_network_name }}') | list | count >= 1
|
||||
- >
|
||||
result.hcloud_network_info
|
||||
| selectattr('name', 'equalto', '{{ hcloud_network_name }}')
|
||||
| list | count == 1
|
||||
|
||||
- name: test gather hcloud network info with wrong label selector
|
||||
- name: 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:
|
||||
register: result
|
||||
- name: Verify hcloud_network_info with wrong label selector
|
||||
ansible.builtin.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:
|
||||
id: "4711"
|
||||
register: hcloud_network
|
||||
ignore_errors: true
|
||||
- name: verify test gather hcloud network with wrong id
|
||||
assert:
|
||||
that:
|
||||
- hcloud_network is failed
|
||||
|
||||
- name: cleanup
|
||||
hetzner.hcloud.hcloud_network:
|
||||
name: "{{ hcloud_network_name }}"
|
||||
state: absent
|
||||
- result.hcloud_network_info | list | count == 0
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
- name: Cleanup test_primary_ip
|
||||
hetzner.hcloud.hcloud_primary_ip:
|
||||
name: "{{ hcloud_primary_ip_name }}"
|
||||
state: absent
|
|
@ -0,0 +1,9 @@
|
|||
---
|
||||
- name: Create test_primary_ip
|
||||
hetzner.hcloud.hcloud_primary_ip:
|
||||
name: "{{ hcloud_primary_ip_name }}"
|
||||
datacenter: fsn1-dc14
|
||||
type: ipv4
|
||||
labels:
|
||||
key: value
|
||||
register: test_primary_ip
|
|
@ -1,104 +1,77 @@
|
|||
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
- name: 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
|
||||
- name: Gather hcloud_primary_ip_info
|
||||
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
|
||||
- name: Verify hcloud_primary_ip_info
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_primary_ip_info | list | count >= 1
|
||||
|
||||
- name: Gather hcloud_primary_ip_info in check mode
|
||||
hetzner.hcloud.hcloud_primary_ip_info:
|
||||
check_mode: true
|
||||
register: result
|
||||
- name: Verify hcloud_primary_ip_info in check mode
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_primary_ip_info | list | count >= 1
|
||||
|
||||
- name: Gather hcloud_primary_ip_info with correct id
|
||||
hetzner.hcloud.hcloud_primary_ip_info:
|
||||
id: "{{ test_primary_ip.hcloud_primary_ip.id }}"
|
||||
register: result
|
||||
- name: Verify hcloud_primary_ip_info with correct id
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_primary_ip_info | list | count == 1
|
||||
|
||||
- name: Gather hcloud_primary_ip_info with wrong id
|
||||
hetzner.hcloud.hcloud_primary_ip_info:
|
||||
id: "{{ test_primary_ip.hcloud_primary_ip.id }}4321"
|
||||
ignore_errors: true
|
||||
- name: verify test gather hcloud primary ip with wrong id
|
||||
assert:
|
||||
register: result
|
||||
- name: Verify hcloud_primary_ip_info with wrong id
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result is failed
|
||||
|
||||
- name: cleanup
|
||||
hetzner.hcloud.hcloud_primary_ip:
|
||||
id: "{{ test_primary_ip.hcloud_primary_ip.id }}"
|
||||
state: absent
|
||||
- name: Gather hcloud_primary_ip_info with correct name
|
||||
hetzner.hcloud.hcloud_primary_ip_info:
|
||||
name: "{{ hcloud_primary_ip_name }}"
|
||||
register: result
|
||||
- name: verify cleanup
|
||||
assert:
|
||||
- name: Verify hcloud_primary_ip_info with correct name
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result is success
|
||||
- result.hcloud_primary_ip_info | list | count == 1
|
||||
|
||||
- name: Gather hcloud_primary_ip_info with wrong name
|
||||
hetzner.hcloud.hcloud_primary_ip_info:
|
||||
name: "{{ hcloud_primary_ip_name }}-invalid"
|
||||
register: result
|
||||
- name: Verify hcloud_primary_ip_info with wrong name
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_primary_ip_info | list | count == 0
|
||||
|
||||
- name: Gather hcloud_primary_ip_info with correct label selector
|
||||
hetzner.hcloud.hcloud_primary_ip_info:
|
||||
label_selector: "key=value"
|
||||
register: result
|
||||
- name: Verify hcloud_primary_ip_info with correct label selector
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- >
|
||||
result.hcloud_primary_ip_info
|
||||
| selectattr('name', 'equalto', '{{ hcloud_primary_ip_name }}')
|
||||
| list | count == 1
|
||||
|
||||
- name: Gather hcloud_primary_ip_info with wrong label selector
|
||||
hetzner.hcloud.hcloud_primary_ip_info:
|
||||
label_selector: "key!=value"
|
||||
register: result
|
||||
- name: Verify hcloud_primary_ip_info with wrong label selector
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_primary_ip_info | list | count == 0
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
---
|
||||
- name: Cleanup test_server
|
||||
hetzner.hcloud.hcloud_server:
|
||||
name: "{{ hcloud_server_name }}"
|
||||
state: absent
|
||||
|
||||
- name: Cleanup test_server2
|
||||
hetzner.hcloud.hcloud_server:
|
||||
name: "{{ hcloud_server_name }}2"
|
||||
state: absent
|
|
@ -0,0 +1,22 @@
|
|||
---
|
||||
- name: Create test_server
|
||||
hetzner.hcloud.hcloud_server:
|
||||
name: "{{ hcloud_server_name }}"
|
||||
server_type: cx11
|
||||
image: ubuntu-22.04
|
||||
state: started
|
||||
labels:
|
||||
key: value
|
||||
register: test_server
|
||||
|
||||
- name: Create test_server2 (stopped + without ip)
|
||||
hetzner.hcloud.hcloud_server:
|
||||
name: "{{ hcloud_server_name }}2"
|
||||
server_type: cx11
|
||||
image: ubuntu-22.04
|
||||
state: stopped
|
||||
labels:
|
||||
key: value
|
||||
enable_ipv4: false
|
||||
enable_ipv6: false
|
||||
register: test_server2
|
|
@ -1,127 +1,89 @@
|
|||
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
- name: setup ensure server is absent
|
||||
hetzner.hcloud.hcloud_server:
|
||||
name: "{{ hcloud_server_name }}"
|
||||
state: absent
|
||||
register: result
|
||||
|
||||
- name: create server
|
||||
hetzner.hcloud.hcloud_server:
|
||||
name: "{{ hcloud_server_name }}"
|
||||
server_type: cx11
|
||||
image: ubuntu-22.04
|
||||
state: started
|
||||
labels:
|
||||
key: value
|
||||
register: main_server
|
||||
- name: verify create server
|
||||
assert:
|
||||
that:
|
||||
- main_server is changed
|
||||
- main_server.hcloud_server.name == "{{ hcloud_server_name }}"
|
||||
- main_server.hcloud_server.server_type == "cx11"
|
||||
- main_server.hcloud_server.status == "running"
|
||||
- main_server.root_password != ""
|
||||
|
||||
- name: test gather hcloud server infos in check mode
|
||||
- name: Gather hcloud_server_info
|
||||
hetzner.hcloud.hcloud_server_info:
|
||||
register: server
|
||||
check_mode: true
|
||||
|
||||
- name: verify test gather hcloud server infos in check mode
|
||||
assert:
|
||||
register: result
|
||||
- name: Verify hcloud_server_info
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- server.hcloud_server_info|selectattr('name','equalto','{{ hcloud_server_name }}') | list | count == 1
|
||||
- result.hcloud_server_info | list | count >= 2
|
||||
|
||||
- name: test gather hcloud server infos with correct label selector
|
||||
- name: Gather hcloud_server_info in check mode
|
||||
hetzner.hcloud.hcloud_server_info:
|
||||
check_mode: true
|
||||
register: result
|
||||
- name: Verify hcloud_server_info in check mode
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_server_info | list | count >= 2
|
||||
|
||||
- name: Gather hcloud_server_info with correct id
|
||||
hetzner.hcloud.hcloud_server_info:
|
||||
id: "{{ test_server.hcloud_server.id }}"
|
||||
register: result
|
||||
- name: Verify hcloud_server_info with correct id
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_server_info | list | count == 1
|
||||
- result.hcloud_server_info[0].name == hcloud_server_name
|
||||
|
||||
- name: Gather hcloud_server_info with wrong id
|
||||
hetzner.hcloud.hcloud_server_info:
|
||||
id: "{{ test_server.hcloud_server.id }}4321"
|
||||
ignore_errors: true
|
||||
register: result
|
||||
- name: Verify hcloud_server_info with wrong id
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result is failed
|
||||
|
||||
- name: Gather hcloud_server_info with correct name
|
||||
hetzner.hcloud.hcloud_server_info:
|
||||
name: "{{ hcloud_server_name }}"
|
||||
register: result
|
||||
- name: Verify hcloud_server_info with correct name
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_server_info | list | count == 1
|
||||
- result.hcloud_server_info[0].name == hcloud_server_name
|
||||
|
||||
- name: Gather hcloud_server_info with wrong name
|
||||
hetzner.hcloud.hcloud_server_info:
|
||||
name: "{{ hcloud_server_name }}-invalid"
|
||||
register: result
|
||||
- name: Verify hcloud_server_info with wrong name
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_server_info | list | count == 0
|
||||
|
||||
- name: Gather hcloud_server_info with correct label selector
|
||||
hetzner.hcloud.hcloud_server_info:
|
||||
label_selector: "key=value"
|
||||
register: server
|
||||
- name: verify test gather hcloud server infos with correct label selector
|
||||
assert:
|
||||
register: result
|
||||
- name: Verify hcloud_server_info with correct label selector
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- server.hcloud_server_info|selectattr('name','equalto','{{ hcloud_server_name }}') | list | count == 1
|
||||
- >
|
||||
result.hcloud_server_info
|
||||
| selectattr('name', 'equalto', '{{ hcloud_server_name }}')
|
||||
| list | count == 1
|
||||
|
||||
- name: test gather hcloud server infos with wrong label selector
|
||||
- name: Gather hcloud_server_info with wrong label selector
|
||||
hetzner.hcloud.hcloud_server_info:
|
||||
label_selector: "key!=value"
|
||||
register: server
|
||||
- name: verify test gather hcloud server infos with wrong label selector
|
||||
assert:
|
||||
register: result
|
||||
- name: Verify hcloud_server_info with wrong label selector
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- server.hcloud_server_info | list | count == 0
|
||||
- result.hcloud_server_info | list | count == 0
|
||||
|
||||
- name: test gather hcloud server infos with correct name
|
||||
- name: Gather hcloud_server_info (without ip)
|
||||
hetzner.hcloud.hcloud_server_info:
|
||||
name: "{{hcloud_server_name}}"
|
||||
register: server
|
||||
- name: verify test gather hcloud server infos with correct name
|
||||
assert:
|
||||
id: "{{ test_server2.hcloud_server.id }}"
|
||||
register: result
|
||||
- name: Verify hcloud_server_info (without ip)
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- server.hcloud_server_info|selectattr('name','equalto','{{ hcloud_server_name }}') | list | count == 1
|
||||
|
||||
- name: test gather hcloud server infos with wrong name
|
||||
hetzner.hcloud.hcloud_server_info:
|
||||
name: "{{hcloud_server_name}}1"
|
||||
register: server
|
||||
- name: verify test gather hcloud server infos with wrong name
|
||||
assert:
|
||||
that:
|
||||
- server.hcloud_server_info | list | count == 0
|
||||
|
||||
- name: test gather hcloud server infos with correct id
|
||||
hetzner.hcloud.hcloud_server_info:
|
||||
id: "{{main_server.hcloud_server.id}}"
|
||||
register: server
|
||||
- name: verify test gather hcloud server infos with correct id
|
||||
assert:
|
||||
that:
|
||||
- server.hcloud_server_info|selectattr('name','equalto','{{ hcloud_server_name }}') | list | count == 1
|
||||
|
||||
- name: test gather hcloud server infos with wrong id
|
||||
hetzner.hcloud.hcloud_server_info:
|
||||
id: "4711"
|
||||
register: server
|
||||
ignore_errors: true
|
||||
- name: verify test gather hcloud server infos with wrong id
|
||||
assert:
|
||||
that:
|
||||
- server is failed
|
||||
|
||||
- name: cleanup
|
||||
hetzner.hcloud.hcloud_server:
|
||||
name: "{{ hcloud_server_name }}"
|
||||
state: absent
|
||||
|
||||
- name: create server without ips
|
||||
hetzner.hcloud.hcloud_server:
|
||||
name: "{{ hcloud_server_name }}"
|
||||
server_type: cx11
|
||||
image: ubuntu-22.04
|
||||
state: stopped
|
||||
labels:
|
||||
key: value
|
||||
enable_ipv4: false
|
||||
enable_ipv6: false
|
||||
register: main_server
|
||||
- name: verify create server
|
||||
assert:
|
||||
that:
|
||||
- main_server is changed
|
||||
- main_server.hcloud_server.name == "{{ hcloud_server_name }}"
|
||||
- main_server.hcloud_server.server_type == "cx11"
|
||||
- main_server.root_password != ""
|
||||
- name: test gather hcloud server infos with correct id
|
||||
hetzner.hcloud.hcloud_server_info:
|
||||
id: "{{main_server.hcloud_server.id}}"
|
||||
register: server
|
||||
- name: verify test gather hcloud server infos with correct id
|
||||
assert:
|
||||
that:
|
||||
- server.hcloud_server_info|selectattr('name','equalto','{{ hcloud_server_name }}') | list | count == 1
|
||||
- name: cleanup
|
||||
hetzner.hcloud.hcloud_server:
|
||||
name: "{{ hcloud_server_name }}"
|
||||
state: absent
|
||||
- result.hcloud_server_info | list | count == 1
|
||||
- result.hcloud_server_info[0].name == hcloud_server_name + '2'
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
hcloud_server_type_name: "cx11"
|
||||
hcloud_server_type_name: cx11
|
||||
hcloud_server_type_id: 1
|
||||
|
||||
hcloud_server_type_id_deprecated: "2" # cx11-ceph
|
||||
hcloud_server_type_id_deprecated: 2 # cx11-ceph
|
||||
|
|
|
@ -1,51 +1,69 @@
|
|||
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
- name: test gather hcloud server type infos
|
||||
- name: Gather hcloud_server_type_info
|
||||
hetzner.hcloud.hcloud_server_type_info:
|
||||
register: hcloud_server_types
|
||||
- name: verify test gather hcloud server type infos
|
||||
assert:
|
||||
register: result
|
||||
- name: Verify hcloud_server_type_info
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- hcloud_server_types.hcloud_server_type_info| list | count > 2
|
||||
- result.hcloud_server_type_info | list | count >= 3
|
||||
|
||||
- name: test gather hcloud server type infos in check mode
|
||||
- name: Gather hcloud_server_type_info in check mode
|
||||
hetzner.hcloud.hcloud_server_type_info:
|
||||
check_mode: true
|
||||
register: hcloud_server_types
|
||||
|
||||
- name: verify test gather hcloud server type infos in check mode
|
||||
assert:
|
||||
register: result
|
||||
- name: Verify hcloud_server_type_info in check mode
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- hcloud_server_types.hcloud_server_type_info| list | count > 2
|
||||
- result.hcloud_server_type_info | list | count >= 3
|
||||
|
||||
- name: test gather hcloud server type infos with name
|
||||
- name: Gather hcloud_server_type_info with correct id
|
||||
hetzner.hcloud.hcloud_server_type_info:
|
||||
name: "{{hcloud_server_type_name}}"
|
||||
register: hcloud_server_types
|
||||
- name: verify test gather hcloud server type with name
|
||||
assert:
|
||||
id: "{{ hcloud_server_type_id }}"
|
||||
register: result
|
||||
- name: Verify hcloud_server_type_info with correct id
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- hcloud_server_types.hcloud_server_type_info|selectattr('name','equalto','{{ hcloud_server_type_name }}') | list | count == 1
|
||||
- hcloud_server_types.hcloud_server_type_info[0].deprecation is none # fails if cx11 is ever deprecated
|
||||
- result.hcloud_server_type_info | list | count == 1
|
||||
- result.hcloud_server_type_info[0].deprecation is none # fails if cx11 is ever deprecated
|
||||
|
||||
- name: test gather hcloud server type infos with correct id
|
||||
- name: Gather hcloud_server_type_info with wrong id
|
||||
hetzner.hcloud.hcloud_server_type_info:
|
||||
id: "{{hcloud_server_type_id}}"
|
||||
register: hcloud_server_types
|
||||
- name: verify test gather hcloud server type with correct id
|
||||
assert:
|
||||
id: "{{ hcloud_server_type_id }}4321"
|
||||
ignore_errors: true
|
||||
register: result
|
||||
- name: Verify hcloud_server_type_info with wrong id
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- hcloud_server_types.hcloud_server_type_info|selectattr('name','equalto','{{ hcloud_server_type_name }}') | list | count == 1
|
||||
- result is failed
|
||||
|
||||
- name: test gather hcloud server type infos for deprecated server type
|
||||
- name: Gather hcloud_server_type_info with correct name
|
||||
hetzner.hcloud.hcloud_server_type_info:
|
||||
id: "{{hcloud_server_type_id_deprecated}}"
|
||||
register: hcloud_server_types
|
||||
|
||||
- name: verify test gather hcloud server type with deprecated field
|
||||
assert:
|
||||
name: "{{ hcloud_server_type_name }}"
|
||||
register: result
|
||||
- name: Verify hcloud_server_type_info with correct name
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- hcloud_server_types.hcloud_server_type_info[0].deprecation is not none
|
||||
- hcloud_server_types.hcloud_server_type_info[0].deprecation.announced == '2021-11-09T09:00:00+00:00'
|
||||
- hcloud_server_types.hcloud_server_type_info[0].deprecation.unavailable_after == '2021-12-01T00:00:00+00:00'
|
||||
- result.hcloud_server_type_info | list | count == 1
|
||||
|
||||
- name: Gather hcloud_server_type_info with wrong name
|
||||
hetzner.hcloud.hcloud_server_type_info:
|
||||
name: "{{ hcloud_server_type_name }}-invalid"
|
||||
register: result
|
||||
- name: Verify hcloud_server_type_info with wrong name
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_server_type_info | list | count == 0
|
||||
|
||||
- name: Gather hcloud_server_type_info with deprecated field
|
||||
hetzner.hcloud.hcloud_server_type_info:
|
||||
id: "{{ hcloud_server_type_id_deprecated }}"
|
||||
register: result
|
||||
- name: Verify hcloud_server_type_info with deprecated field
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_server_type_info | list | count == 1
|
||||
- result.hcloud_server_type_info[0].deprecation is not none
|
||||
- result.hcloud_server_type_info[0].deprecation.announced == '2021-11-09T09:00:00+00:00'
|
||||
- result.hcloud_server_type_info[0].deprecation.unavailable_after == '2021-12-01T00:00:00+00:00'
|
||||
|
|
|
@ -1,38 +1,77 @@
|
|||
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
- name: test gather hcloud ssh key infos in check mode
|
||||
- name: Gather hcloud_ssh_key_info
|
||||
hetzner.hcloud.hcloud_ssh_key_info:
|
||||
register: hcloud_ssh_key
|
||||
check_mode: true
|
||||
- name: verify test gather hcloud ssh key infos in check mode
|
||||
assert:
|
||||
register: result
|
||||
- name: Verify hcloud_ssh_key_info
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- hcloud_ssh_key.hcloud_ssh_key_info| list | count >= 1
|
||||
- result.hcloud_ssh_key_info | list | count >= 1
|
||||
|
||||
- name: test gather hcloud ssh key infos
|
||||
- name: Gather hcloud_ssh_key_info in check mode
|
||||
hetzner.hcloud.hcloud_ssh_key_info:
|
||||
register: hcloud_ssh_key
|
||||
check_mode: true
|
||||
- name: verify test gather hcloud ssh key infos
|
||||
assert:
|
||||
register: result
|
||||
- name: Verify hcloud_ssh_key_info in check mode
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- hcloud_ssh_key.hcloud_ssh_key_info| list | count >= 1
|
||||
- result.hcloud_ssh_key_info | list | count >= 1
|
||||
|
||||
- name: test gather hcloud ssh key infos with correct label selector
|
||||
- name: Gather hcloud_ssh_key_info with correct id
|
||||
hetzner.hcloud.hcloud_ssh_key_info:
|
||||
id: "{{ test_ssh_key.hcloud_ssh_key.id }}"
|
||||
register: result
|
||||
- name: Verify hcloud_ssh_key_info with correct id
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_ssh_key_info | list | count == 1
|
||||
|
||||
- name: Gather hcloud_ssh_key_info with wrong id
|
||||
hetzner.hcloud.hcloud_ssh_key_info:
|
||||
id: "{{ test_ssh_key.hcloud_ssh_key.id }}4321"
|
||||
ignore_errors: true
|
||||
register: result
|
||||
- name: Verify hcloud_ssh_key_info with wrong id
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result is failed
|
||||
|
||||
- name: Gather hcloud_ssh_key_info with correct name
|
||||
hetzner.hcloud.hcloud_ssh_key_info:
|
||||
name: "{{ hcloud_ssh_key_name }}"
|
||||
register: result
|
||||
- name: Verify hcloud_ssh_key_info with correct name
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_ssh_key_info | list | count == 1
|
||||
|
||||
- name: Gather hcloud_ssh_key_info with wrong name
|
||||
hetzner.hcloud.hcloud_ssh_key_info:
|
||||
name: "{{ hcloud_ssh_key_name }}-invalid"
|
||||
register: result
|
||||
- name: Verify hcloud_ssh_key_info with wrong name
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_ssh_key_info | list | count == 0
|
||||
|
||||
- name: Gather hcloud_ssh_key_info with correct label selector
|
||||
hetzner.hcloud.hcloud_ssh_key_info:
|
||||
label_selector: "key=value"
|
||||
register: hcloud_ssh_key
|
||||
- name: verify test gather hcloud ssh key infos with correct label selector
|
||||
assert:
|
||||
register: result
|
||||
- name: Verify hcloud_ssh_key_info with correct label selector
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- hcloud_ssh_key.hcloud_ssh_key_info|selectattr('name','equalto','{{ hcloud_ssh_key_name }}') | list | count == 1
|
||||
- >
|
||||
result.hcloud_ssh_key_info
|
||||
| selectattr('name', 'equalto', '{{ hcloud_ssh_key_name }}')
|
||||
| list | count == 1
|
||||
|
||||
- name: test gather hcloud ssh key infos with wrong label selector
|
||||
- name: Gather hcloud_ssh_key_info with wrong label selector
|
||||
hetzner.hcloud.hcloud_ssh_key_info:
|
||||
label_selector: "key!=value"
|
||||
register: hcloud_ssh_key
|
||||
- name: verify test gather hcloud ssh key infos with wrong label selector
|
||||
assert:
|
||||
register: result
|
||||
- name: Verify hcloud_ssh_key_info with wrong label selector
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- hcloud_ssh_key.hcloud_ssh_key_info | list | count == 0
|
||||
- result.hcloud_ssh_key_info | list | count == 0
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
- name: Cleanup test_volume
|
||||
hetzner.hcloud.hcloud_volume:
|
||||
name: "{{ hcloud_volume_name }}"
|
||||
state: absent
|
|
@ -0,0 +1,9 @@
|
|||
---
|
||||
- name: Create test_volume
|
||||
hetzner.hcloud.hcloud_volume:
|
||||
name: "{{ hcloud_volume_name }}"
|
||||
size: 10
|
||||
location: fsn1
|
||||
labels:
|
||||
key: value
|
||||
register: test_volume
|
|
@ -1,102 +1,81 @@
|
|||
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
- name: setup ensure volume is absent
|
||||
hetzner.hcloud.hcloud_volume:
|
||||
name: "{{ hcloud_volume_name }}"
|
||||
state: absent
|
||||
register: result
|
||||
|
||||
- name: setup volume
|
||||
hetzner.hcloud.hcloud_volume:
|
||||
name: "{{hcloud_volume_name}}"
|
||||
size: 10
|
||||
location: "fsn1"
|
||||
labels:
|
||||
key: value
|
||||
register: main_volume
|
||||
- name: verify setup volume
|
||||
assert:
|
||||
that:
|
||||
- main_volume is changed
|
||||
|
||||
- name: test gather hcloud volume infos in check mode
|
||||
- name: Gather hcloud_volume_info
|
||||
hetzner.hcloud.hcloud_volume_info:
|
||||
register: hcloud_volume
|
||||
check_mode: true
|
||||
|
||||
- name: verify test gather hcloud volume infos in check mode
|
||||
vars:
|
||||
volume: "{{ hcloud_volume.hcloud_volume_info|selectattr('name','equalto',hcloud_volume_name) | first }}"
|
||||
assert:
|
||||
register: result
|
||||
- name: Verify hcloud_volume_info
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- hcloud_volume.hcloud_volume_info|selectattr('name','equalto','{{ hcloud_volume_name }}') | list | count == 1
|
||||
- volume.name == "{{hcloud_volume_name}}"
|
||||
- volume.location == "fsn1"
|
||||
- volume.size == 10
|
||||
- volume.linux_device is defined
|
||||
- result.hcloud_volume_info | list | count >= 1
|
||||
|
||||
- name: test gather hcloud volume infos with correct label selector
|
||||
- name: Gather hcloud_volume_info in check mode
|
||||
hetzner.hcloud.hcloud_volume_info:
|
||||
check_mode: true
|
||||
register: result
|
||||
- name: Verify hcloud_volume_info in check mode
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_volume_info | list | count >= 1
|
||||
|
||||
- name: Gather hcloud_volume_info with correct id
|
||||
hetzner.hcloud.hcloud_volume_info:
|
||||
id: "{{ test_volume.hcloud_volume.id }}"
|
||||
register: result
|
||||
- name: Verify hcloud_volume_info with correct id
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_volume_info | list | count == 1
|
||||
- result.hcloud_volume_info[0].name == '{{ hcloud_volume_name }}'
|
||||
- result.hcloud_volume_info[0].location == 'fsn1'
|
||||
- result.hcloud_volume_info[0].size == 10
|
||||
- result.hcloud_volume_info[0].linux_device is defined
|
||||
|
||||
- name: Gather hcloud_volume_info with wrong id
|
||||
hetzner.hcloud.hcloud_volume_info:
|
||||
id: "{{ test_volume.hcloud_volume.id }}4321"
|
||||
ignore_errors: true
|
||||
register: result
|
||||
- name: Verify hcloud_volume_info with wrong id
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result is failed
|
||||
|
||||
- name: Gather hcloud_volume_info with correct name
|
||||
hetzner.hcloud.hcloud_volume_info:
|
||||
name: "{{ hcloud_volume_name }}"
|
||||
register: result
|
||||
- name: Verify hcloud_volume_info with correct name
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_volume_info | list | count == 1
|
||||
|
||||
- name: Gather hcloud_volume_info with wrong name
|
||||
hetzner.hcloud.hcloud_volume_info:
|
||||
name: "{{ hcloud_volume_name }}-invalid"
|
||||
register: result
|
||||
- name: Verify hcloud_volume_info with wrong name
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_volume_info | list | count == 0
|
||||
|
||||
- name: Gather hcloud_volume_info with correct label selector
|
||||
hetzner.hcloud.hcloud_volume_info:
|
||||
label_selector: "key=value"
|
||||
register: hcloud_volume
|
||||
- name: verify test gather hcloud volume infos with correct label selector
|
||||
assert:
|
||||
register: result
|
||||
- name: Verify hcloud_volume_info with correct label selector
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- hcloud_volume.hcloud_volume_info|selectattr('name','equalto','{{ hcloud_volume_name }}') | list | count == 1
|
||||
- >
|
||||
result.hcloud_volume_info
|
||||
| selectattr('name', 'equalto', '{{ hcloud_volume_name }}')
|
||||
| list | count == 1
|
||||
|
||||
- name: test gather hcloud volume infos with wrong label selector
|
||||
- name: Gather hcloud_volume_info with wrong label selector
|
||||
hetzner.hcloud.hcloud_volume_info:
|
||||
label_selector: "key!=value"
|
||||
register: hcloud_volume
|
||||
- name: verify test gather hcloud volume infos with wrong label selector
|
||||
assert:
|
||||
that:
|
||||
- hcloud_volume.hcloud_volume_info | list | count == 0
|
||||
|
||||
- name: test gather hcloud volume infos with correct name
|
||||
hetzner.hcloud.hcloud_volume_info:
|
||||
name: "{{hcloud_volume_name}}"
|
||||
register: hcloud_volume
|
||||
- name: verify test gather hcloud volume infos with correct name
|
||||
assert:
|
||||
that:
|
||||
- hcloud_volume.hcloud_volume_info|selectattr('name','equalto','{{ hcloud_volume_name }}') | list | count == 1
|
||||
|
||||
- name: test gather hcloud volume infos with wrong name
|
||||
hetzner.hcloud.hcloud_volume_info:
|
||||
name: "{{hcloud_volume_name}}1"
|
||||
register: hcloud_volume
|
||||
- name: verify test gather hcloud volume infos with wrong name
|
||||
assert:
|
||||
that:
|
||||
- hcloud_volume.hcloud_volume_info | list | count == 0
|
||||
|
||||
- name: test gather hcloud volume facts with correct id
|
||||
hetzner.hcloud.hcloud_volume_info:
|
||||
id: "{{main_volume.hcloud_volume.id}}"
|
||||
register: hcloud_volume
|
||||
- name: verify test gather hcloud volume with correct id
|
||||
assert:
|
||||
that:
|
||||
- hcloud_volume.hcloud_volume_info|selectattr('name','equalto','{{ hcloud_volume_name }}') | list | count == 1
|
||||
|
||||
- name: test gather hcloud volume infos with wrong id
|
||||
hetzner.hcloud.hcloud_volume_info:
|
||||
id: "4711"
|
||||
register: hcloud_volume
|
||||
ignore_errors: true
|
||||
- name: verify test gather hcloud volume infos with wrong id
|
||||
assert:
|
||||
that:
|
||||
- hcloud_volume is failed
|
||||
|
||||
- name: cleanup
|
||||
hetzner.hcloud.hcloud_volume:
|
||||
name: "{{ hcloud_volume_name }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify cleanup
|
||||
assert:
|
||||
- name: Verify hcloud_volume_info with wrong label selector
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result is success
|
||||
- result.hcloud_volume_info | list | count == 0
|
||||
|
|
Loading…
Reference in a new issue