1
0
Fork 0
mirror of https://github.com/ansible-collections/hetzner.hcloud.git synced 2026-02-04 08:01:49 +00:00
hetzner.hcloud/tests/integration/targets/primary_ip/tasks/test.yml
Jonas L 328dfb8b0f
refactor: start using new modules names (#393)
##### SUMMARY

Update all references to modules to use the new module names.
Continuation of #390
2023-11-21 09:40:11 +01:00

248 lines
6.6 KiB
YAML

# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
- name: setup ensure primary ip is absent
hetzner.hcloud.primary_ip:
name: "{{ hcloud_primary_ip_name }}"
state: absent
- name: test create Primary IP with check mode
hetzner.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.primary_ip:
name: "{{ hcloud_primary_ip_name }}"
state: "absent"
register: result
- name: verify test delete primary ip
assert:
that:
- result is changed