| 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 }}) Create key |
| 7 |
community.crypto.openssl_privatekey_pipe: |
| 8 |
select_crypto_backend: '{{ select_crypto_backend }}' |
| 9 |
register: result |
| 10 |
|
| 11 |
- name: ({{ select_crypto_backend }}) Get key info |
| 12 |
community.crypto.openssl_privatekey_info: |
| 13 |
content: "{{ result.privatekey }}" |
| 14 |
register: result_info |
| 15 |
|
| 16 |
- ansible.builtin.assert: |
| 17 |
that: |
| 18 |
- result is changed |
| 19 |
- result.privatekey.startswith('----') |
| 20 |
- result_info.type == 'RSA' |
| 21 |
- result_info.public_data.size == 4096 |
| 22 |
- result_info.public_data.exponent >= 5 |
| 23 |
|
| 24 |
- ansible.builtin.assert: |
| 25 |
that: |
| 26 |
- result_info.public_key_fingerprints.sha256 | length > 10 |
| 27 |
- result.fingerprint.sha256 == result_info.public_key_fingerprints.sha256 |
| 28 |
when: result.fingerprint is not none |
| 29 |
|
| 30 |
- name: ({{ select_crypto_backend }}) Update key (check mode) |
| 31 |
community.crypto.openssl_privatekey_pipe: |
| 32 |
select_crypto_backend: '{{ select_crypto_backend }}' |
| 33 |
content: "{{ result.privatekey }}" |
| 34 |
size: '{{ default_rsa_key_size }}' |
| 35 |
register: update_check |
| 36 |
check_mode: true |
| 37 |
|
| 38 |
- name: ({{ select_crypto_backend }}) Update key (check mode, with return_current_key=true) |
| 39 |
community.crypto.openssl_privatekey_pipe: |
| 40 |
select_crypto_backend: '{{ select_crypto_backend }}' |
| 41 |
content: "{{ result.privatekey }}" |
| 42 |
size: '{{ default_rsa_key_size }}' |
| 43 |
return_current_key: true |
| 44 |
register: update_check_return |
| 45 |
check_mode: true |
| 46 |
|
| 47 |
- name: ({{ select_crypto_backend }}) Update key |
| 48 |
community.crypto.openssl_privatekey_pipe: |
| 49 |
select_crypto_backend: '{{ select_crypto_backend }}' |
| 50 |
content: "{{ result.privatekey }}" |
| 51 |
size: '{{ default_rsa_key_size }}' |
| 52 |
register: update |
| 53 |
|
| 54 |
- name: ({{ select_crypto_backend }}) Update key (idempotent, check mode) |
| 55 |
community.crypto.openssl_privatekey_pipe: |
| 56 |
select_crypto_backend: '{{ select_crypto_backend }}' |
| 57 |
content: "{{ update.privatekey }}" |
| 58 |
size: '{{ default_rsa_key_size }}' |
| 59 |
register: update_idempotent_check |
| 60 |
check_mode: true |
| 61 |
|
| 62 |
- name: ({{ select_crypto_backend }}) Update key (idempotent) |
| 63 |
community.crypto.openssl_privatekey_pipe: |
| 64 |
select_crypto_backend: '{{ select_crypto_backend }}' |
| 65 |
content: "{{ update.privatekey }}" |
| 66 |
size: '{{ default_rsa_key_size }}' |
| 67 |
register: update_idempotent |
| 68 |
|
| 69 |
- name: ({{ select_crypto_backend }}) Update key (idempotent, check mode, with return_current_key=true) |
| 70 |
community.crypto.openssl_privatekey_pipe: |
| 71 |
select_crypto_backend: '{{ select_crypto_backend }}' |
| 72 |
content: "{{ update.privatekey }}" |
| 73 |
size: '{{ default_rsa_key_size }}' |
| 74 |
return_current_key: true |
| 75 |
register: update_idempotent_return_check |
| 76 |
check_mode: true |
| 77 |
|
| 78 |
- name: ({{ select_crypto_backend }}) Update key (idempotent, with return_current_key=true) |
| 79 |
community.crypto.openssl_privatekey_pipe: |
| 80 |
select_crypto_backend: '{{ select_crypto_backend }}' |
| 81 |
content: "{{ update.privatekey }}" |
| 82 |
size: '{{ default_rsa_key_size }}' |
| 83 |
return_current_key: true |
| 84 |
register: update_idempotent_return |
| 85 |
|
| 86 |
- name: ({{ select_crypto_backend }}) Get key info |
| 87 |
community.crypto.openssl_privatekey_info: |
| 88 |
content: "{{ update.privatekey }}" |
| 89 |
register: update_info |
| 90 |
|
| 91 |
- ansible.builtin.assert: |
| 92 |
that: |
| 93 |
- update_check is changed |
| 94 |
- update_check.privatekey != 'VALUE_SPECIFIED_IN_NO_LOG_PARAMETER' |
| 95 |
- update_check.privatekey != result.privatekey |
| 96 |
- update_check_return is changed |
| 97 |
- update_check_return.privatekey != 'VALUE_SPECIFIED_IN_NO_LOG_PARAMETER' |
| 98 |
- update_check_return.privatekey != result.privatekey |
| 99 |
- update is changed |
| 100 |
- update.privatekey != result.privatekey |
| 101 |
- update_info.public_data.size == default_rsa_key_size |
| 102 |
- update_idempotent_check is not changed |
| 103 |
- update_idempotent_check.privatekey is undefined |
| 104 |
- update_idempotent is not changed |
| 105 |
- update_idempotent.privatekey is undefined |
| 106 |
- update_idempotent_return_check is not changed |
| 107 |
- update_idempotent_return_check.privatekey == update.privatekey |
| 108 |
- update_idempotent_return is not changed |
| 109 |
- update_idempotent_return.privatekey == update.privatekey |