Debian Codegraph @

ansible_collections/community/crypto/tests/integration/targets/x509_certificate-acme/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 - name: Generate account key
7 community.crypto.openssl_privatekey:
8 path: '{{ remote_tmp_dir }}/account.key'
9 size: '{{ default_rsa_key_size }}'
10
11 - name: Generate privatekey
12 community.crypto.openssl_privatekey:
13 path: '{{ remote_tmp_dir }}/privatekey.pem'
14 size: '{{ default_rsa_key_size }}'
15
16 - name: Generate CSRs
17 community.crypto.openssl_csr:
18 privatekey_path: '{{ remote_tmp_dir }}/privatekey.pem'
19 path: '{{ remote_tmp_dir }}/{{ item.name }}.csr'
20 subject_alt_name: '{{ item.sans }}'
21 loop:
22 - name: cert-1
23 sans:
24 - DNS:example.com
25 - name: cert-2
26 sans:
27 - DNS:example.com
28 - DNS:example.org
29
30 - name: Retrieve certificate 1
31 community.crypto.x509_certificate:
32 provider: acme
33 path: '{{ remote_tmp_dir }}/cert-1.pem'
34 csr_path: '{{ remote_tmp_dir }}/cert-1.csr'
35 acme_accountkey_path: '{{ remote_tmp_dir }}/account.key'
36 acme_challenge_path: '{{ remote_tmp_dir }}/challenges/'
37 acme_directory: "{{ acme_directory_url }}"
38 environment:
39 PATH: '{{ lookup("env", "PATH") }}:{{ remote_tmp_dir }}'
40
41 - name: Get certificate information
42 community.crypto.x509_certificate_info:
43 path: '{{ remote_tmp_dir }}/cert-1.pem'
44 register: result
45
46 - name: Validate certificate information
47 ansible.builtin.assert:
48 that:
49 - result.subject_alt_name | length == 1
50 - "'DNS:example.com' in result.subject_alt_name"
51
52 - name: Retrieve certificate 2
53 community.crypto.x509_certificate:
54 provider: acme
55 path: '{{ remote_tmp_dir }}/cert-2.pem'
56 csr_path: '{{ remote_tmp_dir }}/cert-2.csr'
57 acme_accountkey_path: '{{ remote_tmp_dir }}/account.key'
58 acme_challenge_path: '{{ remote_tmp_dir }}/challenges/'
59 acme_directory: "{{ acme_directory_url }}"
60 environment:
61 PATH: '{{ lookup("env", "PATH") }}:{{ remote_tmp_dir }}'
62
63 - name: Get certificate information
64 community.crypto.x509_certificate_info:
65 path: '{{ remote_tmp_dir }}/cert-2.pem'
66 register: result
67
68 - name: Validate certificate information
69 ansible.builtin.assert:
70 that:
71 - result.subject_alt_name | length == 2
72 - "'DNS:example.com' in result.subject_alt_name"
73 - "'DNS:example.org' in result.subject_alt_name"