mirror of
https://github.com/ansible-collections/hetzner.hcloud.git
synced 2026-02-04 08:01:49 +00:00
feat(primary_ip): add hcloud_primary_ip_info module (#225)
Co-authored-by: Kevin Castner <kcastner@kcastner.de>
This commit is contained in:
parent
23c2d7d228
commit
27821140d7
6 changed files with 320 additions and 0 deletions
2
tests/integration/targets/hcloud_primary_ip_info/aliases
Normal file
2
tests/integration/targets/hcloud_primary_ip_info/aliases
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
cloud/hcloud
|
||||
shippable/hcloud/group2
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
hcloud_prefix: "tests"
|
||||
hcloud_primary_ip_name: "{{hcloud_prefix}}-i"
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
collections:
|
||||
- community.general.ipfilter
|
||||
- hetzner.cloud
|
||||
104
tests/integration/targets/hcloud_primary_ip_info/tasks/main.yml
Normal file
104
tests/integration/targets/hcloud_primary_ip_info/tasks/main.yml
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
- name: setup ensure primary ip is absent
|
||||
hcloud_primary_ip:
|
||||
name: "{{ hcloud_primary_ip_name }}"
|
||||
state: absent
|
||||
|
||||
- name: setup primary ip
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
hcloud_primary_ip_info:
|
||||
id: "{{test_primary_ip.hcloud_primary_ip.id}}1"
|
||||
register: result
|
||||
ignore_errors: true
|
||||
- name: verify test gather hcloud primary ip with wrong id
|
||||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
|
||||
- name: cleanup
|
||||
hcloud_primary_ip:
|
||||
id: "{{ test_primary_ip.hcloud_primary_ip.id }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: verify cleanup
|
||||
assert:
|
||||
that:
|
||||
- result is success
|
||||
Loading…
Add table
Add a link
Reference in a new issue