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_image_info/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

92 lines
3 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: test gather hcloud image infos with type system
hcloud_image_info:
register: hcloud_images
- name: verify test gather hcloud image infos in check mode
assert:
that:
- hcloud_images.hcloud_image_info| list | count > 2
- name: test gather hcloud image infos in check mode
hcloud_image_info:
check_mode: true
register: hcloud_images
- name: verify test gather hcloud image infos in check mode
assert:
that:
- hcloud_images.hcloud_image_info| list | count > 2
- name: test gather hcloud image infos with correct label selector
hcloud_image_info:
label_selector: "key=value"
type: snapshot
register: hcloud_images
- name: verify test gather hcloud image with correct label selector
assert:
that:
- hcloud_images.hcloud_image_info|selectattr('description','equalto','{{ hcloud_test_image_name }}') | list | count == 1
- name: test gather hcloud image infos with wrong label selector
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
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
hcloud_image_info:
id: "{{hcloud_test_image_id}}1"
type: snapshot
ignore_errors: true
register: result
- name: verify test gather hcloud image with wrong id
assert:
that:
- result is failed
- name: test gather hcloud image infos with name
hcloud_image_info:
name: "{{ hcloud_test_image_name_os }}"
register: hcloud_images
- name: verify test gather hcloud image infos with name
assert:
that:
- hcloud_images.hcloud_image_info | list | count == 1
- hcloud_images.hcloud_image_info[0].architecture == "x86"
- name: test gather hcloud image infos with name and architecture
hcloud_image_info:
name: "{{ hcloud_test_image_name_os }}"
architecture: arm
register: hcloud_images
- name: verify test gather hcloud image infos with name
assert:
that:
- hcloud_images.hcloud_image_info | list | count == 1
- hcloud_images.hcloud_image_info[0].architecture == "arm"
- name: test gather hcloud image infos with architecture
hcloud_image_info:
architecture: arm
register: hcloud_images
- name: verify test gather hcloud image infos with name
assert:
that:
- hcloud_images.hcloud_image_info | selectattr('architecture','equalto','x86') | list | count == 0
- hcloud_images.hcloud_image_info | selectattr('architecture','equalto','arm') | list | count > 2