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_certificate_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

65 lines
2.2 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: create certificate
hcloud_certificate:
name: "{{ hcloud_certificate_name }}"
certificate: "{{ certificate_example_com }}"
private_key: "{{ certificate_example_com_key }}"
labels:
key: value
my-label: label
register: certificate
- name: verify create certificate
assert:
that:
- certificate is changed
- certificate.hcloud_certificate.name == "{{ hcloud_certificate_name }}"
- certificate.hcloud_certificate.domain_names[0] == "www.example.com"
- certificate.hcloud_certificate.labels.key == "value"
- name: test gather hcloud certificate infos in check mode
hcloud_certificate_info:
register: hcloud_certificate
check_mode: true
- name: verify test gather hcloud certificate infos in check mode
assert:
that:
- hcloud_certificate.hcloud_certificate_info| list | count >= 1
- name: test gather hcloud certificate infos
hcloud_certificate_info:
register: hcloud_certificate
check_mode: true
- name: verify test gather hcloud certificate infos
assert:
that:
- hcloud_certificate.hcloud_certificate_info| list | count >= 1
- name: test gather hcloud certificate infos with correct label selector
hcloud_certificate_info:
label_selector: "key=value"
register: hcloud_certificate
- name: verify test gather hcloud certificate infos with correct label selector
assert:
that:
- hcloud_certificate.hcloud_certificate_info|selectattr('name','equalto','{{ hcloud_certificate_name }}') | list | count == 1
- name: test gather hcloud certificate infos with wrong label selector
hcloud_certificate_info:
label_selector: "key!=value"
register: hcloud_certificate
- name: verify test gather hcloud certificate infos with wrong label selector
assert:
that:
- hcloud_certificate.hcloud_certificate_info | list | count == 0
- name: absent certificate
hcloud_certificate:
id: "{{ certificate.hcloud_certificate.id }}"
state: absent
register: result
- name: verify absent certificate
assert:
that:
- result is success