| 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 |
- name: Retrieve information |
| 12 |
community.crypto.crypto_info: |
| 13 |
register: result |
| 14 |
|
| 15 |
- name: Display information |
| 16 |
ansible.builtin.debug: |
| 17 |
var: result |
| 18 |
|
| 19 |
- name: Register cryptography version |
| 20 |
ansible.builtin.command: "{{ ansible_facts.python.executable }} -c 'import cryptography; print(cryptography.__version__)'" |
| 21 |
register: local_cryptography_version |
| 22 |
|
| 23 |
- name: Set cryptography version |
| 24 |
ansible.builtin.set_fact: |
| 25 |
local_cryptography_version: "{{ local_cryptography_version.stdout }}" |
| 26 |
|
| 27 |
- name: Determine complex version-based capabilities |
| 28 |
ansible.builtin.set_fact: |
| 29 |
supports_ed25519: >- |
| 30 |
{{ |
| 31 |
local_cryptography_version is version("2.6", ">=") |
| 32 |
and not ( |
| 33 |
ansible_facts.os_family == "FreeBSD" and |
| 34 |
ansible_facts.distribution_version is version("12.1", ">=") and |
| 35 |
ansible_facts.distribution_version is version("12.2", "<") |
| 36 |
) |
| 37 |
}} |
| 38 |
supports_ed448: >- |
| 39 |
{{ |
| 40 |
local_cryptography_version is version("2.6", ">=") |
| 41 |
and not ( |
| 42 |
ansible_facts.os_family == "FreeBSD" and |
| 43 |
ansible_facts.distribution_version is version("12.1", ">=") and |
| 44 |
ansible_facts.distribution_version is version("12.2", "<") |
| 45 |
) |
| 46 |
}} |
| 47 |
|
| 48 |
- name: Verify cryptography information |
| 49 |
ansible.builtin.assert: |
| 50 |
that: |
| 51 |
- result.python_cryptography_installed |
| 52 |
- "'python_cryptography_import_error' not in result" |
| 53 |
- result.python_cryptography_capabilities.version == local_cryptography_version |
| 54 |
- "'secp256r1' in result.python_cryptography_capabilities.curves" |
| 55 |
- result.python_cryptography_capabilities.has_ec == (local_cryptography_version is version('0.5', '>=')) |
| 56 |
- result.python_cryptography_capabilities.has_ec_sign == (local_cryptography_version is version('1.5', '>=')) |
| 57 |
- result.python_cryptography_capabilities.has_ed25519 == supports_ed25519 |
| 58 |
- result.python_cryptography_capabilities.has_ed25519_sign == supports_ed25519 |
| 59 |
- result.python_cryptography_capabilities.has_ed448 == supports_ed448 |
| 60 |
- result.python_cryptography_capabilities.has_ed448_sign == supports_ed448 |
| 61 |
- result.python_cryptography_capabilities.has_dsa == (local_cryptography_version is version('0.5', '>=')) |
| 62 |
- result.python_cryptography_capabilities.has_dsa_sign == (local_cryptography_version is version('1.5', '>=')) |
| 63 |
- result.python_cryptography_capabilities.has_rsa == (local_cryptography_version is version('0.5', '>=')) |
| 64 |
- result.python_cryptography_capabilities.has_rsa_sign == (local_cryptography_version is version('1.4', '>=')) |
| 65 |
- result.python_cryptography_capabilities.has_x25519 == (local_cryptography_version is version('2.0', '>=')) |
| 66 |
- result.python_cryptography_capabilities.has_x25519_serialization == (local_cryptography_version is version('2.5', '>=')) |
| 67 |
- result.python_cryptography_capabilities.has_x448 == (local_cryptography_version is version('2.5', '>=')) |
| 68 |
|
| 69 |
- name: Find OpenSSL binary |
| 70 |
ansible.builtin.command: which openssl |
| 71 |
register: local_openssl_path |
| 72 |
|
| 73 |
- name: Find OpenSSL version |
| 74 |
ansible.builtin.command: openssl version |
| 75 |
register: local_openssl_version_full |
| 76 |
|
| 77 |
- name: Verify OpenSSL information |
| 78 |
ansible.builtin.assert: |
| 79 |
that: |
| 80 |
- result.openssl_present |
| 81 |
- result.openssl.path == local_openssl_path.stdout |
| 82 |
- (result.openssl.version_output | trim) == local_openssl_version_full.stdout |
| 83 |
- result.openssl.version == local_openssl_version_full.stdout.split(' ')[1] |