1
0
Fork 0
mirror of https://github.com/ansible-collections/hetzner.hcloud.git synced 2026-02-03 23:51:48 +00:00
hetzner.hcloud/tests/integration/targets/hcloud_primary_ip/tasks/main.yml
Jonas L 02516d9a7b
refactor: prefer true/false over yes/no (#226)
* style: format md and yml files using prettier

* refactor: prefer true/false over yes/no
2023-06-21 10:49:54 +02:00

248 lines
6.4 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
hcloud_primary_ip:
name: "{{ hcloud_primary_ip_name }}"
state: absent
- name: test create Primary IP with check mode
hcloud_primary_ip:
name: "{{ hcloud_primary_ip_name }}"
type: ipv4
datacenter: "fsn1-dc14"
register: primaryIP
check_mode: true
- name: verify test create Primary IP with check mode
assert:
that:
- primaryIP is changed
- name: test create Primary IP
hcloud_primary_ip:
name: "{{ hcloud_primary_ip_name }}"
type: ipv4
datacenter: "fsn1-dc14"
register: primaryIP
- name: verify test create Primary IP
assert:
that:
- primaryIP is changed
- primaryIP.hcloud_primary_ip.name ==hcloud_primary_ip_name
- primaryIP.hcloud_primary_ip.datacenter == "fsn1-dc14"
- name: test create Primary IP idempotency
hcloud_primary_ip:
name: "{{ hcloud_primary_ip_name }}"
type: ipv4
datacenter: "fsn1-dc14"
register: primaryIP
- name: verify test create Primary IP idempotency
assert:
that:
- primaryIP is not changed
- name: test update Primary IP
hcloud_primary_ip:
name: "{{ hcloud_primary_ip_name }}"
type: ipv4
datacenter: "fsn1-dc14"
labels:
key: value
register: primaryIP
- name: verify test update Primary IP
assert:
that:
- primaryIP is changed
- name: test update Primary IP idempotency
hcloud_primary_ip:
name: "{{ hcloud_primary_ip_name }}"
type: ipv4
datacenter: "fsn1-dc14"
labels:
key: value
register: primaryIP
- name: verify test update Primary IP idempotency
assert:
that:
- primaryIP is not changed
- name: test update Primary IP with same labels
hcloud_primary_ip:
name: "{{ hcloud_primary_ip_name }}"
type: ipv4
datacenter: "fsn1-dc14"
labels:
key: value
register: primaryIP
- name: verify test update Primary IP with same labels
assert:
that:
- primaryIP is not changed
- name: test update Primary IP with other labels
hcloud_primary_ip:
name: "{{ hcloud_primary_ip_name }}"
type: ipv4
datacenter: "fsn1-dc14"
labels:
key: value
other: label
register: primaryIP
- name: verify test update Primary IP with other labels
assert:
that:
- primaryIP is changed
- name: test update Primary IP with other labels in different order
hcloud_primary_ip:
name: "{{ hcloud_primary_ip_name }}"
type: ipv4
datacenter: "fsn1-dc14"
labels:
other: label
key: value
register: primaryIP
- name: verify test update Primary IP with other labels in different order
assert:
that:
- primaryIP is not changed
- name: test update Primary IP delete protection
hcloud_primary_ip:
name: "{{ hcloud_primary_ip_name }}"
type: ipv4
delete_protection: true
register: primaryIP
- name: verify update Primary IP delete protection
assert:
that:
- primaryIP is changed
- primaryIP.hcloud_primary_ip.delete_protection is sameas true
- name: test update Primary IP delete protection idempotency
hcloud_primary_ip:
name: "{{ hcloud_primary_ip_name }}"
type: ipv4
delete_protection: true
register: primaryIP
- name: verify update Primary IP delete protection idempotency
assert:
that:
- primaryIP is not changed
- primaryIP.hcloud_primary_ip.delete_protection is sameas true
- name: test Primary IP without delete protection set to be idempotent
hcloud_primary_ip:
name: "{{ hcloud_primary_ip_name }}"
type: ipv4
register: primaryIP
- name: verify Primary IP without delete protection set to be idempotent
assert:
that:
- primaryIP is not changed
- primaryIP.hcloud_primary_ip.delete_protection is sameas true
- name: test delete Primary IP fails if it is protected
hcloud_primary_ip:
name: "{{ hcloud_primary_ip_name }}"
state: "absent"
register: result
ignore_errors: 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
hcloud_primary_ip:
name: "{{ hcloud_primary_ip_name }}"
type: ipv4
delete_protection: false
register: primaryIP
- name: verify update Primary IP delete protection
assert:
that:
- primaryIP is changed
- primaryIP.hcloud_primary_ip.delete_protection is sameas false
- name: test delete primary ip
hcloud_primary_ip:
name: "{{ hcloud_primary_ip_name }}"
state: "absent"
register: result
- name: verify test delete primary ip
assert:
that:
- result is changed
- name: test create ipv6 primary ip
hcloud_primary_ip:
name: "{{ hcloud_primary_ip_name }}"
type: ipv6
datacenter: "fsn1-dc14"
state: "present"
register: result
- name: verify test create ipv6 primary ip
assert:
that:
- result is changed
- name: test delete ipv6 primary ip
hcloud_primary_ip:
name: "{{ hcloud_primary_ip_name }}"
state: "absent"
register: result
- name: verify test delete ipv6 primary ip
assert:
that:
- result is changed
- name: test create Primary IP with delete protection
hcloud_primary_ip:
name: "{{ hcloud_primary_ip_name }}"
type: ipv4
datacenter: fsn1-dc14
delete_protection: true
register: primaryIP
- name: verify create Primary IP with delete protection
assert:
that:
- primaryIP is changed
- primaryIP.hcloud_primary_ip.delete_protection is sameas true
- name: test delete Primary IP fails if it is protected
hcloud_primary_ip:
name: "{{ hcloud_primary_ip_name }}"
state: "absent"
register: result
ignore_errors: 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
hcloud_primary_ip:
name: "{{ hcloud_primary_ip_name }}"
type: ipv4
delete_protection: false
register: primaryIP
- name: verify update Primary IP delete protection
assert:
that:
- primaryIP is changed
- primaryIP.hcloud_primary_ip.delete_protection is sameas false
- name: test delete primary ip
hcloud_primary_ip:
name: "{{ hcloud_primary_ip_name }}"
state: "absent"
register: result
- name: verify test delete primary ip
assert:
that:
- result is changed