Debian Codegraph @

ansible_collections/hetzner/hcloud/tests/integration/targets/certificate/tasks/test.yml

raw
1 # Copyright: (c) 2020, Hetzner Cloud GmbH <[email protected]>
2 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
3 ---
4 - name: test missing required parameters on create certificate
5 hetzner.hcloud.certificate:
6 name: "{{ hcloud_certificate_name }}"
7 register: result
8 ignore_errors: true
9 - name: verify fail test missing required parameters on create certificate
10 assert:
11 that:
12 - result is failed
13 - 'result.msg == "missing required arguments: certificate, private_key"'
14
15 - name: test create certificate with check mode
16 hetzner.hcloud.certificate:
17 name: "{{ hcloud_certificate_name }}"
18 certificate: "{{ test_certificate_content }}"
19 private_key: "{{ test_certificate_privatekey_content }}"
20 register: result
21 check_mode: true
22 - name: test create certificate with check mode
23 assert:
24 that:
25 - result is changed
26
27 - name: test create certificate
28 hetzner.hcloud.certificate:
29 name: "{{ hcloud_certificate_name }}"
30 certificate: "{{ test_certificate_content }}"
31 private_key: "{{ test_certificate_privatekey_content }}"
32 labels:
33 key: value
34 my-label: label
35 register: certificate
36 - name: verify create certificate
37 assert:
38 that:
39 - certificate is changed
40 - certificate.hcloud_certificate.name == hcloud_certificate_name
41 - certificate.hcloud_certificate.domain_names[0] == "www.example.com"
42 - certificate.hcloud_certificate.labels.key == "value"
43
44 - name: test create certificate idempotence
45 hetzner.hcloud.certificate:
46 name: "{{ hcloud_certificate_name }}"
47 certificate: "{{ test_certificate_content }}"
48 private_key: "{{ test_certificate_privatekey_content }}"
49 register: result
50 - name: verify create certificate idempotence
51 assert:
52 that:
53 - result is not changed
54
55 - name: test update certificate with check mode
56 hetzner.hcloud.certificate:
57 id: "{{ certificate.hcloud_certificate.id }}"
58 name: "changed-{{ hcloud_certificate_name }}"
59 register: result
60 check_mode: true
61 - name: test create certificate with check mode
62 assert:
63 that:
64 - result is changed
65
66 - name: test update certificate
67 hetzner.hcloud.certificate:
68 id: "{{ certificate.hcloud_certificate.id }}"
69 name: "changed-{{ hcloud_certificate_name }}"
70 labels:
71 key: value
72 register: result
73 - name: test update certificate
74 assert:
75 that:
76 - result is changed
77 - result.hcloud_certificate.name == "changed-" + hcloud_certificate_name
78
79 - name: test update certificate with same labels
80 hetzner.hcloud.certificate:
81 id: "{{ certificate.hcloud_certificate.id }}"
82 name: "changed-{{ hcloud_certificate_name }}"
83 labels:
84 key: value
85 register: result
86 - name: test update certificate with same labels
87 assert:
88 that:
89 - result is not changed
90
91 - name: test update certificate with other labels
92 hetzner.hcloud.certificate:
93 id: "{{ certificate.hcloud_certificate.id }}"
94 name: "changed-{{ hcloud_certificate_name }}"
95 labels:
96 key: value
97 test: "val123"
98 register: result
99 - name: test update certificate with other labels
100 assert:
101 that:
102 - result is changed
103
104 - name: test rename certificate
105 hetzner.hcloud.certificate:
106 id: "{{ certificate.hcloud_certificate.id }}"
107 name: "{{ hcloud_certificate_name }}"
108 register: result
109 - name: test rename certificate
110 assert:
111 that:
112 - result is changed
113 - result.hcloud_certificate.name == hcloud_certificate_name
114
115 - name: absent certificate
116 hetzner.hcloud.certificate:
117 id: "{{ certificate.hcloud_certificate.id }}"
118 state: absent
119 register: result
120 - name: verify absent server
121 assert:
122 that:
123 - result is success
124
125 - name: generate dns domain name
126 set_fact:
127 # hcloud_dns_test_domain uses random, which generates a new random number
128 # on every invocation, by saving it into a fact we generate the number once
129 hcloud_dns_test_domain: "{{ hcloud_dns_test_domain }}"
130
131 - name: test create managed certificate
132 hetzner.hcloud.certificate:
133 name: "{{ hcloud_certificate_name }}"
134 domain_names:
135 - "{{ hcloud_dns_test_domain }}"
136 type: managed
137 labels:
138 HC-Use-Staging-CA: "true"
139 register: result
140 - name: verify create managed certificate
141 assert:
142 that:
143 - result is changed
144 - result.hcloud_certificate.name == hcloud_certificate_name
145 - result.hcloud_certificate.domain_names[0] == hcloud_dns_test_domain
146
147 - name: test delete certificate
148 hetzner.hcloud.certificate:
149 id: "{{ result.hcloud_certificate.id }}"
150 state: absent
151 register: result
152 - name: verify test delete certificate
153 assert:
154 that:
155 - result is success