| 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: "({{ select_crypto_backend }}) Generate privatekey" |
| 7 |
community.crypto.openssl_privatekey: |
| 8 |
path: '{{ remote_tmp_dir }}/privatekey.pem' |
| 9 |
size: '{{ default_rsa_key_size }}' |
| 10 |
|
| 11 |
- name: "({{ select_crypto_backend }}) Generate publickey - PEM format (check mode)" |
| 12 |
community.crypto.openssl_publickey: |
| 13 |
path: '{{ remote_tmp_dir }}/publickey.pub' |
| 14 |
privatekey_path: '{{ remote_tmp_dir }}/privatekey.pem' |
| 15 |
select_crypto_backend: '{{ select_crypto_backend }}' |
| 16 |
return_content: true |
| 17 |
check_mode: true |
| 18 |
register: publickey_check |
| 19 |
|
| 20 |
- name: "({{ select_crypto_backend }}) Generate publickey - PEM format" |
| 21 |
community.crypto.openssl_publickey: |
| 22 |
path: '{{ remote_tmp_dir }}/publickey.pub' |
| 23 |
privatekey_path: '{{ remote_tmp_dir }}/privatekey.pem' |
| 24 |
select_crypto_backend: '{{ select_crypto_backend }}' |
| 25 |
return_content: true |
| 26 |
register: publickey |
| 27 |
|
| 28 |
- name: "({{ select_crypto_backend }}) Generate publickey - PEM format (check mode, idempotence)" |
| 29 |
community.crypto.openssl_publickey: |
| 30 |
path: '{{ remote_tmp_dir }}/publickey.pub' |
| 31 |
privatekey_path: '{{ remote_tmp_dir }}/privatekey.pem' |
| 32 |
select_crypto_backend: '{{ select_crypto_backend }}' |
| 33 |
return_content: true |
| 34 |
check_mode: true |
| 35 |
register: publickey_check2 |
| 36 |
|
| 37 |
- name: "({{ select_crypto_backend }}) Generate publickey - PEM format (idempotence)" |
| 38 |
community.crypto.openssl_publickey: |
| 39 |
path: '{{ remote_tmp_dir }}/publickey.pub' |
| 40 |
privatekey_path: '{{ remote_tmp_dir }}/privatekey.pem' |
| 41 |
select_crypto_backend: '{{ select_crypto_backend }}' |
| 42 |
return_content: true |
| 43 |
register: publickey_idempotence |
| 44 |
|
| 45 |
- name: "({{ select_crypto_backend }}) Verify check mode" |
| 46 |
ansible.builtin.assert: |
| 47 |
that: |
| 48 |
- publickey_check is changed |
| 49 |
- publickey is changed |
| 50 |
- publickey_check2 is not changed |
| 51 |
- publickey_idempotence is not changed |
| 52 |
|
| 53 |
- name: "({{ select_crypto_backend }}) Generate publickey - OpenSSH format" |
| 54 |
community.crypto.openssl_publickey: |
| 55 |
path: '{{ remote_tmp_dir }}/publickey-ssh.pub' |
| 56 |
privatekey_path: '{{ remote_tmp_dir }}/privatekey.pem' |
| 57 |
format: OpenSSH |
| 58 |
select_crypto_backend: '{{ select_crypto_backend }}' |
| 59 |
when: select_crypto_backend == 'cryptography' |
| 60 |
|
| 61 |
- name: "({{ select_crypto_backend }}) Generate publickey - OpenSSH format - test idempotence (issue 33256)" |
| 62 |
community.crypto.openssl_publickey: |
| 63 |
path: '{{ remote_tmp_dir }}/publickey-ssh.pub' |
| 64 |
privatekey_path: '{{ remote_tmp_dir }}/privatekey.pem' |
| 65 |
format: OpenSSH |
| 66 |
select_crypto_backend: '{{ select_crypto_backend }}' |
| 67 |
when: select_crypto_backend == 'cryptography' |
| 68 |
register: publickey_ssh_idempotence |
| 69 |
|
| 70 |
- name: "({{ select_crypto_backend }}) Generate publickey2 - standard" |
| 71 |
community.crypto.openssl_publickey: |
| 72 |
path: '{{ remote_tmp_dir }}/publickey2.pub' |
| 73 |
privatekey_path: '{{ remote_tmp_dir }}/privatekey.pem' |
| 74 |
select_crypto_backend: '{{ select_crypto_backend }}' |
| 75 |
|
| 76 |
- name: "({{ select_crypto_backend }}) Delete publickey2 - standard" |
| 77 |
community.crypto.openssl_publickey: |
| 78 |
state: absent |
| 79 |
path: '{{ remote_tmp_dir }}/publickey2.pub' |
| 80 |
privatekey_path: '{{ remote_tmp_dir }}/privatekey.pem' |
| 81 |
select_crypto_backend: '{{ select_crypto_backend }}' |
| 82 |
return_content: true |
| 83 |
register: publickey2_absent |
| 84 |
|
| 85 |
- name: "({{ select_crypto_backend }}) Delete publickey2 - standard (idempotence)" |
| 86 |
community.crypto.openssl_publickey: |
| 87 |
state: absent |
| 88 |
path: '{{ remote_tmp_dir }}/publickey2.pub' |
| 89 |
privatekey_path: '{{ remote_tmp_dir }}/privatekey.pem' |
| 90 |
select_crypto_backend: '{{ select_crypto_backend }}' |
| 91 |
register: publickey2_absent_idempotence |
| 92 |
|
| 93 |
- name: "({{ select_crypto_backend }}) Generate privatekey3 - with passphrase" |
| 94 |
community.crypto.openssl_privatekey: |
| 95 |
path: '{{ remote_tmp_dir }}/privatekey3.pem' |
| 96 |
passphrase: ansible |
| 97 |
size: '{{ default_rsa_key_size }}' |
| 98 |
|
| 99 |
- name: "({{ select_crypto_backend }}) Generate publickey3 - with passphrase protected privatekey" |
| 100 |
community.crypto.openssl_publickey: |
| 101 |
path: '{{ remote_tmp_dir }}/publickey3.pub' |
| 102 |
privatekey_path: '{{ remote_tmp_dir }}/privatekey3.pem' |
| 103 |
privatekey_passphrase: ansible |
| 104 |
select_crypto_backend: '{{ select_crypto_backend }}' |
| 105 |
|
| 106 |
- name: "({{ select_crypto_backend }}) Generate publickey3 - with passphrase protected privatekey - idempotence" |
| 107 |
community.crypto.openssl_publickey: |
| 108 |
path: '{{ remote_tmp_dir }}/publickey3.pub' |
| 109 |
privatekey_path: '{{ remote_tmp_dir }}/privatekey3.pem' |
| 110 |
privatekey_passphrase: ansible |
| 111 |
select_crypto_backend: '{{ select_crypto_backend }}' |
| 112 |
register: publickey3_idempotence |
| 113 |
|
| 114 |
- name: "({{ select_crypto_backend }}) Generate empty file that will hold a public key (issue 33072)" |
| 115 |
ansible.builtin.file: |
| 116 |
path: '{{ remote_tmp_dir }}/publickey4.pub' |
| 117 |
state: touch |
| 118 |
|
| 119 |
- name: "({{ select_crypto_backend }}) Generate publickey in empty existing file (issue 33072)" |
| 120 |
community.crypto.openssl_publickey: |
| 121 |
path: '{{ remote_tmp_dir }}/publickey4.pub' |
| 122 |
privatekey_path: '{{ remote_tmp_dir }}/privatekey.pem' |
| 123 |
select_crypto_backend: '{{ select_crypto_backend }}' |
| 124 |
|
| 125 |
- name: "({{ select_crypto_backend }}) Generate privatekey 5 (ECC)" |
| 126 |
community.crypto.openssl_privatekey: |
| 127 |
path: '{{ remote_tmp_dir }}/privatekey5.pem' |
| 128 |
type: ECC |
| 129 |
curve: secp256r1 |
| 130 |
size: '{{ default_rsa_key_size }}' |
| 131 |
|
| 132 |
- name: "({{ select_crypto_backend }}) Generate publickey 5 - PEM format" |
| 133 |
community.crypto.openssl_publickey: |
| 134 |
path: '{{ remote_tmp_dir }}/publickey5.pub' |
| 135 |
privatekey_path: '{{ remote_tmp_dir }}/privatekey.pem' |
| 136 |
backup: true |
| 137 |
select_crypto_backend: '{{ select_crypto_backend }}' |
| 138 |
register: privatekey5_1 |
| 139 |
- name: "({{ select_crypto_backend }}) Generate publickey 5 - PEM format (idempotent)" |
| 140 |
community.crypto.openssl_publickey: |
| 141 |
path: '{{ remote_tmp_dir }}/publickey5.pub' |
| 142 |
privatekey_path: '{{ remote_tmp_dir }}/privatekey.pem' |
| 143 |
backup: true |
| 144 |
select_crypto_backend: '{{ select_crypto_backend }}' |
| 145 |
register: privatekey5_2 |
| 146 |
- name: "({{ select_crypto_backend }}) Generate publickey 5 - PEM format (different private key)" |
| 147 |
community.crypto.openssl_publickey: |
| 148 |
path: '{{ remote_tmp_dir }}/publickey5.pub' |
| 149 |
privatekey_path: '{{ remote_tmp_dir }}/privatekey5.pem' |
| 150 |
backup: true |
| 151 |
select_crypto_backend: '{{ select_crypto_backend }}' |
| 152 |
register: privatekey5_3 |
| 153 |
|
| 154 |
- name: "({{ select_crypto_backend }}) Generate privatekey with password" |
| 155 |
community.crypto.openssl_privatekey: |
| 156 |
path: '{{ remote_tmp_dir }}/privatekeypw.pem' |
| 157 |
passphrase: hunter2 |
| 158 |
select_crypto_backend: cryptography |
| 159 |
size: '{{ default_rsa_key_size }}' |
| 160 |
|
| 161 |
- name: "({{ select_crypto_backend }}) Generate publickey - PEM format (failed passphrase 1)" |
| 162 |
community.crypto.openssl_publickey: |
| 163 |
path: '{{ remote_tmp_dir }}/publickey_pw1.pub' |
| 164 |
privatekey_path: '{{ remote_tmp_dir }}/privatekey.pem' |
| 165 |
privatekey_passphrase: hunter2 |
| 166 |
select_crypto_backend: '{{ select_crypto_backend }}' |
| 167 |
ignore_errors: true |
| 168 |
register: passphrase_error_1 |
| 169 |
|
| 170 |
- name: "({{ select_crypto_backend }}) Generate publickey - PEM format (failed passphrase 2)" |
| 171 |
community.crypto.openssl_publickey: |
| 172 |
path: '{{ remote_tmp_dir }}/publickey_pw2.pub' |
| 173 |
privatekey_path: '{{ remote_tmp_dir }}/privatekeypw.pem' |
| 174 |
privatekey_passphrase: wrong_password |
| 175 |
select_crypto_backend: '{{ select_crypto_backend }}' |
| 176 |
ignore_errors: true |
| 177 |
register: passphrase_error_2 |
| 178 |
|
| 179 |
- name: "({{ select_crypto_backend }}) Generate publickey - PEM format (failed passphrase 3)" |
| 180 |
community.crypto.openssl_publickey: |
| 181 |
path: '{{ remote_tmp_dir }}/publickey_pw3.pub' |
| 182 |
privatekey_path: '{{ remote_tmp_dir }}/privatekeypw.pem' |
| 183 |
select_crypto_backend: '{{ select_crypto_backend }}' |
| 184 |
ignore_errors: true |
| 185 |
register: passphrase_error_3 |
| 186 |
|
| 187 |
- name: "({{ select_crypto_backend }}) Create broken key" |
| 188 |
ansible.builtin.copy: |
| 189 |
dest: "{{ remote_tmp_dir }}/publickeybroken.pub" |
| 190 |
content: "broken" |
| 191 |
- name: "({{ select_crypto_backend }}) Regenerate broken key" |
| 192 |
community.crypto.openssl_publickey: |
| 193 |
path: '{{ remote_tmp_dir }}/publickeybroken.pub' |
| 194 |
privatekey_path: '{{ remote_tmp_dir }}/privatekey5.pem' |
| 195 |
select_crypto_backend: '{{ select_crypto_backend }}' |
| 196 |
register: output_broken |
| 197 |
|
| 198 |
- name: "({{ select_crypto_backend }}) Generate publickey - PEM format (for removal)" |
| 199 |
community.crypto.openssl_publickey: |
| 200 |
path: '{{ remote_tmp_dir }}/publickey_removal.pub' |
| 201 |
privatekey_path: '{{ remote_tmp_dir }}/privatekey.pem' |
| 202 |
select_crypto_backend: '{{ select_crypto_backend }}' |
| 203 |
- name: "({{ select_crypto_backend }}) Generate publickey - PEM format (removal)" |
| 204 |
community.crypto.openssl_publickey: |
| 205 |
state: absent |
| 206 |
path: '{{ remote_tmp_dir }}/publickey_removal.pub' |
| 207 |
privatekey_path: '{{ remote_tmp_dir }}/privatekey.pem' |
| 208 |
backup: true |
| 209 |
select_crypto_backend: '{{ select_crypto_backend }}' |
| 210 |
register: remove_1 |
| 211 |
- name: "({{ select_crypto_backend }}) Generate publickey - PEM format (removal, idempotent)" |
| 212 |
community.crypto.openssl_publickey: |
| 213 |
state: absent |
| 214 |
path: '{{ remote_tmp_dir }}/publickey_removal.pub' |
| 215 |
privatekey_path: '{{ remote_tmp_dir }}/privatekey.pem' |
| 216 |
backup: true |
| 217 |
select_crypto_backend: '{{ select_crypto_backend }}' |
| 218 |
register: remove_2 |