Debian Codegraph @

ansible_collections/community/crypto/tests/integration/targets/acme_account/tasks/impl.yml

raw
1 ---
2 # Copyright (c) Ansible Project
3 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
4 # SPDX-License-Identifier: GPL-3.0-or-later
5
6 - block:
7 - name: Generate account keys
8 community.crypto.openssl_privatekey:
9 path: "{{ remote_tmp_dir }}/{{ item.name }}.pem"
10 passphrase: "{{ item.pass | default(omit) | default(omit, true) }}"
11 type: ECC
12 curve: secp256r1
13 force: true
14 loop: "{{ account_keys }}"
15
16 - name: Parse account keys (to ease debugging some test failures)
17 community.crypto.openssl_privatekey_info:
18 path: "{{ remote_tmp_dir }}/{{ item.name }}.pem"
19 passphrase: "{{ item.pass | default(omit) | default(omit, true) }}"
20 return_private_key_data: true
21 loop: "{{ account_keys }}"
22
23 vars:
24 account_keys:
25 - name: accountkey
26 - name: accountkey2
27 pass: "{{ 'hunter2' if select_crypto_backend != 'openssl' else '' }}"
28 - name: accountkey3
29 - name: accountkey4
30 - name: accountkey5
31
32 - name: Do not try to create account
33 community.crypto.acme_account:
34 select_crypto_backend: "{{ select_crypto_backend }}"
35 account_key_src: "{{ remote_tmp_dir }}/accountkey.pem"
36 acme_version: 2
37 acme_directory: "{{ acme_directory_url }}"
38 validate_certs: false
39 state: present
40 allow_creation: false
41 ignore_errors: true
42 register: account_not_created
43
44 - name: Create it now (check mode, diff)
45 community.crypto.acme_account:
46 select_crypto_backend: "{{ select_crypto_backend }}"
47 account_key_src: "{{ remote_tmp_dir }}/accountkey.pem"
48 acme_version: 2
49 acme_directory: "{{ acme_directory_url }}"
50 validate_certs: false
51 state: present
52 allow_creation: true
53 terms_agreed: true
54 contact:
55 - mailto:[email protected]
56 check_mode: true
57 diff: true
58 register: account_created_check
59
60 - name: Create it now
61 community.crypto.acme_account:
62 select_crypto_backend: "{{ select_crypto_backend }}"
63 account_key_src: "{{ remote_tmp_dir }}/accountkey.pem"
64 acme_version: 2
65 acme_directory: "{{ acme_directory_url }}"
66 validate_certs: false
67 state: present
68 allow_creation: true
69 terms_agreed: true
70 contact:
71 - mailto:[email protected]
72 register: account_created
73
74 - name: Create it now (idempotent)
75 community.crypto.acme_account:
76 select_crypto_backend: "{{ select_crypto_backend }}"
77 account_key_src: "{{ remote_tmp_dir }}/accountkey.pem"
78 acme_version: 2
79 acme_directory: "{{ acme_directory_url }}"
80 validate_certs: false
81 state: present
82 allow_creation: true
83 terms_agreed: true
84 contact:
85 - mailto:[email protected]
86 register: account_created_idempotent
87
88 - name: Read account key
89 ansible.builtin.slurp:
90 src: '{{ remote_tmp_dir }}/accountkey.pem'
91 register: slurp
92
93 - name: Change email address (check mode, diff)
94 community.crypto.acme_account:
95 select_crypto_backend: "{{ select_crypto_backend }}"
96 account_key_content: "{{ slurp.content | b64decode }}"
97 acme_version: 2
98 acme_directory: "{{ acme_directory_url }}"
99 validate_certs: false
100 state: present
101 # allow_creation: false
102 contact:
103 - mailto:[email protected]
104 check_mode: true
105 diff: true
106 register: account_modified_check
107
108 - name: Change email address
109 community.crypto.acme_account:
110 select_crypto_backend: "{{ select_crypto_backend }}"
111 account_key_content: "{{ slurp.content | b64decode }}"
112 acme_version: 2
113 acme_directory: "{{ acme_directory_url }}"
114 validate_certs: false
115 state: present
116 # allow_creation: false
117 contact:
118 - mailto:[email protected]
119 register: account_modified
120
121 - name: Change email address (idempotent)
122 community.crypto.acme_account:
123 select_crypto_backend: "{{ select_crypto_backend }}"
124 account_key_src: "{{ remote_tmp_dir }}/accountkey.pem"
125 account_uri: "{{ account_created.account_uri }}"
126 acme_version: 2
127 acme_directory: "{{ acme_directory_url }}"
128 validate_certs: false
129 state: present
130 # allow_creation: false
131 contact:
132 - mailto:[email protected]
133 register: account_modified_idempotent
134
135 - name: Cannot access account with wrong URI
136 community.crypto.acme_account:
137 select_crypto_backend: "{{ select_crypto_backend }}"
138 account_key_src: "{{ remote_tmp_dir }}/accountkey.pem"
139 account_uri: "{{ account_created.account_uri ~ '12345thisdoesnotexist' }}"
140 acme_version: 2
141 acme_directory: "{{ acme_directory_url }}"
142 validate_certs: false
143 state: present
144 contact: []
145 ignore_errors: true
146 register: account_modified_wrong_uri
147
148 - name: Clear contact email addresses (check mode, diff)
149 community.crypto.acme_account:
150 select_crypto_backend: "{{ select_crypto_backend }}"
151 account_key_src: "{{ remote_tmp_dir }}/accountkey.pem"
152 acme_version: 2
153 acme_directory: "{{ acme_directory_url }}"
154 validate_certs: false
155 state: present
156 # allow_creation: false
157 contact: []
158 check_mode: true
159 diff: true
160 register: account_modified_2_check
161
162 - name: Clear contact email addresses
163 community.crypto.acme_account:
164 select_crypto_backend: "{{ select_crypto_backend }}"
165 account_key_src: "{{ remote_tmp_dir }}/accountkey.pem"
166 acme_version: 2
167 acme_directory: "{{ acme_directory_url }}"
168 validate_certs: false
169 state: present
170 # allow_creation: false
171 contact: []
172 register: account_modified_2
173
174 - name: Clear contact email addresses (idempotent)
175 community.crypto.acme_account:
176 select_crypto_backend: "{{ select_crypto_backend }}"
177 account_key_src: "{{ remote_tmp_dir }}/accountkey.pem"
178 acme_version: 2
179 acme_directory: "{{ acme_directory_url }}"
180 validate_certs: false
181 state: present
182 # allow_creation: false
183 contact: []
184 register: account_modified_2_idempotent
185
186 - name: Change account key (check mode, diff)
187 community.crypto.acme_account:
188 select_crypto_backend: "{{ select_crypto_backend }}"
189 account_key_src: "{{ remote_tmp_dir }}/accountkey.pem"
190 acme_version: 2
191 acme_directory: "{{ acme_directory_url }}"
192 validate_certs: false
193 new_account_key_src: "{{ remote_tmp_dir }}/accountkey2.pem"
194 new_account_key_passphrase: "{{ 'hunter2' if select_crypto_backend != 'openssl' else omit }}"
195 state: changed_key
196 contact:
197 - mailto:[email protected]
198 check_mode: true
199 diff: true
200 register: account_change_key_check
201
202 - name: Change account key
203 community.crypto.acme_account:
204 select_crypto_backend: "{{ select_crypto_backend }}"
205 account_key_src: "{{ remote_tmp_dir }}/accountkey.pem"
206 acme_version: 2
207 acme_directory: "{{ acme_directory_url }}"
208 validate_certs: false
209 new_account_key_src: "{{ remote_tmp_dir }}/accountkey2.pem"
210 new_account_key_passphrase: "{{ 'hunter2' if select_crypto_backend != 'openssl' else omit }}"
211 state: changed_key
212 contact:
213 - mailto:[email protected]
214 register: account_change_key
215
216 - name: Deactivate account (check mode, diff)
217 community.crypto.acme_account:
218 select_crypto_backend: "{{ select_crypto_backend }}"
219 account_key_src: "{{ remote_tmp_dir }}/accountkey2.pem"
220 account_key_passphrase: "{{ 'hunter2' if select_crypto_backend != 'openssl' else omit }}"
221 acme_version: 2
222 acme_directory: "{{ acme_directory_url }}"
223 validate_certs: false
224 state: absent
225 check_mode: true
226 diff: true
227 register: account_deactivate_check
228
229 - name: Deactivate account
230 community.crypto.acme_account:
231 select_crypto_backend: "{{ select_crypto_backend }}"
232 account_key_src: "{{ remote_tmp_dir }}/accountkey2.pem"
233 account_key_passphrase: "{{ 'hunter2' if select_crypto_backend != 'openssl' else omit }}"
234 acme_version: 2
235 acme_directory: "{{ acme_directory_url }}"
236 validate_certs: false
237 state: absent
238 register: account_deactivate
239
240 - name: Deactivate account (idempotent)
241 community.crypto.acme_account:
242 select_crypto_backend: "{{ select_crypto_backend }}"
243 account_key_src: "{{ remote_tmp_dir }}/accountkey2.pem"
244 account_key_passphrase: "{{ 'hunter2' if select_crypto_backend != 'openssl' else omit }}"
245 acme_version: 2
246 acme_directory: "{{ acme_directory_url }}"
247 validate_certs: false
248 state: absent
249 register: account_deactivate_idempotent
250
251 - name: Do not try to create account II
252 community.crypto.acme_account:
253 select_crypto_backend: "{{ select_crypto_backend }}"
254 account_key_src: "{{ remote_tmp_dir }}/accountkey2.pem"
255 account_key_passphrase: "{{ 'hunter2' if select_crypto_backend != 'openssl' else omit }}"
256 acme_version: 2
257 acme_directory: "{{ acme_directory_url }}"
258 validate_certs: false
259 state: present
260 allow_creation: false
261 ignore_errors: true
262 register: account_not_created_2
263
264 - name: Do not try to create account III
265 community.crypto.acme_account:
266 select_crypto_backend: "{{ select_crypto_backend }}"
267 account_key_src: "{{ remote_tmp_dir }}/accountkey.pem"
268 acme_version: 2
269 acme_directory: "{{ acme_directory_url }}"
270 validate_certs: false
271 state: present
272 allow_creation: false
273 ignore_errors: true
274 register: account_not_created_3
275
276 - name: Create account with External Account Binding
277 community.crypto.acme_account:
278 select_crypto_backend: "{{ select_crypto_backend }}"
279 account_key_src: "{{ remote_tmp_dir }}/{{ item.account }}.pem"
280 acme_version: 2
281 acme_directory: "{{ acme_directory_url }}"
282 validate_certs: false
283 state: present
284 allow_creation: true
285 terms_agreed: true
286 contact:
287 - mailto:[email protected]
288 external_account_binding:
289 kid: "{{ item.kid }}"
290 alg: "{{ item.alg }}"
291 key: "{{ item.key }}"
292 register: account_created_eab
293 ignore_errors: true
294 loop:
295 - account: accountkey3
296 kid: kid-1
297 alg: HS256
298 key: zWNDZM6eQGHWpSRTPal5eIUYFTu7EajVIoguysqZ9wG44nMEtx3MUAsUDkMTQ12W
299 - account: accountkey4
300 kid: kid-2
301 alg: HS384
302 key: b10lLJs8l1GPIzsLP0s6pMt8O0XVGnfTaCeROxQM0BIt2XrJMDHJZBM5NuQmQJQH
303 - account: accountkey5
304 kid: kid-3
305 alg: HS512
306 key: zWNDZM6eQGHWpSRTPal5eIUYFTu7EajVIoguysqZ9wG44nMEtx3MUAsUDkMTQ12W
307 - ansible.builtin.debug: var=account_created_eab