Debian Codegraph @

ansible_collections/community/crypto/tests/integration/targets/openssl_pkcs12/tasks/main.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 ####################################################################
7 # WARNING: These are designed specifically for Ansible tests #
8 # and should not be used as examples of how to write Ansible roles #
9 ####################################################################
10
11 - block:
12 - name: Generate private keys
13 community.crypto.openssl_privatekey:
14 path: '{{ remote_tmp_dir }}/ansible_pkey{{ item }}.pem'
15 size: '{{ default_rsa_key_size_certificates }}'
16 loop: "{{ range(1, 4) | list }}"
17
18 - name: Generate privatekey with password
19 community.crypto.openssl_privatekey:
20 path: '{{ remote_tmp_dir }}/privatekeypw.pem'
21 passphrase: hunter2
22 size: '{{ default_rsa_key_size }}'
23
24 - name: Generate CSRs
25 community.crypto.openssl_csr:
26 path: '{{ remote_tmp_dir }}/ansible{{ item }}.csr'
27 privatekey_path: '{{ remote_tmp_dir }}/ansible_pkey{{ item }}.pem'
28 commonName: www{{ item }}.ansible.com
29 loop: "{{ range(1, 4) | list }}"
30
31 - name: Generate certificate
32 community.crypto.x509_certificate:
33 path: '{{ remote_tmp_dir }}/ansible{{ item }}.crt'
34 privatekey_path: '{{ remote_tmp_dir }}/ansible_pkey{{ item }}.pem'
35 csr_path: '{{ remote_tmp_dir }}/ansible{{ item }}.csr'
36 provider: selfsigned
37 loop: "{{ range(1, 4) | list }}"
38
39 - name: Read files
40 ansible.builtin.slurp:
41 src: '{{ item }}'
42 loop:
43 - "{{ remote_tmp_dir ~ '/ansible2.crt' }}"
44 - "{{ remote_tmp_dir ~ '/ansible3.crt' }}"
45 register: slurp
46
47 - name: Generate concatenated PEM file
48 ansible.builtin.copy:
49 dest: '{{ remote_tmp_dir }}/ansible23.crt'
50 content: '{{ slurp.results[0].content | b64decode }}{{ slurp.results[1].content | b64decode }}'
51
52 - name: Generate PKCS#12 file with backend autodetection
53 community.crypto.openssl_pkcs12:
54 path: '{{ remote_tmp_dir }}/ansible.p12'
55 friendly_name: abracadabra
56 privatekey_path: '{{ remote_tmp_dir }}/ansible_pkey1.pem'
57 certificate_path: '{{ remote_tmp_dir }}/ansible1.crt'
58 state: present
59
60 - name: Delete result
61 ansible.builtin.file:
62 path: '{{ remote_tmp_dir }}/ansible.p12'
63 state: absent
64
65 - name: Running tests with cryptography backend
66 ansible.builtin.include_tasks: impl.yml
67 vars:
68 select_crypto_backend: cryptography
69
70 when: >-
71 cryptography_version is version('3.3', '>=')