summaryrefslogtreecommitdiffstats
path: root/ansible_collections/community/crypto/plugins/modules
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-18 05:52:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-18 05:52:35 +0000
commit7fec0b69a082aaeec72fee0612766aa42f6b1b4d (patch)
treeefb569b86ca4da888717f5433e757145fa322e08 /ansible_collections/community/crypto/plugins/modules
parentReleasing progress-linux version 7.7.0+dfsg-3~progress7.99u1. (diff)
downloadansible-7fec0b69a082aaeec72fee0612766aa42f6b1b4d.tar.xz
ansible-7fec0b69a082aaeec72fee0612766aa42f6b1b4d.zip
Merging upstream version 9.4.0+dfsg.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/community/crypto/plugins/modules')
-rw-r--r--ansible_collections/community/crypto/plugins/modules/acme_account.py30
-rw-r--r--ansible_collections/community/crypto/plugins/modules/acme_account_info.py31
-rw-r--r--ansible_collections/community/crypto/plugins/modules/acme_certificate.py105
-rw-r--r--ansible_collections/community/crypto/plugins/modules/acme_certificate_revoke.py30
-rw-r--r--ansible_collections/community/crypto/plugins/modules/acme_challenge_cert_helper.py16
-rw-r--r--ansible_collections/community/crypto/plugins/modules/acme_inspect.py20
-rw-r--r--ansible_collections/community/crypto/plugins/modules/certificate_complete_chain.py4
-rw-r--r--ansible_collections/community/crypto/plugins/modules/crypto_info.py6
-rw-r--r--ansible_collections/community/crypto/plugins/modules/ecs_certificate.py161
-rw-r--r--ansible_collections/community/crypto/plugins/modules/ecs_domain.py96
-rw-r--r--ansible_collections/community/crypto/plugins/modules/get_certificate.py53
-rw-r--r--ansible_collections/community/crypto/plugins/modules/luks_device.py253
-rw-r--r--ansible_collections/community/crypto/plugins/modules/openssh_cert.py91
-rw-r--r--ansible_collections/community/crypto/plugins/modules/openssh_keypair.py50
-rw-r--r--ansible_collections/community/crypto/plugins/modules/openssl_csr.py10
-rw-r--r--ansible_collections/community/crypto/plugins/modules/openssl_csr_info.py79
-rw-r--r--ansible_collections/community/crypto/plugins/modules/openssl_csr_pipe.py29
-rw-r--r--ansible_collections/community/crypto/plugins/modules/openssl_dhparam.py20
-rw-r--r--ansible_collections/community/crypto/plugins/modules/openssl_pkcs12.py65
-rw-r--r--ansible_collections/community/crypto/plugins/modules/openssl_privatekey.py27
-rw-r--r--ansible_collections/community/crypto/plugins/modules/openssl_privatekey_convert.py8
-rw-r--r--ansible_collections/community/crypto/plugins/modules/openssl_privatekey_info.py58
-rw-r--r--ansible_collections/community/crypto/plugins/modules/openssl_privatekey_pipe.py43
-rw-r--r--ansible_collections/community/crypto/plugins/modules/openssl_publickey.py24
-rw-r--r--ansible_collections/community/crypto/plugins/modules/openssl_publickey_info.py39
-rw-r--r--ansible_collections/community/crypto/plugins/modules/openssl_signature.py8
-rw-r--r--ansible_collections/community/crypto/plugins/modules/openssl_signature_info.py10
-rw-r--r--ansible_collections/community/crypto/plugins/modules/x509_certificate.py16
-rw-r--r--ansible_collections/community/crypto/plugins/modules/x509_certificate_info.py88
-rw-r--r--ansible_collections/community/crypto/plugins/modules/x509_certificate_pipe.py28
-rw-r--r--ansible_collections/community/crypto/plugins/modules/x509_crl.py179
-rw-r--r--ansible_collections/community/crypto/plugins/modules/x509_crl_info.py43
32 files changed, 1043 insertions, 677 deletions
diff --git a/ansible_collections/community/crypto/plugins/modules/acme_account.py b/ansible_collections/community/crypto/plugins/modules/acme_account.py
index 13de49ab0..1e8d64a57 100644
--- a/ansible_collections/community/crypto/plugins/modules/acme_account.py
+++ b/ansible_collections/community/crypto/plugins/modules/acme_account.py
@@ -22,7 +22,7 @@ description:
notes:
- "The M(community.crypto.acme_certificate) module also allows to do basic account management.
When using both modules, it is recommended to disable account management
- for M(community.crypto.acme_certificate). For that, use the C(modify_account) option of
+ for M(community.crypto.acme_certificate). For that, use the O(community.crypto.acme_certificate#module:modify_account) option of
M(community.crypto.acme_certificate)."
seealso:
- name: Automatic Certificate Management Environment (ACME)
@@ -49,9 +49,9 @@ options:
state:
description:
- "The state of the account, to be identified by its account key."
- - "If the state is C(absent), the account will either not exist or be
+ - "If the state is V(absent), the account will either not exist or be
deactivated."
- - "If the state is C(changed_key), the account must exist. The account
+ - "If the state is V(changed_key), the account must exist. The account
key will be changed; no other information will be touched."
type: str
required: true
@@ -61,7 +61,7 @@ options:
- changed_key
allow_creation:
description:
- - "Whether account creation is allowed (when state is C(present))."
+ - "Whether account creation is allowed (when state is V(present))."
type: bool
default: true
contact:
@@ -70,30 +70,30 @@ options:
- "Email addresses must be prefixed with C(mailto:)."
- "See U(https://tools.ietf.org/html/rfc8555#section-7.3)
for what is allowed."
- - "Must be specified when state is C(present). Will be ignored
- if state is C(absent) or C(changed_key)."
+ - "Must be specified when state is V(present). Will be ignored
+ if state is V(absent) or V(changed_key)."
type: list
elements: str
default: []
terms_agreed:
description:
- "Boolean indicating whether you agree to the terms of service document."
- - "ACME servers can require this to be true."
+ - "ACME servers can require this to be V(true)."
type: bool
default: false
new_account_key_src:
description:
- "Path to a file containing the ACME account RSA or Elliptic Curve key to change to."
- - "Same restrictions apply as to C(account_key_src)."
- - "Mutually exclusive with C(new_account_key_content)."
- - "Required if C(new_account_key_content) is not used and state is C(changed_key)."
+ - "Same restrictions apply as to O(account_key_src)."
+ - "Mutually exclusive with O(new_account_key_content)."
+ - "Required if O(new_account_key_content) is not used and O(state) is V(changed_key)."
type: path
new_account_key_content:
description:
- "Content of the ACME account RSA or Elliptic Curve key to change to."
- - "Same restrictions apply as to C(account_key_content)."
- - "Mutually exclusive with C(new_account_key_src)."
- - "Required if C(new_account_key_src) is not used and state is C(changed_key)."
+ - "Same restrictions apply as to O(account_key_content)."
+ - "Mutually exclusive with O(new_account_key_src)."
+ - "Required if O(new_account_key_src) is not used and O(state) is V(changed_key)."
type: str
new_account_key_passphrase:
description:
@@ -117,14 +117,14 @@ options:
alg:
description:
- The MAC algorithm provided by the CA.
- - If not specified by the CA, this is probably C(HS256).
+ - If not specified by the CA, this is probably V(HS256).
type: str
required: true
choices: [ HS256, HS384, HS512 ]
key:
description:
- Base64 URL encoded value of the MAC key provided by the CA.
- - Padding (C(=) symbols at the end) can be omitted.
+ - Padding (V(=) symbols at the end) can be omitted.
type: str
required: true
version_added: 1.1.0
diff --git a/ansible_collections/community/crypto/plugins/modules/acme_account_info.py b/ansible_collections/community/crypto/plugins/modules/acme_account_info.py
index 4e1a3c7b7..ac4617c90 100644
--- a/ansible_collections/community/crypto/plugins/modules/acme_account_info.py
+++ b/ansible_collections/community/crypto/plugins/modules/acme_account_info.py
@@ -34,11 +34,11 @@ options:
description:
- "Whether to retrieve the list of order URLs or order objects, if provided
by the ACME server."
- - "A value of C(ignore) will not fetch the list of orders."
- - "If the value is not C(ignore) and the ACME server supports orders, the C(order_uris)
- return value is always populated. The C(orders) return value is only returned
- if this option is set to C(object_list)."
- - "Currently, Let's Encrypt does not return orders, so the C(orders) result
+ - "A value of V(ignore) will not fetch the list of orders."
+ - "If the value is not V(ignore) and the ACME server supports orders, the RV(order_uris)
+ return value is always populated. The RV(orders) return value is only returned
+ if this option is set to V(object_list)."
+ - "Currently, Let's Encrypt does not return orders, so the RV(orders) result
will always be empty."
type: str
choices:
@@ -113,7 +113,7 @@ account:
orders:
description:
- A URL where a list of orders can be retrieved for this account.
- - Use the I(retrieve_orders) option to query this URL and retrieve the
+ - Use the O(retrieve_orders) option to query this URL and retrieve the
complete list of orders.
returned: always
type: str
@@ -129,7 +129,7 @@ orders:
- "The list of orders."
type: list
elements: dict
- returned: if account exists, I(retrieve_orders) is C(object_list), and server supports order listing
+ returned: if account exists, O(retrieve_orders) is V(object_list), and server supports order listing
contains:
status:
description: The order's status.
@@ -144,7 +144,7 @@ orders:
description:
- When the order expires.
- Timestamp should be formatted as described in RFC3339.
- - Only required to be included in result when I(status) is C(pending) or C(valid).
+ - Only required to be included in result when RV(orders[].status) is V(pending) or V(valid).
type: str
returned: when server gives expiry date
identifiers:
@@ -154,14 +154,17 @@ orders:
elements: dict
contains:
type:
- description: Type of identifier. C(dns) or C(ip).
+ description: Type of identifier.
type: str
+ choices:
+ - dns
+ - ip
value:
description: Name of identifier. Hostname or IP address.
type: str
wildcard:
- description: "Whether I(value) is actually a wildcard. The wildcard
- prefix C(*.) is not included in I(value) if this is C(true)."
+ description: "Whether RV(orders[].identifiers[].value) is actually a wildcard. The wildcard
+ prefix C(*.) is not included in RV(orders[].identifiers[].value) if this is V(true)."
type: bool
returned: required to be included if the identifier is wildcarded
notBefore:
@@ -202,11 +205,11 @@ orders:
order_uris:
description:
- "The list of orders."
- - "If I(retrieve_orders) is C(url_list), this will be a list of URLs."
- - "If I(retrieve_orders) is C(object_list), this will be a list of objects."
+ - "If O(retrieve_orders) is V(url_list), this will be a list of URLs."
+ - "If O(retrieve_orders) is V(object_list), this will be a list of objects."
type: list
elements: str
- returned: if account exists, I(retrieve_orders) is not C(ignore), and server supports order listing
+ returned: if account exists, O(retrieve_orders) is not V(ignore), and server supports order listing
version_added: 1.5.0
'''
diff --git a/ansible_collections/community/crypto/plugins/modules/acme_certificate.py b/ansible_collections/community/crypto/plugins/modules/acme_certificate.py
index 6aec44e08..9c0b349c4 100644
--- a/ansible_collections/community/crypto/plugins/modules/acme_certificate.py
+++ b/ansible_collections/community/crypto/plugins/modules/acme_certificate.py
@@ -19,15 +19,15 @@ description:
L(ACME protocol,https://tools.ietf.org/html/rfc8555),
such as L(Let's Encrypt,https://letsencrypt.org/) or
L(Buypass,https://www.buypass.com/). The current implementation
- supports the C(http-01), C(dns-01) and C(tls-alpn-01) challenges."
+ supports the V(http-01), V(dns-01) and V(tls-alpn-01) challenges."
- "To use this module, it has to be executed twice. Either as two
different tasks in the same run or during two runs. Note that the output
of the first run needs to be recorded and passed to the second run as the
- module argument C(data)."
+ module argument O(data)."
- "Between these two tasks you have to fulfill the required steps for the
- chosen challenge by whatever means necessary. For C(http-01) that means
+ chosen challenge by whatever means necessary. For V(http-01) that means
creating the necessary challenge file on the destination webserver. For
- C(dns-01) the necessary dns record has to be created. For C(tls-alpn-01)
+ V(dns-01) the necessary dns record has to be created. For V(tls-alpn-01)
the necessary certificate has to be created and served.
It is I(not) the responsibility of this module to perform these steps."
- "For details on how to fulfill these challenges, you might have to read through
@@ -37,11 +37,11 @@ description:
- "The module includes experimental support for IP identifiers according to
the L(RFC 8738,https://www.rfc-editor.org/rfc/rfc8738.html)."
notes:
- - "At least one of C(dest) and C(fullchain_dest) must be specified."
+ - "At least one of O(dest) and O(fullchain_dest) must be specified."
- "This module includes basic account management functionality.
If you want to have more control over your ACME account, use the
M(community.crypto.acme_account) module and disable account management
- for this module using the C(modify_account) option."
+ for this module using the O(modify_account) option."
- "This module was called C(letsencrypt) before Ansible 2.6. The usage
did not change."
seealso:
@@ -57,10 +57,10 @@ seealso:
description: The specification of the ACME protocol (RFC 8555).
link: https://tools.ietf.org/html/rfc8555
- name: ACME TLS ALPN Challenge Extension
- description: The specification of the C(tls-alpn-01) challenge (RFC 8737).
+ description: The specification of the V(tls-alpn-01) challenge (RFC 8737).
link: https://www.rfc-editor.org/rfc/rfc8737.html-05
- module: community.crypto.acme_challenge_cert_helper
- description: Helps preparing C(tls-alpn-01) challenges.
+ description: Helps preparing V(tls-alpn-01) challenges.
- module: community.crypto.openssl_privatekey
description: Can be used to create private keys (both for certificates and accounts).
- module: community.crypto.openssl_privatekey_pipe
@@ -94,7 +94,7 @@ options:
description:
- "The email address associated with this account."
- "It will be used for certificate expiration warnings."
- - "Note that when C(modify_account) is not set to C(false) and you also
+ - "Note that when O(modify_account) is not set to V(false) and you also
used the M(community.crypto.acme_account) module to specify more than one contact
for your account, this module will update your account and restrict
it to the (at most one) contact email address specified here."
@@ -102,31 +102,31 @@ options:
agreement:
description:
- "URI to a terms of service document you agree to when using the
- ACME v1 service at C(acme_directory)."
- - Default is latest gathered from C(acme_directory) URL.
- - This option will only be used when C(acme_version) is 1.
+ ACME v1 service at O(acme_directory)."
+ - Default is latest gathered from O(acme_directory) URL.
+ - This option will only be used when O(acme_version) is 1.
type: str
terms_agreed:
description:
- "Boolean indicating whether you agree to the terms of service document."
- "ACME servers can require this to be true."
- - This option will only be used when C(acme_version) is not 1.
+ - This option will only be used when O(acme_version) is not 1.
type: bool
default: false
modify_account:
description:
- "Boolean indicating whether the module should create the account if
necessary, and update its contact data."
- - "Set to C(false) if you want to use the M(community.crypto.acme_account) module to manage
+ - "Set to V(false) if you want to use the M(community.crypto.acme_account) module to manage
your account instead, and to avoid accidental creation of a new account
using an old key if you changed the account key with M(community.crypto.acme_account)."
- - "If set to C(false), C(terms_agreed) and C(account_email) are ignored."
+ - "If set to V(false), O(terms_agreed) and O(account_email) are ignored."
type: bool
default: true
challenge:
description:
- The challenge to be performed.
- - If set to C(no challenge), no challenge will be used. This is necessary for some private
+ - If set to V(no challenge), no challenge will be used. This is necessary for some private
CAs which use External Account Binding and other means of validating certificate assurance.
For example, an account could be allowed to issue certificates for C(foo.example.com)
without any further validation for a certain period of time.
@@ -148,7 +148,7 @@ options:
account key. This is a bad idea from a security point of view, and
the CA should not accept the CSR. The ACME server should return an
error in this case."
- - Precisely one of I(csr) or I(csr_content) must be specified.
+ - Precisely one of O(csr) or O(csr_content) must be specified.
type: path
aliases: ['src']
csr_content:
@@ -162,7 +162,7 @@ options:
account key. This is a bad idea from a security point of view, and
the CA should not accept the CSR. The ACME server should return an
error in this case."
- - Precisely one of I(csr) or I(csr_content) must be specified.
+ - Precisely one of O(csr) or O(csr_content) must be specified.
type: str
version_added: 1.2.0
data:
@@ -171,27 +171,27 @@ options:
the second run of the module only."
- "The value that must be used here will be provided by a previous use
of this module. See the examples for more details."
- - "Note that for ACME v2, only the C(order_uri) entry of C(data) will
- be used. For ACME v1, C(data) must be non-empty to indicate the
+ - "Note that for ACME v2, only the C(order_uri) entry of O(data) will
+ be used. For ACME v1, O(data) must be non-empty to indicate the
second stage is active; all needed data will be taken from the
CSR."
- - "I(Note): the C(data) option was marked as C(no_log) up to
+ - "I(Note): the O(data) option was marked as C(no_log) up to
Ansible 2.5. From Ansible 2.6 on, it is no longer marked this way
- as it causes error messages to be come unusable, and C(data) does
+ as it causes error messages to be come unusable, and O(data) does
not contain any information which can be used without having
access to the account key or which are not public anyway."
type: dict
dest:
description:
- "The destination file for the certificate."
- - "Required if C(fullchain_dest) is not specified."
+ - "Required if O(fullchain_dest) is not specified."
type: path
aliases: ['cert']
fullchain_dest:
description:
- "The destination file for the full chain (that is, a certificate followed
by chain of intermediate certificates)."
- - "Required if C(dest) is not specified."
+ - "Required if O(dest) is not specified."
type: path
aliases: ['fullchain']
chain_dest:
@@ -202,11 +202,11 @@ options:
remaining_days:
description:
- "The number of days the certificate must have left being valid.
- If C(cert_days < remaining_days), then it will be renewed.
+ If RV(cert_days) < O(remaining_days), then it will be renewed.
If the certificate is not renewed, module return values will not
- include C(challenge_data)."
+ include RV(challenge_data)."
- "To make sure that the certificate is renewed in any case, you can
- use the C(force) option."
+ use the O(force) option."
type: int
default: 10
deactivate_authzs:
@@ -222,16 +222,16 @@ options:
force:
description:
- Enforces the execution of the challenge and validation, even if an
- existing certificate is still valid for more than C(remaining_days).
+ existing certificate is still valid for more than O(remaining_days).
- This is especially helpful when having an updated CSR, for example with
additional domains for which a new certificate is desired.
type: bool
default: false
retrieve_all_alternates:
description:
- - "When set to C(true), will retrieve all alternate trust chains offered by the ACME CA.
+ - "When set to V(true), will retrieve all alternate trust chains offered by the ACME CA.
These will not be written to disk, but will be returned together with the main
- chain as C(all_chains). See the documentation for the C(all_chains) return
+ chain as RV(all_chains). See the documentation for the RV(all_chains) return
value for details."
type: bool
default: false
@@ -244,8 +244,8 @@ options:
- "If a criterium matches multiple chains, the first one matching will be
returned. The order is determined by the ordering of the C(Link) headers
returned by the ACME server and might not be deterministic."
- - "Every criterium can consist of multiple different conditions, like I(issuer)
- and I(subject). For the criterium to match a chain, all conditions must apply
+ - "Every criterium can consist of multiple different conditions, like O(select_chain[].issuer)
+ and O(select_chain[].subject). For the criterium to match a chain, all conditions must apply
to the same certificate in the chain."
- "This option can only be used with the C(cryptography) backend."
type: list
@@ -255,11 +255,11 @@ options:
test_certificates:
description:
- "Determines which certificates in the chain will be tested."
- - "I(all) tests all certificates in the chain (excluding the leaf, which is
+ - "V(all) tests all certificates in the chain (excluding the leaf, which is
identical in all chains)."
- - "I(first) only tests the first certificate in the chain, that is the one which
+ - "V(first) only tests the first certificate in the chain, that is the one which
signed the leaf."
- - "I(last) only tests the last certificate in the chain, that is the one furthest
+ - "V(last) only tests the last certificate in the chain, that is the one furthest
away from the leaf. Its issuer is the root certificate of this chain."
type: str
default: all
@@ -268,29 +268,29 @@ options:
description:
- "Allows to specify parts of the issuer of a certificate in the chain must
have to be selected."
- - "If I(issuer) is empty, any certificate will match."
- - 'An example value would be C({"commonName": "My Preferred CA Root"}).'
+ - "If O(select_chain[].issuer) is empty, any certificate will match."
+ - 'An example value would be V({"commonName": "My Preferred CA Root"}).'
type: dict
subject:
description:
- "Allows to specify parts of the subject of a certificate in the chain must
have to be selected."
- - "If I(subject) is empty, any certificate will match."
- - 'An example value would be C({"CN": "My Preferred CA Intermediate"})'
+ - "If O(select_chain[].subject) is empty, any certificate will match."
+ - 'An example value would be V({"CN": "My Preferred CA Intermediate"})'
type: dict
subject_key_identifier:
description:
- "Checks for the SubjectKeyIdentifier extension. This is an identifier based
on the private key of the intermediate certificate."
- "The identifier must be of the form
- C(A8:4A:6A:63:04:7D:DD:BA:E6:D1:39:B7:A6:45:65:EF:F3:A8:EC:A1)."
+ V(A8:4A:6A:63:04:7D:DD:BA:E6:D1:39:B7:A6:45:65:EF:F3:A8:EC:A1)."
type: str
authority_key_identifier:
description:
- "Checks for the AuthorityKeyIdentifier extension. This is an identifier based
on the private key of the issuer of the intermediate certificate."
- "The identifier must be of the form
- C(C4:A7:B1:A4:7B:2C:71:FA:DB:E1:4B:90:75:FF:C4:15:60:85:89:10)."
+ V(C4:A7:B1:A4:7B:2C:71:FA:DB:E1:4B:90:75:FF:C4:15:60:85:89:10)."
type: str
'''
@@ -305,9 +305,10 @@ EXAMPLES = r'''
register: sample_com_challenge
# Alternative first step:
-- name: Create a challenge for sample.com using a account key from hashi vault.
+- name: Create a challenge for sample.com using a account key from Hashi Vault.
community.crypto.acme_certificate:
- account_key_content: "{{ lookup('hashi_vault', 'secret=secret/account_private_key:value') }}"
+ account_key_content: >-
+ {{ lookup('community.hashi_vault.hashi_vault', 'secret=secret/account_private_key:value') }}
csr: /etc/pki/cert/csr/sample.com.csr
fullchain_dest: /etc/httpd/ssl/sample.com-fullchain.crt
register: sample_com_challenge
@@ -455,32 +456,32 @@ challenge_data:
sample: .well-known/acme-challenge/evaGxfADs6pSRb2LAv9IZf17Dt3juxGJ-PCt92wr-oA
resource_original:
description:
- - The original challenge resource including type identifier for C(tls-alpn-01)
+ - The original challenge resource including type identifier for V(tls-alpn-01)
challenges.
- returned: changed and challenge is C(tls-alpn-01)
+ returned: changed and O(challenge) is V(tls-alpn-01)
type: str
sample: DNS:example.com
resource_value:
description:
- The value the resource has to produce for the validation.
- - For C(http-01) and C(dns-01) challenges, the value can be used as-is.
- - "For C(tls-alpn-01) challenges, note that this return value contains a
+ - For V(http-01) and V(dns-01) challenges, the value can be used as-is.
+ - "For V(tls-alpn-01) challenges, note that this return value contains a
Base64 encoded version of the correct binary blob which has to be put
into the acmeValidation x509 extension; see
U(https://www.rfc-editor.org/rfc/rfc8737.html#section-3)
- for details. To do this, you might need the C(b64decode) Jinja filter
+ for details. To do this, you might need the P(ansible.builtin.b64decode#filter) Jinja filter
to extract the binary blob from this return value."
returned: changed
type: str
sample: IlirfxKKXA...17Dt3juxGJ-PCt92wr-oA
record:
description: The full DNS record's name for the challenge.
- returned: changed and challenge is C(dns-01)
+ returned: changed and challenge is V(dns-01)
type: str
sample: _acme-challenge.example.com
challenge_data_dns:
description:
- - List of TXT values per DNS record, in case challenge is C(dns-01).
+ - List of TXT values per DNS record, in case challenge is V(dns-01).
- Since Ansible 2.8.5, only challenges which are not yet valid are returned.
returned: changed
type: dict
@@ -518,11 +519,11 @@ account_uri:
type: str
all_chains:
description:
- - When I(retrieve_all_alternates) is set to C(true), the module will query the ACME server
+ - When O(retrieve_all_alternates) is set to V(true), the module will query the ACME server
for alternate chains. This return value will contain a list of all chains returned,
the first entry being the main chain returned by the server.
- See L(Section 7.4.2 of RFC8555,https://tools.ietf.org/html/rfc8555#section-7.4.2) for details.
- returned: when certificate was retrieved and I(retrieve_all_alternates) is set to C(true)
+ returned: when certificate was retrieved and O(retrieve_all_alternates) is set to V(true)
type: list
elements: dict
contains:
diff --git a/ansible_collections/community/crypto/plugins/modules/acme_certificate_revoke.py b/ansible_collections/community/crypto/plugins/modules/acme_certificate_revoke.py
index f1922384a..022862e60 100644
--- a/ansible_collections/community/crypto/plugins/modules/acme_certificate_revoke.py
+++ b/ansible_collections/community/crypto/plugins/modules/acme_certificate_revoke.py
@@ -19,8 +19,8 @@ description:
L(ACME protocol,https://tools.ietf.org/html/rfc8555),
such as L(Let's Encrypt,https://letsencrypt.org/)."
notes:
- - "Exactly one of C(account_key_src), C(account_key_content),
- C(private_key_src) or C(private_key_content) must be specified."
+ - "Exactly one of O(account_key_src), O(account_key_content),
+ O(private_key_src), or O(private_key_content) must be specified."
- "Trying to revoke an already revoked certificate
should result in an unchanged status, even if the revocation reason
was different than the one specified here. Also, depending on the
@@ -58,13 +58,13 @@ options:
- "RSA keys can be created with C(openssl rsa ...). Elliptic curve keys can
be created with C(openssl ecparam -genkey ...). Any other tool creating
private keys in PEM format can be used as well."
- - "Mutually exclusive with C(account_key_content)."
- - "Required if C(account_key_content) is not used."
+ - "Mutually exclusive with O(account_key_content)."
+ - "Required if O(account_key_content) is not used."
account_key_content:
description:
- "Content of the ACME account RSA or Elliptic Curve key."
- - "Note that exactly one of C(account_key_src), C(account_key_content),
- C(private_key_src) or C(private_key_content) must be specified."
+ - "Note that exactly one of O(account_key_src), O(account_key_content),
+ O(private_key_src), or O(private_key_content) must be specified."
- "I(Warning): the content will be written into a temporary file, which will
be deleted by Ansible when the module completes. Since this is an
important private key — it can be used to change the account key,
@@ -77,14 +77,14 @@ options:
private_key_src:
description:
- "Path to the certificate's private key."
- - "Note that exactly one of C(account_key_src), C(account_key_content),
- C(private_key_src) or C(private_key_content) must be specified."
+ - "Note that exactly one of O(account_key_src), O(account_key_content),
+ O(private_key_src), or O(private_key_content) must be specified."
type: path
private_key_content:
description:
- "Content of the certificate's private key."
- - "Note that exactly one of C(account_key_src), C(account_key_content),
- C(private_key_src) or C(private_key_content) must be specified."
+ - "Note that exactly one of O(account_key_src), O(account_key_content),
+ O(private_key_src), or O(private_key_content) must be specified."
- "I(Warning): the content will be written into a temporary file, which will
be deleted by Ansible when the module completes. Since this is an
important private key — it can be used to change the account key,
@@ -105,11 +105,11 @@ options:
description:
- "One of the revocation reasonCodes defined in
L(Section 5.3.1 of RFC5280,https://tools.ietf.org/html/rfc5280#section-5.3.1)."
- - "Possible values are C(0) (unspecified), C(1) (keyCompromise),
- C(2) (cACompromise), C(3) (affiliationChanged), C(4) (superseded),
- C(5) (cessationOfOperation), C(6) (certificateHold),
- C(8) (removeFromCRL), C(9) (privilegeWithdrawn),
- C(10) (aACompromise)."
+ - "Possible values are V(0) (unspecified), V(1) (keyCompromise),
+ V(2) (cACompromise), V(3) (affiliationChanged), V(4) (superseded),
+ V(5) (cessationOfOperation), V(6) (certificateHold),
+ V(8) (removeFromCRL), V(9) (privilegeWithdrawn),
+ V(10) (aACompromise)."
type: int
'''
diff --git a/ansible_collections/community/crypto/plugins/modules/acme_challenge_cert_helper.py b/ansible_collections/community/crypto/plugins/modules/acme_challenge_cert_helper.py
index 1b963e8cc..9740cd16d 100644
--- a/ansible_collections/community/crypto/plugins/modules/acme_challenge_cert_helper.py
+++ b/ansible_collections/community/crypto/plugins/modules/acme_challenge_cert_helper.py
@@ -49,7 +49,7 @@ options:
- tls-alpn-01
challenge_data:
description:
- - "The C(challenge_data) entry provided by M(community.crypto.acme_certificate) for the
+ - "The RV(community.crypto.acme_certificate#module:challenge_data) entry provided by M(community.crypto.acme_certificate) for the
challenge."
type: dict
required: true
@@ -57,12 +57,12 @@ options:
description:
- "Path to a file containing the private key file to use for this challenge
certificate."
- - "Mutually exclusive with C(private_key_content)."
+ - "Mutually exclusive with O(private_key_content)."
type: path
private_key_content:
description:
- "Content of the private key to use for this challenge certificate."
- - "Mutually exclusive with C(private_key_src)."
+ - "Mutually exclusive with O(private_key_src)."
type: str
private_key_passphrase:
description:
@@ -122,14 +122,16 @@ domain:
type: str
identifier_type:
description:
- - "The identifier type for the actual resource identifier. Will be C(dns)
- or C(ip)."
+ - "The identifier type for the actual resource identifier."
returned: always
type: str
+ choices:
+ - dns
+ - ip
identifier:
description:
- - "The identifier for the actual resource. Will be a domain name if the
- type is C(dns), or an IP address if the type is C(ip)."
+ - "The identifier for the actual resource. Will be a domain name if
+ RV(identifier_type=dns), or an IP address if RV(identifier_type=ip)."
returned: always
type: str
challenge_certificate:
diff --git a/ansible_collections/community/crypto/plugins/modules/acme_inspect.py b/ansible_collections/community/crypto/plugins/modules/acme_inspect.py
index d5c96b722..a2c76507e 100644
--- a/ansible_collections/community/crypto/plugins/modules/acme_inspect.py
+++ b/ansible_collections/community/crypto/plugins/modules/acme_inspect.py
@@ -24,7 +24,7 @@ description:
- "The module can also be used to directly access features of an ACME servers
which are not yet supported by the Ansible ACME modules."
notes:
- - "The I(account_uri) option must be specified for properly authenticated
+ - "The O(account_uri) option must be specified for properly authenticated
ACME v2 requests (except a C(new-account) request)."
- "Using the C(ansible) tool, M(community.crypto.acme_inspect) can be used to directly execute
ACME requests without the need of writing a playbook. For example, the
@@ -54,16 +54,16 @@ options:
url:
description:
- "The URL to send the request to."
- - "Must be specified if I(method) is not C(directory-only)."
+ - "Must be specified if O(method) is not V(directory-only)."
type: str
method:
description:
- "The method to use to access the given URL on the ACME server."
- - "The value C(post) executes an authenticated POST request. The content
- must be specified in the I(content) option."
- - "The value C(get) executes an authenticated POST-as-GET request for ACME v2,
+ - "The value V(post) executes an authenticated POST request. The content
+ must be specified in the O(content) option."
+ - "The value V(get) executes an authenticated POST-as-GET request for ACME v2,
and a regular GET request for ACME v1."
- - "The value C(directory-only) only retrieves the directory, without doing
+ - "The value V(directory-only) only retrieves the directory, without doing
a request."
type: str
default: get
@@ -73,13 +73,13 @@ options:
- directory-only
content:
description:
- - "An encoded JSON object which will be sent as the content if I(method)
- is C(post)."
- - "Required when I(method) is C(post), and not allowed otherwise."
+ - "An encoded JSON object which will be sent as the content if O(method)
+ is V(post)."
+ - "Required when O(method) is V(post), and not allowed otherwise."
type: str
fail_on_acme_error:
description:
- - "If I(method) is C(post) or C(get), make the module fail in case an ACME
+ - "If O(method) is V(post) or V(get), make the module fail in case an ACME
error is returned."
type: bool
default: true
diff --git a/ansible_collections/community/crypto/plugins/modules/certificate_complete_chain.py b/ansible_collections/community/crypto/plugins/modules/certificate_complete_chain.py
index b1862d2ce..357d2f668 100644
--- a/ansible_collections/community/crypto/plugins/modules/certificate_complete_chain.py
+++ b/ansible_collections/community/crypto/plugins/modules/certificate_complete_chain.py
@@ -78,7 +78,7 @@ EXAMPLES = '''
# certificates, finds the associated root certificate.
- name: Find root certificate
community.crypto.certificate_complete_chain:
- input_chain: "{{ lookup('file', '/etc/ssl/csr/www.ansible.com-fullchain.pem') }}"
+ input_chain: "{{ lookup('ansible.builtin.file', '/etc/ssl/csr/www.ansible.com-fullchain.pem') }}"
root_certificates:
- /etc/ca-certificates/
register: www_ansible_com
@@ -91,7 +91,7 @@ EXAMPLES = '''
# certificates, finds the associated root certificate.
- name: Find root certificate
community.crypto.certificate_complete_chain:
- input_chain: "{{ lookup('file', '/etc/ssl/csr/www.ansible.com.pem') }}"
+ input_chain: "{{ lookup('ansible.builtin.file', '/etc/ssl/csr/www.ansible.com.pem') }}"
intermediate_certificates:
- /etc/ssl/csr/www.ansible.com-chain.pem
root_certificates:
diff --git a/ansible_collections/community/crypto/plugins/modules/crypto_info.py b/ansible_collections/community/crypto/plugins/modules/crypto_info.py
index 1988eb32d..d776ac52c 100644
--- a/ansible_collections/community/crypto/plugins/modules/crypto_info.py
+++ b/ansible_collections/community/crypto/plugins/modules/crypto_info.py
@@ -45,12 +45,12 @@ python_cryptography_installed:
python_cryptography_import_error:
description: Import error when trying to import the L(Python cryptography library, https://cryptography.io/).
- returned: when I(python_cryptography_installed=false)
+ returned: when RV(python_cryptography_installed=false)
type: str
python_cryptography_capabilities:
description: Information on the installed L(Python cryptography library, https://cryptography.io/).
- returned: when I(python_cryptography_installed=true)
+ returned: when RV(python_cryptography_installed=true)
type: dict
contains:
version:
@@ -136,7 +136,7 @@ openssl_present:
openssl:
description: Information on the installed OpenSSL binary.
- returned: when I(openssl_present=true)
+ returned: when RV(openssl_present=true)
type: dict
contains:
path:
diff --git a/ansible_collections/community/crypto/plugins/modules/ecs_certificate.py b/ansible_collections/community/crypto/plugins/modules/ecs_certificate.py
index b19b86f56..2c1238d48 100644
--- a/ansible_collections/community/crypto/plugins/modules/ecs_certificate.py
+++ b/ansible_collections/community/crypto/plugins/modules/ecs_certificate.py
@@ -21,7 +21,7 @@ description:
- In order to request a certificate, the domain and organization used in the certificate signing request must be already
validated in the ECS system. It is I(not) the responsibility of this module to perform those steps.
notes:
- - C(path) must be specified as the output location of the certificate.
+ - O(path) must be specified as the output location of the certificate.
requirements:
- cryptography >= 1.6
extends_documentation_fragment:
@@ -32,7 +32,7 @@ attributes:
check_mode:
support: partial
details:
- - Check mode is only supported if I(request_type=new).
+ - Check mode is only supported if O(request_type=new).
diff_mode:
support: none
safe_file_operations:
@@ -40,14 +40,14 @@ attributes:
options:
backup:
description:
- - Whether a backup should be made for the certificate in I(path).
+ - Whether a backup should be made for the certificate in O(path).
type: bool
default: false
force:
description:
- - If force is used, a certificate is requested regardless of whether I(path) points to an existing valid certificate.
- - If C(request_type=renew), a forced renew will fail if the certificate being renewed has been issued within the past 30 days, regardless of the
- value of I(remaining_days) or the return value of I(cert_days) - the ECS API does not support the "renew" operation for certificates that are not
+ - If force is used, a certificate is requested regardless of whether O(path) points to an existing valid certificate.
+ - If O(request_type=renew), a forced renew will fail if the certificate being renewed has been issued within the past 30 days, regardless of the
+ value of O(remaining_days) or the return value of RV(cert_days) - the ECS API does not support the "renew" operation for certificates that are not
at least 30 days old.
type: bool
default: false
@@ -56,9 +56,9 @@ options:
- The destination path for the generated certificate as a PEM encoded cert.
- If the certificate at this location is not an Entrust issued certificate, a new certificate will always be requested even if the current
certificate is technically valid.
- - If there is already an Entrust certificate at this location, whether it is replaced is depends on the I(remaining_days) calculation.
- - If an existing certificate is being replaced (see I(remaining_days), I(force), and I(tracking_id)), whether a new certificate is requested
- or the existing certificate is renewed or reissued is based on I(request_type).
+ - If there is already an Entrust certificate at this location, whether it is replaced is depends on the O(remaining_days) calculation.
+ - If an existing certificate is being replaced (see O(remaining_days), O(force), and O(tracking_id)), whether a new certificate is requested
+ or the existing certificate is renewed or reissued is based on O(request_type).
type: path
required: true
full_chain_path:
@@ -67,54 +67,54 @@ options:
type: path
csr:
description:
- - Base-64 encoded Certificate Signing Request (CSR). I(csr) is accepted with or without PEM formatting around the Base-64 string.
- - If no I(csr) is provided when C(request_type=reissue) or C(request_type=renew), the certificate will be generated with the same public key as
+ - Base-64 encoded Certificate Signing Request (CSR). O(csr) is accepted with or without PEM formatting around the Base-64 string.
+ - If no O(csr) is provided when O(request_type=reissue) or O(request_type=renew), the certificate will be generated with the same public key as
the certificate being renewed or reissued.
- - If I(subject_alt_name) is specified, it will override the subject alternate names in the CSR.
- - If I(eku) is specified, it will override the extended key usage in the CSR.
- - If I(ou) is specified, it will override the organizational units "ou=" present in the subject distinguished name of the CSR, if any.
- - The organization "O=" field from the CSR will not be used. It will be replaced in the issued certificate by I(org) if present, and if not present,
- the organization tied to I(client_id).
+ - If O(subject_alt_name) is specified, it will override the subject alternate names in the CSR.
+ - If O(eku) is specified, it will override the extended key usage in the CSR.
+ - If O(ou) is specified, it will override the organizational units "ou=" present in the subject distinguished name of the CSR, if any.
+ - The organization "O=" field from the CSR will not be used. It will be replaced in the issued certificate by O(org) if present, and if not present,
+ the organization tied to O(client_id).
type: str
tracking_id:
description:
- The tracking ID of the certificate to reissue or renew.
- - I(tracking_id) is invalid if C(request_type=new) or C(request_type=validate_only).
- - If there is a certificate present in I(path) and it is an ECS certificate, I(tracking_id) will be ignored.
- - If there is no certificate present in I(path) or there is but it is from another provider, the certificate represented by I(tracking_id) will
- be renewed or reissued and saved to I(path).
- - If there is no certificate present in I(path) and the I(force) and I(remaining_days) parameters do not indicate a new certificate is needed,
- the certificate referenced by I(tracking_id) certificate will be saved to I(path).
+ - O(tracking_id) is invalid if O(request_type=new) or O(request_type=validate_only).
+ - If there is a certificate present in O(path) and it is an ECS certificate, O(tracking_id) will be ignored.
+ - If there is no certificate present in O(path) or there is but it is from another provider, the certificate represented by O(tracking_id) will
+ be renewed or reissued and saved to O(path).
+ - If there is no certificate present in O(path) and the O(force) and O(remaining_days) parameters do not indicate a new certificate is needed,
+ the certificate referenced by O(tracking_id) certificate will be saved to O(path).
- This can be used when a known certificate is not currently present on a server, but you want to renew or reissue it to be managed by an ansible
- playbook. For example, if you specify C(request_type=renew), I(tracking_id) of an issued certificate, and I(path) to a file that does not exist,
- the first run of a task will download the certificate specified by I(tracking_id) (assuming it is still valid). Future runs of the task will
- (if applicable - see I(force) and I(remaining_days)) renew the certificate now present in I(path).
+ playbook. For example, if you specify O(request_type=renew), O(tracking_id) of an issued certificate, and O(path) to a file that does not exist,
+ the first run of a task will download the certificate specified by O(tracking_id) (assuming it is still valid). Future runs of the task will
+ (if applicable - see O(force) and O(remaining_days)) renew the certificate now present in O(path).
type: int
remaining_days:
description:
- - The number of days the certificate must have left being valid. If C(cert_days < remaining_days) then a new certificate will be
- obtained using I(request_type).
- - If C(request_type=renew), a renewal will fail if the certificate being renewed has been issued within the past 30 days, so do not set a
- I(remaining_days) value that is within 30 days of the full lifetime of the certificate being acted upon.
- - For exmaple, if you are requesting Certificates with a 90 day lifetime, do not set I(remaining_days) to a value C(60) or higher).
- - The I(force) option may be used to ensure that a new certificate is always obtained.
+ - The number of days the certificate must have left being valid. If RV(cert_days) < O(remaining_days) then a new certificate will be
+ obtained using O(request_type).
+ - If O(request_type=renew), a renewal will fail if the certificate being renewed has been issued within the past 30 days, so do not set a
+ O(remaining_days) value that is within 30 days of the full lifetime of the certificate being acted upon.
+ - For example, if you are requesting Certificates with a 90 day lifetime, do not set O(remaining_days) to a value V(60) or higher).
+ - The O(force) option may be used to ensure that a new certificate is always obtained.
type: int
default: 30
request_type:
description:
- - The operation performed if I(tracking_id) references a valid certificate to reissue, or there is already a certificate present in I(path) but
- either I(force) is specified or C(cert_days < remaining_days).
- - Specifying C(request_type=validate_only) means the request will be validated against the ECS API, but no certificate will be issued.
- - Specifying C(request_type=new) means a certificate request will always be submitted and a new certificate issued.
- - Specifying C(request_type=renew) means that an existing certificate (specified by I(tracking_id) if present, otherwise I(path)) will be renewed.
+ - The operation performed if O(tracking_id) references a valid certificate to reissue, or there is already a certificate present in O(path) but
+ either O(force) is specified or RV(cert_days) < O(remaining_days).
+ - Specifying O(request_type=validate_only) means the request will be validated against the ECS API, but no certificate will be issued.
+ - Specifying O(request_type=new) means a certificate request will always be submitted and a new certificate issued.
+ - Specifying O(request_type=renew) means that an existing certificate (specified by O(tracking_id) if present, otherwise O(path)) will be renewed.
If there is no certificate to renew, a new certificate is requested.
- - Specifying C(request_type=reissue) means that an existing certificate (specified by I(tracking_id) if present, otherwise I(path)) will be
+ - Specifying O(request_type=reissue) means that an existing certificate (specified by O(tracking_id) if present, otherwise O(path)) will be
reissued.
If there is no certificate to reissue, a new certificate is requested.
- - If a certificate was issued within the past 30 days, the C(renew) operation is not a valid operation and will fail.
- - Note that C(reissue) is an operation that will result in the revocation of the certificate that is reissued, be cautious with its use.
- - I(check_mode) is only supported if C(request_type=new)
- - For example, setting C(request_type=renew) and C(remaining_days=30) and pointing to the same certificate on multiple playbook runs means that on
+ - If a certificate was issued within the past 30 days, the V(renew) operation is not a valid operation and will fail.
+ - Note that V(reissue) is an operation that will result in the revocation of the certificate that is reissued, be cautious with its use.
+ - I(check_mode) is only supported if O(request_type=new)
+ - For example, setting O(request_type=renew) and O(remaining_days=30) and pointing to the same certificate on multiple playbook runs means that on
the first run new certificate will be requested. It will then be left along on future runs until it is within 30 days of expiry, then the
ECS "renew" operation will be performed.
type: str
@@ -123,57 +123,57 @@ options:
cert_type:
description:
- Specify the type of certificate requested.
- - If a certificate is being reissued or renewed, this parameter is ignored, and the C(cert_type) of the initial certificate is used.
+ - If a certificate is being reissued or renewed, this parameter is ignored, and the O(cert_type) of the initial certificate is used.
type: str
choices: [ 'STANDARD_SSL', 'ADVANTAGE_SSL', 'UC_SSL', 'EV_SSL', 'WILDCARD_SSL', 'PRIVATE_SSL', 'PD_SSL', 'CODE_SIGNING', 'EV_CODE_SIGNING',
'CDS_INDIVIDUAL', 'CDS_GROUP', 'CDS_ENT_LITE', 'CDS_ENT_PRO', 'SMIME_ENT' ]
subject_alt_name:
description:
- - The subject alternative name identifiers, as an array of values (applies to I(cert_type) with a value of C(STANDARD_SSL), C(ADVANTAGE_SSL),
- C(UC_SSL), C(EV_SSL), C(WILDCARD_SSL), C(PRIVATE_SSL), and C(PD_SSL)).
- - If you are requesting a new SSL certificate, and you pass a I(subject_alt_name) parameter, any SAN names in the CSR are ignored.
+ - The subject alternative name identifiers, as an array of values (applies to O(cert_type) with a value of V(STANDARD_SSL), V(ADVANTAGE_SSL),
+ V(UC_SSL), V(EV_SSL), V(WILDCARD_SSL), V(PRIVATE_SSL), and V(PD_SSL)).
+ - If you are requesting a new SSL certificate, and you pass a O(subject_alt_name) parameter, any SAN names in the CSR are ignored.
If no subjectAltName parameter is passed, the SAN names in the CSR are used.
- - See I(request_type) to understand more about SANs during reissues and renewals.
- - In the case of certificates of type C(STANDARD_SSL) certificates, if the CN of the certificate is <domain>.<tld> only the www.<domain>.<tld> value
+ - See O(request_type) to understand more about SANs during reissues and renewals.
+ - In the case of certificates of type V(STANDARD_SSL) certificates, if the CN of the certificate is <domain>.<tld> only the www.<domain>.<tld> value
is accepted. If the CN of the certificate is www.<domain>.<tld> only the <domain>.<tld> value is accepted.
type: list
elements: str
eku:
description:
- - If specified, overrides the key usage in the I(csr).
+ - If specified, overrides the key usage in the O(csr).
type: str
choices: [ SERVER_AUTH, CLIENT_AUTH, SERVER_AND_CLIENT_AUTH ]
ct_log:
description:
- In compliance with browser requirements, this certificate may be posted to the Certificate Transparency (CT) logs. This is a best practice
technique that helps domain owners monitor certificates issued to their domains. Note that not all certificates are eligible for CT logging.
- - If I(ct_log) is not specified, the certificate uses the account default.
- - If I(ct_log) is specified and the account settings allow it, I(ct_log) overrides the account default.
- - If I(ct_log) is set to C(false), but the account settings are set to "always log", the certificate generation will fail.
+ - If O(ct_log) is not specified, the certificate uses the account default.
+ - If O(ct_log) is specified and the account settings allow it, O(ct_log) overrides the account default.
+ - If O(ct_log) is set to V(false), but the account settings are set to "always log", the certificate generation will fail.
type: bool
client_id:
description:
- The client ID to submit the Certificate Signing Request under.
- If no client ID is specified, the certificate will be submitted under the primary client with ID of 1.
- - When using a client other than the primary client, the I(org) parameter cannot be specified.
+ - When using a client other than the primary client, the O(org) parameter cannot be specified.
- The issued certificate will have an organization value in the subject distinguished name represented by the client.
type: int
default: 1
org:
description:
- Organization "O=" to include in the certificate.
- - If I(org) is not specified, the organization from the client represented by I(client_id) is used.
- - Unless the I(cert_type) is C(PD_SSL), this field may not be specified if the value of I(client_id) is not "1" (the primary client).
+ - If O(org) is not specified, the organization from the client represented by O(client_id) is used.
+ - Unless the O(cert_type) is V(PD_SSL), this field may not be specified if the value of O(client_id) is not "1" (the primary client).
non-primary clients, certificates may only be issued with the organization of that client.
type: str
ou:
description:
- Organizational unit "OU=" to include in the certificate.
- - I(ou) behavior is dependent on whether organizational units are enabled for your account. If organizational unit support is disabled for your
- account, organizational units from the I(csr) and the I(ou) parameter are ignored.
- - If both I(csr) and I(ou) are specified, the value in I(ou) will override the OU fields present in the subject distinguished name in the I(csr)
- - If neither I(csr) nor I(ou) are specified for a renew or reissue operation, the OU fields in the initial certificate are reused.
- - An invalid OU from I(csr) is ignored, but any invalid organizational units in I(ou) will result in an error indicating "Unapproved OU". The I(ou)
+ - O(ou) behavior is dependent on whether organizational units are enabled for your account. If organizational unit support is disabled for your
+ account, organizational units from the O(csr) and the O(ou) parameter are ignored.
+ - If both O(csr) and O(ou) are specified, the value in O(ou) will override the OU fields present in the subject distinguished name in the O(csr)
+ - If neither O(csr) nor O(ou) are specified for a renew or reissue operation, the OU fields in the initial certificate are reused.
+ - An invalid OU from O(csr) is ignored, but any invalid organizational units in O(ou) will result in an error indicating "Unapproved OU". The O(ou)
parameter can be used to force failure if an unapproved organizational unit is provided.
- A maximum of one OU may be specified for current products. Multiple OUs are reserved for future products.
type: list
@@ -181,10 +181,10 @@ options:
end_user_key_storage_agreement:
description:
- The end user of the Code Signing certificate must generate and store the private key for this request on cryptographically secure
- hardware to be compliant with the Entrust CSP and Subscription agreement. If requesting a certificate of type C(CODE_SIGNING) or
- C(EV_CODE_SIGNING), you must set I(end_user_key_storage_agreement) to true if and only if you acknowledge that you will inform the user of this
+ hardware to be compliant with the Entrust CSP and Subscription agreement. If requesting a certificate of type V(CODE_SIGNING) or
+ V(EV_CODE_SIGNING), you must set O(end_user_key_storage_agreement) to true if and only if you acknowledge that you will inform the user of this
requirement.
- - Applicable only to I(cert_type) of values C(CODE_SIGNING) and C(EV_CODE_SIGNING).
+ - Applicable only to O(cert_type) of values V(CODE_SIGNING) and V(EV_CODE_SIGNING).
type: bool
tracking_info:
description: Free form tracking information to attach to the record for the certificate.
@@ -320,29 +320,29 @@ options:
cert_expiry:
description:
- The date the certificate should be set to expire, in RFC3339 compliant date or date-time format. For example,
- C(2020-02-23), C(2020-02-23T15:00:00.05Z).
- - I(cert_expiry) is only supported for requests of C(request_type=new) or C(request_type=renew). If C(request_type=reissue),
- I(cert_expiry) will be used for the first certificate issuance, but subsequent issuances will have the same expiry as the initial
+ V(2020-02-23), V(2020-02-23T15:00:00.05Z).
+ - O(cert_expiry) is only supported for requests of O(request_type=new) or O(request_type=renew). If O(request_type=reissue),
+ O(cert_expiry) will be used for the first certificate issuance, but subsequent issuances will have the same expiry as the initial
certificate.
- A reissued certificate will always have the same expiry as the original certificate.
- Note that only the date (day, month, year) is supported for specifying the expiry date. If you choose to specify an expiry time with the expiry
date, the time will be adjusted to Eastern Standard Time (EST). This could have the unintended effect of moving your expiry date to the previous
day.
- Applies only to accounts with a pooling inventory model.
- - Only one of I(cert_expiry) or I(cert_lifetime) may be specified.
+ - Only one of O(cert_expiry) or O(cert_lifetime) may be specified.
type: str
cert_lifetime:
description:
- The lifetime of the certificate.
- Applies to all certificates for accounts with a non-pooling inventory model.
- - I(cert_lifetime) is only supported for requests of C(request_type=new) or C(request_type=renew). If C(request_type=reissue), I(cert_lifetime) will
+ - O(cert_lifetime) is only supported for requests of O(request_type=new) or O(request_type=renew). If O(request_type=reissue), O(cert_lifetime) will
be used for the first certificate issuance, but subsequent issuances will have the same expiry as the initial certificate.
- - Applies to certificates of I(cert_type)=C(CDS_INDIVIDUAL, CDS_GROUP, CDS_ENT_LITE, CDS_ENT_PRO, SMIME_ENT) for accounts with a pooling inventory
- model.
- - C(P1Y) is a certificate with a 1 year lifetime.
- - C(P2Y) is a certificate with a 2 year lifetime.
- - C(P3Y) is a certificate with a 3 year lifetime.
- - Only one of I(cert_expiry) or I(cert_lifetime) may be specified.
+ - Applies to certificates of O(cert_type=CDS_INDIVIDUAL), V(CDS_GROUP), V(CDS_ENT_LITE), V(CDS_ENT_PRO), or V(SMIME_ENT)
+ for accounts with a pooling inventory model.
+ - V(P1Y) is a certificate with a 1 year lifetime.
+ - V(P2Y) is a certificate with a 2 year lifetime.
+ - V(P3Y) is a certificate with a 3 year lifetime.
+ - Only one of O(cert_expiry) or O(cert_lifetime) may be specified.
type: str
choices: [ P1Y, P2Y, P3Y ]
seealso:
@@ -350,6 +350,8 @@ seealso:
description: Can be used to create private keys (both for certificates and accounts).
- module: community.crypto.openssl_csr
description: Can be used to create a Certificate Signing Request (CSR).
+ - plugin: community.crypto.to_serial
+ plugin_type: filter
'''
EXAMPLES = r'''
@@ -476,12 +478,12 @@ filename:
sample: /etc/ssl/crt/www.ansible.com.crt
backup_file:
description: Name of backup file created for the certificate.
- returned: changed and if I(backup) is C(true)
+ returned: changed and if O(backup) is V(true)
type: str
sample: /path/to/www.ansible.com.crt.2019-03-09@11:22~
backup_full_chain_file:
description: Name of the backup file created for the certificate chain.
- returned: changed and if I(backup) is C(true) and I(full_chain_path) is set.
+ returned: changed and if O(backup) is V(true) and O(full_chain_path) is set.
type: str
sample: /path/to/ca.chain.crt.2019-03-09@11:22~
tracking_id:
@@ -490,7 +492,10 @@ tracking_id:
type: int
sample: 380079
serial_number:
- description: The serial number of the issued certificate.
+ description:
+ - The serial number of the issued certificate.
+ - This return value is an B(integer). If you need the serial numbers as a colon-separated hex string,
+ such as C(11:22:33), you need to convert it to that form with P(community.crypto.to_serial#filter).
returned: success
type: int
sample: 1235262234164342
@@ -502,8 +507,8 @@ cert_days:
cert_status:
description:
- The certificate status in ECS.
- - 'Current possible values (which may be expanded in the future) are: C(ACTIVE), C(APPROVED), C(DEACTIVATED), C(DECLINED), C(EXPIRED), C(NA),
- C(PENDING), C(PENDING_QUORUM), C(READY), C(REISSUED), C(REISSUING), C(RENEWED), C(RENEWING), C(REVOKED), C(SUSPENDED)'
+ - 'Current possible values (which may be expanded in the future) are: V(ACTIVE), V(APPROVED), V(DEACTIVATED), V(DECLINED), V(EXPIRED), V(NA),
+ V(PENDING), V(PENDING_QUORUM), V(READY), V(REISSUED), V(REISSUING), V(RENEWED), V(RENEWING), V(REVOKED), V(SUSPENDED)'
returned: success
type: str
sample: ACTIVE
diff --git a/ansible_collections/community/crypto/plugins/modules/ecs_domain.py b/ansible_collections/community/crypto/plugins/modules/ecs_domain.py
index ec7ad98b0..0ee9380f1 100644
--- a/ansible_collections/community/crypto/plugins/modules/ecs_domain.py
+++ b/ansible_collections/community/crypto/plugins/modules/ecs_domain.py
@@ -20,19 +20,19 @@ description:
- Request validation or re-validation of a domain with the Entrust Certificate Services (ECS) API.
- Requires credentials for the L(Entrust Certificate Services,https://www.entrustdatacard.com/products/categories/ssl-certificates) (ECS) API.
- If the domain is already in the validation process, no new validation will be requested, but the validation data (if applicable) will be returned.
- - If the domain is already in the validation process but the I(verification_method) specified is different than the current I(verification_method),
- the I(verification_method) will be updated and validation data (if applicable) will be returned.
- - If the domain is an active, validated domain, the return value of I(changed) will be false, unless C(domain_status=EXPIRED), in which case a re-validation
- will be performed.
- - If C(verification_method=dns), details about the required DNS entry will be specified in the return parameters I(dns_contents), I(dns_location), and
- I(dns_resource_type).
- - If C(verification_method=web_server), details about the required file details will be specified in the return parameters I(file_contents) and
- I(file_location).
- - If C(verification_method=email), the email address(es) that the validation email(s) were sent to will be in the return parameter I(emails). This is
+ - If the domain is already in the validation process but the O(verification_method) specified is different than the current O(verification_method),
+ the O(verification_method) will be updated and validation data (if applicable) will be returned.
+ - If the domain is an active, validated domain, the return value of C(changed) will be false, unless RV(domain_status=EXPIRED), in which case a
+ re-validation will be performed.
+ - If O(verification_method=dns), details about the required DNS entry will be specified in the return parameters RV(dns_contents), RV(dns_location), and
+ RV(dns_resource_type).
+ - If O(verification_method=web_server), details about the required file details will be specified in the return parameters RV(file_contents) and
+ RV(file_location).
+ - If O(verification_method=email), the email address(es) that the validation email(s) were sent to will be in the return parameter RV(emails). This is
purely informational. For domains requested using this module, this will always be a list of size 1.
notes:
- There is a small delay (typically about 5 seconds, but can be as long as 60 seconds) before obtaining the random values when requesting a validation
- while C(verification_method=dns) or C(verification_method=web_server). Be aware of that if doing many domain validation requests.
+ while O(verification_method=dns) or O(verification_method=web_server). Be aware of that if doing many domain validation requests.
extends_documentation_fragment:
- community.crypto.attributes
- community.crypto.ecs_credential
@@ -56,35 +56,35 @@ options:
verification_method:
description:
- The verification method to be used to prove control of the domain.
- - If C(verification_method=email) and the value I(verification_email) is specified, that value is used for the email validation. If
- I(verification_email) is not provided, the first value present in WHOIS data will be used. An email will be sent to the address in
- I(verification_email) with instructions on how to verify control of the domain.
- - If C(verification_method=dns), the value I(dns_contents) must be stored in location I(dns_location), with a DNS record type of
- I(verification_dns_record_type). To prove domain ownership, update your DNS records so the text string returned by I(dns_contents) is available at
- I(dns_location).
- - If C(verification_method=web_server), the contents of return value I(file_contents) must be made available on a web server accessible at location
- I(file_location).
- - If C(verification_method=manual), the domain will be validated with a manual process. This is not recommended.
+ - If O(verification_method=email) and the value O(verification_email) is specified, that value is used for the email validation. If
+ O(verification_email) is not provided, the first value present in WHOIS data will be used. An email will be sent to the address in
+ O(verification_email) with instructions on how to verify control of the domain.
+ - If O(verification_method=dns), the value RV(dns_contents) must be stored in location RV(dns_location), with a DNS record type of
+ RV(dns_resource_type). To prove domain ownership, update your DNS records so the text string returned by RV(dns_contents) is available at
+ RV(dns_location).
+ - If O(verification_method=web_server), the contents of return value RV(file_contents) must be made available on a web server accessible at location
+ RV(file_location).
+ - If O(verification_method=manual), the domain will be validated with a manual process. This is not recommended.
type: str
choices: [ 'dns', 'email', 'manual', 'web_server']
required: true
verification_email:
description:
- Email address to be used to verify domain ownership.
- - 'Email address must be either an email address present in the WHOIS data for I(domain_name), or one of the following constructed emails:
- admin@I(domain_name), administrator@I(domain_name), webmaster@I(domain_name), hostmaster@I(domain_name), postmaster@I(domain_name).'
- - 'Note that if I(domain_name) includes subdomains, the top level domain should be used. For example, if requesting validation of
+ - 'Email address must be either an email address present in the WHOIS data for O(domain_name), or one of the following constructed emails:
+ admin@O(domain_name), administrator@O(domain_name), webmaster@O(domain_name), hostmaster@O(domain_name), postmaster@O(domain_name).'
+ - 'Note that if O(domain_name) includes subdomains, the top level domain should be used. For example, if requesting validation of
example1.ansible.com, or test.example2.ansible.com, and you want to use the "admin" preconstructed name, the email address should be
admin@ansible.com.'
- If using the email values from the WHOIS data for the domain or its top level namespace, they must be exact matches.
- - If C(verification_method=email) but I(verification_email) is not provided, the first email address found in WHOIS data for the domain will be
+ - If O(verification_method=email) but O(verification_email) is not provided, the first email address found in WHOIS data for the domain will be
used.
- To verify domain ownership, domain owner must follow the instructions in the email they receive.
- - Only allowed if C(verification_method=email)
+ - Only allowed if O(verification_method=email)
type: str
seealso:
- module: community.crypto.x509_certificate
- description: Can be used to request certificates from ECS, with C(provider=entrust).
+ description: Can be used to request certificates from ECS, with O(community.crypto.x509_certificate#module:provider=entrust).
- module: community.crypto.ecs_certificate
description: Can be used to request a Certificate from ECS using a verified domain.
'''
@@ -133,72 +133,72 @@ EXAMPLES = r'''
RETURN = '''
domain_status:
- description: Status of the current domain. Will be one of C(APPROVED), C(DECLINED), C(CANCELLED), C(INITIAL_VERIFICATION), C(DECLINED), C(CANCELLED),
- C(RE_VERIFICATION), C(EXPIRED), C(EXPIRING)
+ description: Status of the current domain. Will be one of V(APPROVED), V(DECLINED), V(CANCELLED), V(INITIAL_VERIFICATION), V(DECLINED), V(CANCELLED),
+ V(RE_VERIFICATION), V(EXPIRED), V(EXPIRING)
returned: changed or success
type: str
sample: APPROVED
verification_method:
- description: Verification method used to request the domain validation. If C(changed) will be the same as I(verification_method) input parameter.
+ description: Verification method used to request the domain validation. If C(changed) will be the same as O(verification_method) input parameter.
returned: changed or success
type: str
sample: dns
file_location:
- description: The location that ECS will be expecting to be able to find the file for domain verification, containing the contents of I(file_contents).
- returned: I(verification_method) is C(web_server)
+ description: The location that ECS will be expecting to be able to find the file for domain verification, containing the contents of RV(file_contents).
+ returned: O(verification_method) is V(web_server)
type: str
sample: http://ansible.com/.well-known/pki-validation/abcd.txt
file_contents:
- description: The contents of the file that ECS will be expecting to find at C(file_location).
- returned: I(verification_method) is C(web_server)
+ description: The contents of the file that ECS will be expecting to find at RV(file_location).
+ returned: O(verification_method) is V(web_server)
type: str
sample: AB23CD41432522FF2526920393982FAB
emails:
description:
- The list of emails used to request validation of this domain.
- Domains requested using this module will only have a list of size 1.
- returned: I(verification_method) is C(email)
+ returned: O(verification_method) is V(email)
type: list
sample: [ admin@ansible.com, administrator@ansible.com ]
dns_location:
- description: The location that ECS will be expecting to be able to find the DNS entry for domain verification, containing the contents of I(dns_contents).
- returned: changed and if I(verification_method) is C(dns)
+ description: The location that ECS will be expecting to be able to find the DNS entry for domain verification, containing the contents of RV(dns_contents).
+ returned: changed and if O(verification_method) is V(dns)
type: str
sample: _pki-validation.ansible.com
dns_contents:
- description: The value that ECS will be expecting to find in the DNS record located at I(dns_location).
- returned: changed and if I(verification_method) is C(dns)
+ description: The value that ECS will be expecting to find in the DNS record located at RV(dns_location).
+ returned: changed and if O(verification_method) is V(dns)
type: str
sample: AB23CD41432522FF2526920393982FAB
dns_resource_type:
- description: The type of resource record that ECS will be expecting for the DNS record located at I(dns_location).
- returned: changed and if I(verification_method) is C(dns)
+ description: The type of resource record that ECS will be expecting for the DNS record located at RV(dns_location).
+ returned: changed and if O(verification_method) is V(dns)
type: str
sample: TXT
client_id:
- description: Client ID that the domain belongs to. If the input value I(client_id) is specified, this will always be the same as I(client_id)
+ description: Client ID that the domain belongs to. If the input value O(client_id) is specified, this will always be the same as O(client_id)
returned: changed or success
type: int
sample: 1
ov_eligible:
- description: Whether the domain is eligible for submission of "OV" certificates. Will never be C(false) if I(ov_eligible) is C(true)
- returned: success and I(domain_status) is C(APPROVED), C(RE_VERIFICATION), C(EXPIRING), or C(EXPIRED).
+ description: Whether the domain is eligible for submission of "OV" certificates. Will never be V(false) if RV(ev_eligible) is V(true)
+ returned: success and RV(domain_status) is V(APPROVED), V(RE_VERIFICATION), V(EXPIRING), or V(EXPIRED).
type: bool
sample: true
ov_days_remaining:
- description: The number of days the domain remains eligible for submission of "OV" certificates. Will never be less than the value of I(ev_days_remaining)
- returned: success and I(ov_eligible) is C(true) and I(domain_status) is C(APPROVED), C(RE_VERIFICATION) or C(EXPIRING).
+ description: The number of days the domain remains eligible for submission of "OV" certificates. Will never be less than the value of RV(ev_days_remaining)
+ returned: success and RV(ov_eligible) is V(true) and RV(domain_status) is V(APPROVED), V(RE_VERIFICATION) or V(EXPIRING).
type: int
sample: 129
ev_eligible:
- description: Whether the domain is eligible for submission of "EV" certificates. Will never be C(true) if I(ov_eligible) is C(false)
- returned: success and I(domain_status) is C(APPROVED), C(RE_VERIFICATION) or C(EXPIRING), or C(EXPIRED).
+ description: Whether the domain is eligible for submission of "EV" certificates. Will never be V(true) if RV(ov_eligible) is V(false)
+ returned: success and RV(domain_status) is V(APPROVED), V(RE_VERIFICATION) or V(EXPIRING), or V(EXPIRED).
type: bool
sample: true
ev_days_remaining:
description: The number of days the domain remains eligible for submission of "EV" certificates. Will never be greater than the value of
- I(ov_days_remaining)
- returned: success and I(ev_eligible) is C(true) and I(domain_status) is C(APPROVED), C(RE_VERIFICATION) or C(EXPIRING).
+ RV(ov_days_remaining)
+ returned: success and RV(ev_eligible) is V(true) and RV(domain_status) is V(APPROVED), V(RE_VERIFICATION) or V(EXPIRING).
type: int
sample: 94
diff --git a/ansible_collections/community/crypto/plugins/modules/get_certificate.py b/ansible_collections/community/crypto/plugins/modules/get_certificate.py
index 4b2eeaed8..0f8abc90a 100644
--- a/ansible_collections/community/crypto/plugins/modules/get_certificate.py
+++ b/ansible_collections/community/crypto/plugins/modules/get_certificate.py
@@ -63,7 +63,7 @@ options:
starttls:
description:
- Requests a secure connection for protocols which require clients to initiate encryption.
- - Only available for C(mysql) currently.
+ - Only available for V(mysql) currently.
type: str
choices:
- mysql
@@ -76,15 +76,15 @@ options:
select_crypto_backend:
description:
- Determines which crypto backend to use.
- - The default choice is C(auto), which tries to use C(cryptography) if available.
- - If set to C(cryptography), will try to use the L(cryptography,https://cryptography.io/) library.
+ - The default choice is V(auto), which tries to use C(cryptography) if available.
+ - If set to V(cryptography), will try to use the L(cryptography,https://cryptography.io/) library.
type: str
default: auto
choices: [ auto, cryptography ]
ciphers:
description:
- SSL/TLS Ciphers to use for the request.
- - 'When a list is provided, all ciphers are joined in order with C(:).'
+ - 'When a list is provided, all ciphers are joined in order with V(:).'
- See the L(OpenSSL Cipher List Format,https://www.openssl.org/docs/manmaster/man1/openssl-ciphers.html#CIPHER-LIST-FORMAT)
for more details.
- The available ciphers is dependent on the Python and OpenSSL/LibreSSL versions.
@@ -93,20 +93,23 @@ options:
version_added: 2.11.0
asn1_base64:
description:
- - Whether to encode the ASN.1 values in the C(extensions) return value with Base64 or not.
+ - Whether to encode the ASN.1 values in the RV(extensions) return value with Base64 or not.
- The documentation claimed for a long time that the values are Base64 encoded, but they
- never were. For compatibility this option is set to C(false), but that value will eventually
- be deprecated and changed to C(true).
+ never were. For compatibility this option is set to V(false).
+ - The default value V(false) is B(deprecated) and will change to V(true) in community.crypto 3.0.0.
type: bool
- default: false
version_added: 2.12.0
notes:
- When using ca_cert on OS X it has been reported that in some conditions the validate will always succeed.
requirements:
- - "python >= 2.7 when using C(proxy_host)"
+ - "python >= 2.7 when using O(proxy_host)"
- "cryptography >= 1.6"
+
+seealso:
+ - plugin: community.crypto.to_serial
+ plugin_type: filter
'''
RETURN = '''
@@ -133,7 +136,7 @@ extensions:
type: str
description:
- The ASN.1 content of the extension.
- - If I(asn1_base64=true) this will be Base64 encoded, otherwise the raw
+ - If O(asn1_base64=true) this will be Base64 encoded, otherwise the raw
binary value will be returned.
- Please note that the raw binary value might not survive JSON serialization
to the Ansible controller, and also might cause failures when displaying it.
@@ -148,31 +151,34 @@ extensions:
type: str
description: The extension's name.
issuer:
- description: Information about the issuer of the cert
+ description: Information about the issuer of the cert.
returned: success
type: dict
not_after:
- description: Expiration date of the cert
+ description: Expiration date of the cert.
returned: success
type: str
not_before:
- description: Issue date of the cert
+ description: Issue date of the cert.
returned: success
type: str
serial_number:
- description: The serial number of the cert
+ description:
+ - The serial number of the cert.
+ - This return value is an B(integer). If you need the serial numbers as a colon-separated hex string,
+ such as C(11:22:33), you need to convert it to that form with P(community.crypto.to_serial#filter).
returned: success
- type: str
+ type: int
signature_algorithm:
- description: The algorithm used to sign the cert
+ description: The algorithm used to sign the cert.
returned: success
type: str
subject:
- description: Information about the subject of the cert (OU, CN, etc)
+ description: Information about the subject of the cert (C(OU), C(CN), etc).
returned: success
type: dict
version:
- description: The version number of the certificate
+ description: The version number of the certificate.
returned: success
type: str
'''
@@ -272,7 +278,7 @@ def main():
select_crypto_backend=dict(type='str', choices=['auto', 'cryptography'], default='auto'),
starttls=dict(type='str', choices=['mysql']),
ciphers=dict(type='list', elements='str'),
- asn1_base64=dict(type='bool', default=False),
+ asn1_base64=dict(type='bool'),
),
)
@@ -286,6 +292,15 @@ def main():
start_tls_server_type = module.params.get('starttls')
ciphers = module.params.get('ciphers')
asn1_base64 = module.params['asn1_base64']
+ if asn1_base64 is None:
+ module.deprecate(
+ 'The default value `false` for asn1_base64 is deprecated and will change to `true` in '
+ 'community.crypto 3.0.0. If you need this value, it is best to set the value explicitly '
+ 'and adjust your roles/playbooks to use `asn1_base64=true` as soon as possible',
+ version='3.0.0',
+ collection_name='community.crypto',
+ )
+ asn1_base64 = False
backend = module.params.get('select_crypto_backend')
if backend == 'auto':
diff --git a/ansible_collections/community/crypto/plugins/modules/luks_device.py b/ansible_collections/community/crypto/plugins/modules/luks_device.py
index d8b70e748..5c41eddd3 100644
--- a/ansible_collections/community/crypto/plugins/modules/luks_device.py
+++ b/ansible_collections/community/crypto/plugins/modules/luks_device.py
@@ -30,55 +30,66 @@ attributes:
options:
device:
description:
- - "Device to work with (for example C(/dev/sda1)). Needed in most cases.
- Can be omitted only when I(state=closed) together with I(name)
+ - "Device to work with (for example V(/dev/sda1)). Needed in most cases.
+ Can be omitted only when O(state=closed) together with O(name)
is provided."
type: str
state:
description:
- "Desired state of the LUKS container. Based on its value creates,
destroys, opens or closes the LUKS container on a given device."
- - "I(present) will create LUKS container unless already present.
- Requires I(device) and either I(keyfile) or I(passphrase) options
+ - "V(present) will create LUKS container unless already present.
+ Requires O(device) and either O(keyfile) or O(passphrase) options
to be provided."
- - "I(absent) will remove existing LUKS container if it exists.
- Requires I(device) or I(name) to be specified."
- - "I(opened) will unlock the LUKS container. If it does not exist
+ - "V(absent) will remove existing LUKS container if it exists.
+ Requires O(device) or O(name) to be specified."
+ - "V(opened) will unlock the LUKS container. If it does not exist
it will be created first.
- Requires I(device) and either I(keyfile) or I(passphrase)
- to be specified. Use the I(name) option to set the name of
+ Requires O(device) and either O(keyfile) or O(passphrase)
+ to be specified. Use the O(name) option to set the name of
the opened container. Otherwise the name will be
generated automatically and returned as a part of the
result."
- - "I(closed) will lock the LUKS container. However if the container
+ - "V(closed) will lock the LUKS container. However if the container
does not exist it will be created.
- Requires I(device) and either I(keyfile) or I(passphrase)
+ Requires O(device) and either O(keyfile) or O(passphrase)
options to be provided. If container does already exist
- I(device) or I(name) will suffice."
+ O(device) or O(name) will suffice."
type: str
default: present
choices: [present, absent, opened, closed]
name:
description:
- - "Sets container name when I(state=opened). Can be used
- instead of I(device) when closing the existing container
- (that is, when I(state=closed))."
+ - "Sets container name when O(state=opened). Can be used
+ instead of O(device) when closing the existing container
+ (that is, when O(state=closed))."
type: str
keyfile:
description:
- - "Used to unlock the container. Either a I(keyfile) or a
- I(passphrase) is needed for most of the operations. Parameter
+ - "Used to unlock the container. Either a O(keyfile) or a
+ O(passphrase) is needed for most of the operations. Parameter
value is the path to the keyfile with the passphrase."
- "BEWARE that working with keyfiles in plaintext is dangerous.
Make sure that they are protected."
type: path
passphrase:
description:
- - "Used to unlock the container. Either a I(passphrase) or a
- I(keyfile) is needed for most of the operations. Parameter
+ - "Used to unlock the container. Either a O(passphrase) or a
+ O(keyfile) is needed for most of the operations. Parameter
value is a string with the passphrase."
type: str
version_added: '1.0.0'
+ keyslot:
+ description:
+ - "Adds the O(keyfile) or O(passphrase) to a specific keyslot when
+ creating a new container on O(device). Parameter value is the
+ number of the keyslot."
+ - "B(Note) that a device of O(type=luks1) supports the keyslot numbers
+ V(0)-V(7) and a device of O(type=luks2) supports the keyslot numbers
+ V(0)-V(31). In order to use the keyslots V(8)-V(31) when creating a new
+ container, setting O(type) to V(luks2) is required."
+ type: int
+ version_added: '2.16.0'
keysize:
description:
- "Sets the key size only if LUKS container does not exist."
@@ -86,8 +97,8 @@ options:
version_added: '1.0.0'
new_keyfile:
description:
- - "Adds additional key to given container on I(device).
- Needs I(keyfile) or I(passphrase) option for authorization.
+ - "Adds additional key to given container on O(device).
+ Needs O(keyfile) or O(passphrase) option for authorization.
LUKS container supports up to 8 keyslots. Parameter value
is the path to the keyfile with the passphrase."
- "NOTE that adding additional keys is idempotent only since
@@ -99,8 +110,8 @@ options:
type: path
new_passphrase:
description:
- - "Adds additional passphrase to given container on I(device).
- Needs I(keyfile) or I(passphrase) option for authorization. LUKS
+ - "Adds additional passphrase to given container on O(device).
+ Needs O(keyfile) or O(passphrase) option for authorization. LUKS
container supports up to 8 keyslots. Parameter value is a string
with the new passphrase."
- "NOTE that adding additional passphrase is idempotent only since
@@ -108,34 +119,55 @@ options:
be used even if another keyslot already exists for this passphrase."
type: str
version_added: '1.0.0'
+ new_keyslot:
+ description:
+ - "Adds the additional O(new_keyfile) or O(new_passphrase) to a
+ specific keyslot on the given O(device). Parameter value is the number
+ of the keyslot."
+ - "B(Note) that a device of O(type=luks1) supports the keyslot numbers
+ V(0)-V(7) and a device of O(type=luks2) supports the keyslot numbers
+ V(0)-V(31)."
+ type: int
+ version_added: '2.16.0'
remove_keyfile:
description:
- - "Removes given key from the container on I(device). Does not
+ - "Removes given key from the container on O(device). Does not
remove the keyfile from filesystem.
Parameter value is the path to the keyfile with the passphrase."
- "NOTE that removing keys is idempotent only since
community.crypto 1.4.0. For older versions, trying to remove
a key which no longer exists results in an error."
- "NOTE that to remove the last key from a LUKS container, the
- I(force_remove_last_key) option must be set to C(true)."
+ O(force_remove_last_key) option must be set to V(true)."
- "BEWARE that working with keyfiles in plaintext is dangerous.
Make sure that they are protected."
type: path
remove_passphrase:
description:
- - "Removes given passphrase from the container on I(device).
+ - "Removes given passphrase from the container on O(device).
Parameter value is a string with the passphrase to remove."
- "NOTE that removing passphrases is idempotent only since
community.crypto 1.4.0. For older versions, trying to remove
a passphrase which no longer exists results in an error."
- "NOTE that to remove the last keyslot from a LUKS
- container, the I(force_remove_last_key) option must be set
- to C(true)."
+ container, the O(force_remove_last_key) option must be set
+ to V(true)."
type: str
version_added: '1.0.0'
+ remove_keyslot:
+ description:
+ - "Removes the key in the given slot on O(device). Needs
+ O(keyfile) or O(passphrase) for authorization."
+ - "B(Note) that a device of O(type=luks1) supports the keyslot numbers
+ V(0)-V(7) and a device of O(type=luks2) supports the keyslot numbers
+ V(0)-V(31)."
+ - "B(Note) that the given O(keyfile) or O(passphrase) must not be
+ in the slot to be removed."
+ type: int
+ version_added: '2.16.0'
force_remove_last_key:
description:
- - "If set to C(true), allows removing the last key from a container."
+ - "If set to V(true), allows removing the last key from a container."
- "BEWARE that when the last key has been removed from a container,
the container can no longer be opened!"
type: bool
@@ -145,21 +177,21 @@ options:
- "This option allow the user to create a LUKS2 format container
with label support, respectively to identify the container by
label on later usages."
- - "Will only be used on container creation, or when I(device) is
+ - "Will only be used on container creation, or when O(device) is
not specified."
- - "This cannot be specified if I(type) is set to C(luks1)."
+ - "This cannot be specified if O(type) is set to V(luks1)."
type: str
version_added: '1.0.0'
uuid:
description:
- "With this option user can identify the LUKS container by UUID."
- - "Will only be used when I(device) and I(label) are not specified."
+ - "Will only be used when O(device) and O(label) are not specified."
type: str
version_added: '1.0.0'
type:
description:
- "This option allow the user explicit define the format of LUKS
- container that wants to work with. Options are C(luks1) or C(luks2)"
+ container that wants to work with. Options are V(luks1) or V(luks2)"
type: str
choices: [luks1, luks2]
version_added: '1.0.0'
@@ -168,8 +200,8 @@ options:
- "This option allows the user to define the cipher specification
string for the LUKS container."
- "Will only be used on container creation."
- - "For pre-2.6.10 kernels, use C(aes-plain) as they do not understand
- the new cipher spec strings. To use ESSIV, use C(aes-cbc-essiv:sha256)."
+ - "For pre-2.6.10 kernels, use V(aes-plain) as they do not understand
+ the new cipher spec strings. To use ESSIV, use V(aes-cbc-essiv:sha256)."
type: str
version_added: '1.1.0'
hash:
@@ -193,12 +225,12 @@ options:
- Specify the iteration time used for the PBKDF.
- Note that this is in B(seconds), not in milliseconds as on the
command line.
- - Mutually exclusive with I(iteration_count).
+ - Mutually exclusive with O(pbkdf.iteration_count).
type: float
iteration_count:
description:
- Specify the iteration count used for the PBKDF.
- - Mutually exclusive with I(iteration_time).
+ - Mutually exclusive with O(pbkdf.iteration_time).
type: int
algorithm:
description:
@@ -261,19 +293,26 @@ options:
persistent:
description:
- "Allows the user to store options into container's metadata persistently and automatically use them next time.
- Only I(perf_same_cpu_crypt), I(perf_submit_from_crypt_cpus), I(perf_no_read_workqueue), and I(perf_no_write_workqueue)
- can be stored persistently."
+ Only O(perf_same_cpu_crypt), O(perf_submit_from_crypt_cpus), O(perf_no_read_workqueue), O(perf_no_write_workqueue),
+ and O(allow_discards) can be stored persistently."
- "Will only work with LUKS2 containers."
- "Will only be used when opening containers."
type: bool
default: false
version_added: '2.3.0'
+ allow_discards:
+ description:
+ - "Allow discards (also known as TRIM) requests for device."
+ - "Will only be used when opening containers."
+ type: bool
+ default: false
+ version_added: '2.17.0'
requirements:
- "cryptsetup"
- - "wipefs (when I(state) is C(absent))"
+ - "wipefs (when O(state) is V(absent))"
- "lsblk"
- - "blkid (when I(label) or I(uuid) options are used)"
+ - "blkid (when O(label) or O(uuid) options are used)"
author: Jan Pokorny (@japokorn)
'''
@@ -377,12 +416,32 @@ EXAMPLES = '''
state: "present"
keyfile: "/vault/keyfile"
type: luks2
+
+- name: Create a container with key in slot 4
+ community.crypto.luks_device:
+ device: "/dev/loop0"
+ state: "present"
+ keyfile: "/vault/keyfile"
+ keyslot: 4
+
+- name: Add a new key in slot 5
+ community.crypto.luks_device:
+ device: "/dev/loop0"
+ keyfile: "/vault/keyfile"
+ new_keyfile: "/vault/keyfile"
+ new_keyslot: 5
+
+- name: Remove the key from slot 4 (given keyfile must not be slot 4)
+ community.crypto.luks_device:
+ device: "/dev/loop0"
+ keyfile: "/vault/keyfile"
+ remove_keyslot: 4
'''
RETURN = '''
name:
description:
- When I(state=opened) returns (generated or given) name
+ When O(state=opened) returns (generated or given) name
of LUKS container. Returns None if no name is supplied.
returned: success
type: str
@@ -523,6 +582,29 @@ class CryptHandler(Handler):
result = self._run_command([self._cryptsetup_bin, 'isLuks', device])
return result[RETURN_CODE] == 0
+ def get_luks_type(self, device):
+ ''' get the luks type of a device
+ '''
+ if self.is_luks(device):
+ with open(device, 'rb') as f:
+ for offset in LUKS2_HEADER_OFFSETS:
+ f.seek(offset)
+ data = f.read(LUKS_HEADER_L)
+ if data == LUKS2_HEADER2:
+ return 'luks2'
+ return 'luks1'
+ return None
+
+ def is_luks_slot_set(self, device, keyslot):
+ ''' check if a keyslot is set
+ '''
+ result = self._run_command([self._cryptsetup_bin, 'luksDump', device])
+ if result[RETURN_CODE] != 0:
+ raise ValueError('Error while dumping LUKS header from %s' % (device, ))
+ result_luks1 = 'Key Slot %d: ENABLED' % (keyslot) in result[STDOUT]
+ result_luks2 = ' %d: luks2' % (keyslot) in result[STDOUT]
+ return result_luks1 or result_luks2
+
def _add_pbkdf_options(self, options, pbkdf):
if pbkdf['iteration_time'] is not None:
options.extend(['--iter-time', str(int(pbkdf['iteration_time'] * 1000))])
@@ -535,7 +617,7 @@ class CryptHandler(Handler):
if pbkdf['parallel'] is not None:
options.extend(['--pbkdf-parallel', str(pbkdf['parallel'])])
- def run_luks_create(self, device, keyfile, passphrase, keysize, cipher, hash_, sector_size, pbkdf):
+ def run_luks_create(self, device, keyfile, passphrase, keyslot, keysize, cipher, hash_, sector_size, pbkdf):
# create a new luks container; use batch mode to auto confirm
luks_type = self._module.params['type']
label = self._module.params['label']
@@ -556,6 +638,8 @@ class CryptHandler(Handler):
self._add_pbkdf_options(options, pbkdf)
if sector_size is not None:
options.extend(['--sector-size', str(sector_size)])
+ if keyslot is not None:
+ options.extend(['--key-slot', str(keyslot)])
args = [self._cryptsetup_bin, 'luksFormat']
args.extend(options)
@@ -569,7 +653,7 @@ class CryptHandler(Handler):
% (device, result[STDERR]))
def run_luks_open(self, device, keyfile, passphrase, perf_same_cpu_crypt, perf_submit_from_crypt_cpus,
- perf_no_read_workqueue, perf_no_write_workqueue, persistent, name):
+ perf_no_read_workqueue, perf_no_write_workqueue, persistent, allow_discards, name):
args = [self._cryptsetup_bin]
if keyfile:
args.extend(['--key-file', keyfile])
@@ -583,6 +667,8 @@ class CryptHandler(Handler):
args.extend(['--perf-no_write_workqueue'])
if persistent:
args.extend(['--persistent'])
+ if allow_discards:
+ args.extend(['--allow-discards'])
args.extend(['open', '--type', 'luks', device, name])
result = self._run_command(args, data=passphrase)
@@ -615,7 +701,7 @@ class CryptHandler(Handler):
raise ValueError('Error while wiping LUKS container signatures for %s: %s' % (device, exc))
def run_luks_add_key(self, device, keyfile, passphrase, new_keyfile,
- new_passphrase, pbkdf):
+ new_passphrase, new_keyslot, pbkdf):
''' Add new key from a keyfile or passphrase to given 'device';
authentication done using 'keyfile' or 'passphrase'.
Raises ValueError when command fails.
@@ -625,6 +711,9 @@ class CryptHandler(Handler):
if pbkdf is not None:
self._add_pbkdf_options(args, pbkdf)
+ if new_keyslot is not None:
+ args.extend(['--key-slot', str(new_keyslot)])
+
if keyfile:
args.extend(['--key-file', keyfile])
else:
@@ -640,7 +729,7 @@ class CryptHandler(Handler):
raise ValueError('Error while adding new LUKS keyslot to %s: %s'
% (device, result[STDERR]))
- def run_luks_remove_key(self, device, keyfile, passphrase,
+ def run_luks_remove_key(self, device, keyfile, passphrase, keyslot,
force_remove_last_key=False):
''' Remove key from given device
Raises ValueError when command fails
@@ -675,7 +764,10 @@ class CryptHandler(Handler):
"To be able to remove a key, please set "
"`force_remove_last_key` to `true`." % device)
- args = [self._cryptsetup_bin, 'luksRemoveKey', device, '-q']
+ if keyslot is None:
+ args = [self._cryptsetup_bin, 'luksRemoveKey', device, '-q']
+ else:
+ args = [self._cryptsetup_bin, 'luksKillSlot', device, '-q', str(keyslot)]
if keyfile:
args.extend(['--key-file', keyfile])
result = self._run_command(args, data=passphrase)
@@ -683,7 +775,7 @@ class CryptHandler(Handler):
raise ValueError('Error while removing LUKS key from %s: %s'
% (device, result[STDERR]))
- def luks_test_key(self, device, keyfile, passphrase):
+ def luks_test_key(self, device, keyfile, passphrase, keyslot=None):
''' Check whether the keyfile or passphrase works.
Raises ValueError when command fails.
'''
@@ -695,12 +787,22 @@ class CryptHandler(Handler):
else:
data = passphrase
+ if keyslot is not None:
+ args.extend(['--key-slot', str(keyslot)])
+
result = self._run_command(args, data=data)
if result[RETURN_CODE] == 0:
return True
for output in (STDOUT, STDERR):
if 'No key available with this passphrase' in result[output]:
return False
+ if 'No usable keyslot is available.' in result[output]:
+ return False
+
+ # This check is necessary due to cryptsetup in version 2.0.3 not printing 'No usable keyslot is available'
+ # when using the --key-slot parameter in combination with --test-passphrase
+ if result[RETURN_CODE] == 1 and keyslot is not None and result[STDOUT] == '' and result[STDERR] == '':
+ return False
raise ValueError('Error while testing whether keyslot exists on %s: %s'
% (device, result[STDERR]))
@@ -812,12 +914,20 @@ class ConditionsHandler(Handler):
self._module.fail_json(msg="Contradiction in setup: Asking to "
"add a key to absent LUKS.")
- return not self._crypthandler.luks_test_key(self.device, self._module.params['new_keyfile'], self._module.params['new_passphrase'])
+ key_present = self._crypthandler.luks_test_key(self.device, self._module.params['new_keyfile'], self._module.params['new_passphrase'])
+ if self._module.params['new_keyslot'] is not None:
+ key_present_slot = self._crypthandler.luks_test_key(self.device, self._module.params['new_keyfile'], self._module.params['new_passphrase'],
+ self._module.params['new_keyslot'])
+ if key_present and not key_present_slot:
+ self._module.fail_json(msg="Trying to add key that is already present in another slot")
+
+ return not key_present
def luks_remove_key(self):
if (self.device is None or
(self._module.params['remove_keyfile'] is None and
- self._module.params['remove_passphrase'] is None)):
+ self._module.params['remove_passphrase'] is None and
+ self._module.params['remove_keyslot'] is None)):
# conditions for removing a key not fulfilled
return False
@@ -825,6 +935,15 @@ class ConditionsHandler(Handler):
self._module.fail_json(msg="Contradiction in setup: Asking to "
"remove a key from absent LUKS.")
+ if self._module.params['remove_keyslot'] is not None:
+ if not self._crypthandler.is_luks_slot_set(self.device, self._module.params['remove_keyslot']):
+ return False
+ result = self._crypthandler.luks_test_key(self.device, self._module.params['keyfile'], self._module.params['passphrase'])
+ if self._crypthandler.luks_test_key(self.device, self._module.params['keyfile'], self._module.params['passphrase'],
+ self._module.params['remove_keyslot']):
+ self._module.fail_json(msg='Cannot remove keyslot with keyfile or passphrase in same slot.')
+ return result
+
return self._crypthandler.luks_test_key(self.device, self._module.params['remove_keyfile'], self._module.params['remove_passphrase'])
def luks_remove(self):
@@ -832,6 +951,19 @@ class ConditionsHandler(Handler):
self._module.params['state'] == 'absent' and
self._crypthandler.is_luks(self.device))
+ def validate_keyslot(self, param, luks_type):
+ if self._module.params[param] is not None:
+ if luks_type is None and param == 'keyslot':
+ if 8 <= self._module.params[param] <= 31:
+ self._module.fail_json(msg="You must specify type=luks2 when creating a new LUKS device to use keyslots 8-31.")
+ elif not (0 <= self._module.params[param] <= 7):
+ self._module.fail_json(msg="When not specifying a type, only the keyslots 0-7 are allowed.")
+
+ if luks_type == 'luks1' and not 0 <= self._module.params[param] <= 7:
+ self._module.fail_json(msg="%s must be between 0 and 7 when using LUKS1." % self._module.params[param])
+ elif luks_type == 'luks2' and not 0 <= self._module.params[param] <= 31:
+ self._module.fail_json(msg="%s must be between 0 and 31 when using LUKS2." % self._module.params[param])
+
def run_module():
# available arguments/parameters that a user can pass
@@ -845,6 +977,9 @@ def run_module():
passphrase=dict(type='str', no_log=True),
new_passphrase=dict(type='str', no_log=True),
remove_passphrase=dict(type='str', no_log=True),
+ keyslot=dict(type='int', no_log=False),
+ new_keyslot=dict(type='int', no_log=False),
+ remove_keyslot=dict(type='int', no_log=False),
force_remove_last_key=dict(type='bool', default=False),
keysize=dict(type='int'),
label=dict(type='str'),
@@ -869,12 +1004,13 @@ def run_module():
perf_no_read_workqueue=dict(type='bool', default=False),
perf_no_write_workqueue=dict(type='bool', default=False),
persistent=dict(type='bool', default=False),
+ allow_discards=dict(type='bool', default=False),
)
mutually_exclusive = [
('keyfile', 'passphrase'),
('new_keyfile', 'new_passphrase'),
- ('remove_keyfile', 'remove_passphrase')
+ ('remove_keyfile', 'remove_passphrase', 'remove_keyslot')
]
# seed the result dict in the object
@@ -904,6 +1040,17 @@ def run_module():
if module.params['label'] is not None and module.params['type'] == 'luks1':
module.fail_json(msg='You cannot combine type luks1 with the label option.')
+ if module.params['keyslot'] is not None or module.params['new_keyslot'] is not None or module.params['remove_keyslot'] is not None:
+ luks_type = crypt.get_luks_type(conditions.get_device_name())
+ if luks_type is None and module.params['type'] is not None:
+ luks_type = module.params['type']
+ for param in ['keyslot', 'new_keyslot', 'remove_keyslot']:
+ conditions.validate_keyslot(param, luks_type)
+
+ for param in ['new_keyslot', 'remove_keyslot']:
+ if module.params[param] is not None and module.params['keyfile'] is None and module.params['passphrase'] is None:
+ module.fail_json(msg="Removing a keyslot requires the passphrase or keyfile of another slot.")
+
# The conditions are in order to allow more operations in one run.
# (e.g. create luks and add a key to it)
@@ -914,6 +1061,7 @@ def run_module():
crypt.run_luks_create(conditions.device,
module.params['keyfile'],
module.params['passphrase'],
+ module.params['keyslot'],
module.params['keysize'],
module.params['cipher'],
module.params['hash'],
@@ -949,6 +1097,7 @@ def run_module():
module.params['perf_no_read_workqueue'],
module.params['perf_no_write_workqueue'],
module.params['persistent'],
+ module.params['allow_discards'],
name)
except ValueError as e:
module.fail_json(msg="luks_device error: %s" % e)
@@ -986,6 +1135,7 @@ def run_module():
module.params['passphrase'],
module.params['new_keyfile'],
module.params['new_passphrase'],
+ module.params['new_keyslot'],
module.params['pbkdf'])
except ValueError as e:
module.fail_json(msg="luks_device error: %s" % e)
@@ -1001,6 +1151,7 @@ def run_module():
crypt.run_luks_remove_key(conditions.device,
module.params['remove_keyfile'],
module.params['remove_passphrase'],
+ module.params['remove_keyslot'],
force_remove_last_key=last_key)
except ValueError as e:
module.fail_json(msg="luks_device error: %s" % e)
diff --git a/ansible_collections/community/crypto/plugins/modules/openssh_cert.py b/ansible_collections/community/crypto/plugins/modules/openssh_cert.py
index 8f428107a..8e864cd7d 100644
--- a/ansible_collections/community/crypto/plugins/modules/openssh_cert.py
+++ b/ansible_collections/community/crypto/plugins/modules/openssh_cert.py
@@ -40,13 +40,13 @@ options:
type:
description:
- Whether the module should generate a host or a user certificate.
- - Required if I(state) is C(present).
+ - Required if O(state) is V(present).
type: str
choices: ['host', 'user']
force:
description:
- Should the certificate be regenerated even if it already exists and is valid.
- - Equivalent to I(regenerate=always).
+ - Equivalent to O(regenerate=always).
type: bool
default: false
path:
@@ -56,16 +56,16 @@ options:
required: true
regenerate:
description:
- - When C(never) the task will fail if a certificate already exists at I(path) and is unreadable
+ - When V(never) the task will fail if a certificate already exists at O(path) and is unreadable
otherwise a new certificate will only be generated if there is no existing certificate.
- - When C(fail) the task will fail if a certificate already exists at I(path) and does not
+ - When V(fail) the task will fail if a certificate already exists at O(path) and does not
match the module's options.
- - When C(partial_idempotence) an existing certificate will be regenerated based on
- I(serial), I(signature_algorithm), I(type), I(valid_from), I(valid_to), I(valid_at), and I(principals).
- I(valid_from) and I(valid_to) can be excluded by I(ignore_timestamps=true).
- - When C(full_idempotence) I(identifier), I(options), I(public_key), and I(signing_key)
+ - When V(partial_idempotence) an existing certificate will be regenerated based on
+ O(serial_number), O(signature_algorithm), O(type), O(valid_from), O(valid_to), O(valid_at), and O(principals).
+ O(valid_from) and O(valid_to) can be excluded by O(ignore_timestamps=true).
+ - When V(full_idempotence) O(identifier), O(options), O(public_key), and O(signing_key)
are also considered when compared against an existing certificate.
- - C(always) is equivalent to I(force=true).
+ - V(always) is equivalent to O(force=true).
type: str
choices:
- never
@@ -78,14 +78,14 @@ options:
signature_algorithm:
description:
- As of OpenSSH 8.2 the SHA-1 signature algorithm for RSA keys has been disabled and C(ssh) will refuse
- host certificates signed with the SHA-1 algorithm. OpenSSH 8.1 made C(rsa-sha2-512) the default algorithm
+ host certificates signed with the SHA-1 algorithm. OpenSSH 8.1 made V(rsa-sha2-512) the default algorithm
when acting as a CA and signing certificates with a RSA key. However, for OpenSSH versions less than 8.1
- the SHA-2 signature algorithms, C(rsa-sha2-256) or C(rsa-sha2-512), must be specified using this option
+ the SHA-2 signature algorithms, V(rsa-sha2-256) or V(rsa-sha2-512), must be specified using this option
if compatibility with newer C(ssh) clients is required. Conversely if hosts using OpenSSH version 8.2
- or greater must remain compatible with C(ssh) clients using OpenSSH less than 7.2, then C(ssh-rsa)
- can be used when generating host certificates (a corresponding change to the sshd_config to add C(ssh-rsa)
+ or greater must remain compatible with C(ssh) clients using OpenSSH less than 7.2, then V(ssh-rsa)
+ can be used when generating host certificates (a corresponding change to the sshd_config to add V(ssh-rsa)
to the C(CASignatureAlgorithms) keyword is also required).
- - Using any value for this option with a non-RSA I(signing_key) will cause this module to fail.
+ - Using any value for this option with a non-RSA O(signing_key) will cause this module to fail.
- "Note: OpenSSH versions prior to 7.2 do not support SHA-2 signature algorithms for RSA keys and OpenSSH
versions prior to 7.3 do not support SHA-2 signature algorithms for certificates."
- See U(https://www.openssh.com/txt/release-8.2) for more information.
@@ -98,14 +98,14 @@ options:
signing_key:
description:
- The path to the private openssh key that is used for signing the public key in order to generate the certificate.
- - If the private key is on a PKCS#11 token (I(pkcs11_provider)), set this to the path to the public key instead.
- - Required if I(state) is C(present).
+ - If the private key is on a PKCS#11 token (O(pkcs11_provider)), set this to the path to the public key instead.
+ - Required if O(state) is V(present).
type: path
pkcs11_provider:
description:
- To use a signing key that resides on a PKCS#11 token, set this to the name (or full path) of the shared library to use with the token.
Usually C(libpkcs11.so).
- - If this is set, I(signing_key) needs to point to a file containing the public key of the CA.
+ - If this is set, O(signing_key) needs to point to a file containing the public key of the CA.
type: str
version_added: 1.1.0
use_agent:
@@ -117,37 +117,37 @@ options:
public_key:
description:
- The path to the public key that will be signed with the signing key in order to generate the certificate.
- - Required if I(state) is C(present).
+ - Required if O(state) is V(present).
type: path
valid_from:
description:
- "The point in time the certificate is valid from. Time can be specified either as relative time or as absolute timestamp.
Time will always be interpreted as UTC. Valid formats are: C([+-]timespec | YYYY-MM-DD | YYYY-MM-DDTHH:MM:SS | YYYY-MM-DD HH:MM:SS | always)
- where timespec can be an integer + C([w | d | h | m | s]) (for example C(+32w1d2h)).
+ where timespec can be an integer + C([w | d | h | m | s]) (for example V(+32w1d2h)).
Note that if using relative time this module is NOT idempotent."
- - "The value C(always) is only supported for OpenSSH 7.7 and greater, however, the value C(1970-01-01T00:00:01)
+ - "The value V(always) is only supported for OpenSSH 7.7 and greater, however, the value V(1970-01-01T00:00:01)
can be used with earlier versions as an equivalent expression."
- - "To ignore this value during comparison with an existing certificate set I(ignore_timestamps=true)."
- - Required if I(state) is C(present).
+ - "To ignore this value during comparison with an existing certificate set O(ignore_timestamps=true)."
+ - Required if O(state) is V(present).
type: str
valid_to:
description:
- "The point in time the certificate is valid to. Time can be specified either as relative time or as absolute timestamp.
Time will always be interpreted as UTC. Valid formats are: C([+-]timespec | YYYY-MM-DD | YYYY-MM-DDTHH:MM:SS | YYYY-MM-DD HH:MM:SS | forever)
- where timespec can be an integer + C([w | d | h | m | s]) (for example C(+32w1d2h)).
+ where timespec can be an integer + C([w | d | h | m | s]) (for example V(+32w1d2h)).
Note that if using relative time this module is NOT idempotent."
- - "To ignore this value during comparison with an existing certificate set I(ignore_timestamps=true)."
- - Required if I(state) is C(present).
+ - "To ignore this value during comparison with an existing certificate set O(ignore_timestamps=true)."
+ - Required if O(state) is V(present).
type: str
valid_at:
description:
- "Check if the certificate is valid at a certain point in time. If it is not the certificate will be regenerated.
- Time will always be interpreted as UTC. Mainly to be used with relative timespec for I(valid_from) and / or I(valid_to).
+ Time will always be interpreted as UTC. Mainly to be used with relative timespec for O(valid_from) and / or O(valid_to).
Note that if using relative time this module is NOT idempotent."
type: str
ignore_timestamps:
description:
- - "Whether the I(valid_from) and I(valid_to) timestamps should be ignored for idempotency checks."
+ - "Whether the O(valid_from) and O(valid_to) timestamps should be ignored for idempotency checks."
- "However, the values will still be applied to a new certificate if it meets any other necessary conditions for generation/regeneration."
type: bool
default: false
@@ -161,20 +161,20 @@ options:
options:
description:
- "Specify certificate options when signing a key. The option that are valid for user certificates are:"
- - "C(clear): Clear all enabled permissions. This is useful for clearing the default set of permissions so permissions may be added individually."
- - "C(force-command=command): Forces the execution of command instead of any shell or
+ - "V(clear): Clear all enabled permissions. This is useful for clearing the default set of permissions so permissions may be added individually."
+ - "V(force-command=command): Forces the execution of command instead of any shell or
command specified by the user when the certificate is used for authentication."
- - "C(no-agent-forwarding): Disable ssh-agent forwarding (permitted by default)."
- - "C(no-port-forwarding): Disable port forwarding (permitted by default)."
- - "C(no-pty): Disable PTY allocation (permitted by default)."
- - "C(no-user-rc): Disable execution of C(~/.ssh/rc) by sshd (permitted by default)."
- - "C(no-x11-forwarding): Disable X11 forwarding (permitted by default)"
- - "C(permit-agent-forwarding): Allows ssh-agent forwarding."
- - "C(permit-port-forwarding): Allows port forwarding."
- - "C(permit-pty): Allows PTY allocation."
- - "C(permit-user-rc): Allows execution of C(~/.ssh/rc) by sshd."
- - "C(permit-x11-forwarding): Allows X11 forwarding."
- - "C(source-address=address_list): Restrict the source addresses from which the certificate is considered valid.
+ - "V(no-agent-forwarding): Disable ssh-agent forwarding (permitted by default)."
+ - "V(no-port-forwarding): Disable port forwarding (permitted by default)."
+ - "V(no-pty): Disable PTY allocation (permitted by default)."
+ - "V(no-user-rc): Disable execution of C(~/.ssh/rc) by sshd (permitted by default)."
+ - "V(no-x11-forwarding): Disable X11 forwarding (permitted by default)"
+ - "V(permit-agent-forwarding): Allows ssh-agent forwarding."
+ - "V(permit-port-forwarding): Allows port forwarding."
+ - "V(permit-pty): Allows PTY allocation."
+ - "V(permit-user-rc): Allows execution of C(~/.ssh/rc) by sshd."
+ - "V(permit-x11-forwarding): Allows X11 forwarding."
+ - "V(source-address=address_list): Restrict the source addresses from which the certificate is considered valid.
The C(address_list) is a comma-separated list of one or more address/netmask pairs in CIDR format."
- "At present, no options are valid for host keys."
type: list
@@ -190,7 +190,13 @@ options:
The certificate serial number may be used in a KeyRevocationList.
The serial number may be omitted for checks, but must be specified again for a new certificate.
Note: The default value set by ssh-keygen is 0."
+ - This option accepts an B(integer). If you want to provide serial numbers as colon-separated hex strings,
+ such as C(11:22:33), you need to convert them to an integer with P(community.crypto.parse_serial#filter).
type: int
+
+seealso:
+ - plugin: community.crypto.parse_serial
+ plugin_type: filter
'''
EXAMPLES = '''
@@ -497,7 +503,10 @@ class Certificate(OpensshModule):
if self.state != 'present':
return {}
- certificate_info = self.ssh_keygen.get_certificate_info(self.path)[1]
+ certificate_info = self.ssh_keygen.get_certificate_info(
+ self.path,
+ check_rc=self.state == 'present' and not self.module.check_mode,
+ )[1]
return {
'type': self.type,
diff --git a/ansible_collections/community/crypto/plugins/modules/openssh_keypair.py b/ansible_collections/community/crypto/plugins/modules/openssh_keypair.py
index 35ee6d631..7bb35b27f 100644
--- a/ansible_collections/community/crypto/plugins/modules/openssh_keypair.py
+++ b/ansible_collections/community/crypto/plugins/modules/openssh_keypair.py
@@ -15,12 +15,12 @@ author: "David Kainz (@lolcube)"
short_description: Generate OpenSSH private and public keys
description:
- "This module allows one to (re)generate OpenSSH private and public keys. It uses
- ssh-keygen to generate keys. One can generate C(rsa), C(dsa), C(rsa1), C(ed25519)
- or C(ecdsa) private keys."
+ ssh-keygen to generate keys. One can generate V(rsa), V(dsa), V(rsa1), V(ed25519)
+ or V(ecdsa) private keys."
requirements:
- - ssh-keygen (if I(backend=openssh))
- - cryptography >= 2.6 (if I(backend=cryptography) and OpenSSH < 7.8 is installed)
- - cryptography >= 3.0 (if I(backend=cryptography) and OpenSSH >= 7.8 is installed)
+ - ssh-keygen (if O(backend=openssh))
+ - cryptography >= 2.6 (if O(backend=cryptography) and OpenSSH < 7.8 is installed)
+ - cryptography >= 3.0 (if O(backend=cryptography) and OpenSSH >= 7.8 is installed)
extends_documentation_fragment:
- ansible.builtin.files
- community.crypto.attributes
@@ -49,8 +49,8 @@ options:
type: int
type:
description:
- - "The algorithm used to generate the SSH private key. C(rsa1) is for protocol version 1.
- C(rsa1) is deprecated and may not be supported by every version of ssh-keygen."
+ - "The algorithm used to generate the SSH private key. V(rsa1) is for protocol version 1.
+ V(rsa1) is deprecated and may not be supported by every version of ssh-keygen."
type: str
default: rsa
choices: ['rsa', 'dsa', 'rsa1', 'ecdsa', 'ed25519']
@@ -71,18 +71,18 @@ options:
passphrase:
description:
- Passphrase used to decrypt an existing private key or encrypt a newly generated private key.
- - Passphrases are not supported for I(type=rsa1).
- - Can only be used when I(backend=cryptography), or when I(backend=auto) and a required C(cryptography) version is installed.
+ - Passphrases are not supported for O(type=rsa1).
+ - Can only be used when O(backend=cryptography), or when O(backend=auto) and a required C(cryptography) version is installed.
type: str
version_added: 1.7.0
private_key_format:
description:
- - Used when I(backend=cryptography) to select a format for the private key at the provided I(path).
- - When set to C(auto) this module will match the key format of the installed OpenSSH version.
+ - Used when O(backend=cryptography) to select a format for the private key at the provided O(path).
+ - When set to V(auto) this module will match the key format of the installed OpenSSH version.
- For OpenSSH < 7.8 private keys will be in PKCS1 format except ed25519 keys which will be in OpenSSH format.
- For OpenSSH >= 7.8 all private key types will be in the OpenSSH format.
- - Using this option when I(regenerate=partial_idempotence) or I(regenerate=full_idempotence) will cause
- a new keypair to be generated if the private key's format does not match the value of I(private_key_format).
+ - Using this option when O(regenerate=partial_idempotence) or O(regenerate=full_idempotence) will cause
+ a new keypair to be generated if the private key's format does not match the value of O(private_key_format).
This module will not however convert existing private keys between formats.
type: str
default: auto
@@ -94,8 +94,8 @@ options:
version_added: 1.7.0
backend:
description:
- - Selects between the C(cryptography) library or the OpenSSH binary C(opensshbin).
- - C(auto) will default to C(opensshbin) unless the OpenSSH binary is not installed or when using I(passphrase).
+ - Selects between the V(cryptography) library or the OpenSSH binary V(opensshbin).
+ - V(auto) will default to V(opensshbin) unless the OpenSSH binary is not installed or when using O(passphrase).
type: str
default: auto
choices:
@@ -109,24 +109,24 @@ options:
The module will always generate a new key if the destination file does not exist.
- By default, the key will be regenerated when it does not match the module's options,
except when the key cannot be read or the passphrase does not match. Please note that
- this B(changed) for Ansible 2.10. For Ansible 2.9, the behavior was as if C(full_idempotence)
+ this B(changed) for Ansible 2.10. For Ansible 2.9, the behavior was as if V(full_idempotence)
is specified.
- - If set to C(never), the module will fail if the key cannot be read or the passphrase
+ - If set to V(never), the module will fail if the key cannot be read or the passphrase
is not matching, and will never regenerate an existing key.
- - If set to C(fail), the module will fail if the key does not correspond to the module's
+ - If set to V(fail), the module will fail if the key does not correspond to the module's
options.
- - If set to C(partial_idempotence), the key will be regenerated if it does not conform to
+ - If set to V(partial_idempotence), the key will be regenerated if it does not conform to
the module's options. The key is B(not) regenerated if it cannot be read (broken file),
the key is protected by an unknown passphrase, or when they key is not protected by a
passphrase, but a passphrase is specified.
- - If set to C(full_idempotence), the key will be regenerated if it does not conform to the
+ - If set to V(full_idempotence), the key will be regenerated if it does not conform to the
module's options. This is also the case if the key cannot be read (broken file), the key
is protected by an unknown passphrase, or when they key is not protected by a passphrase,
but a passphrase is specified. Make sure you have a B(backup) when using this option!
- - If set to C(always), the module will always regenerate the key. This is equivalent to
- setting I(force) to C(true).
+ - If set to V(always), the module will always regenerate the key. This is equivalent to
+ setting O(force) to V(true).
- Note that adjusting the comment and the permissions can be changed without regeneration.
- Therefore, even for C(never), the task can result in changed.
+ Therefore, even for V(never), the task can result in changed.
type: str
choices:
- never
@@ -138,8 +138,8 @@ options:
version_added: '1.0.0'
notes:
- In case the ssh key is broken or password protected, the module will fail.
- Set the I(force) option to C(true) if you want to regenerate the keypair.
- - In the case a custom C(mode), C(group), C(owner), or other file attribute is provided it will be applied to both key files.
+ Set the O(force) option to V(true) if you want to regenerate the keypair.
+ - In the case a custom O(mode), O(group), O(owner), or other file attribute is provided it will be applied to both key files.
'''
EXAMPLES = '''
diff --git a/ansible_collections/community/crypto/plugins/modules/openssl_csr.py b/ansible_collections/community/crypto/plugins/modules/openssl_csr.py
index 69b663b23..01a748e79 100644
--- a/ansible_collections/community/crypto/plugins/modules/openssl_csr.py
+++ b/ansible_collections/community/crypto/plugins/modules/openssl_csr.py
@@ -17,7 +17,7 @@ short_description: Generate OpenSSL Certificate Signing Request (CSR)
description:
- "Please note that the module regenerates an existing CSR if it does not match the module's
options, or if it seems to be corrupt. If you are concerned that this could overwrite
- your existing CSR, consider using the I(backup) option."
+ your existing CSR, consider using the O(backup) option."
author:
- Yanis Guenane (@Spredzy)
- Felix Fontein (@felixfontein)
@@ -58,7 +58,7 @@ options:
default: false
return_content:
description:
- - If set to C(true), will return the (current or generated) CSR's content as I(csr).
+ - If set to V(true), will return the (current or generated) CSR's content as RV(csr).
type: bool
default: false
version_added: "1.0.0"
@@ -173,7 +173,7 @@ RETURN = r'''
privatekey:
description:
- Path to the TLS/SSL private key the CSR was generated for
- - Will be C(none) if the private key has been provided in I(privatekey_content).
+ - Will be V(none) if the private key has been provided in O(privatekey_content).
returned: changed or success
type: str
sample: /etc/ssl/private/ansible.com.pem
@@ -234,12 +234,12 @@ name_constraints_excluded:
version_added: 1.1.0
backup_file:
description: Name of backup file created.
- returned: changed and if I(backup) is C(true)
+ returned: changed and if O(backup) is V(true)
type: str
sample: /path/to/www.ansible.com.csr.2019-03-09@11:22~
csr:
description: The (current or generated) CSR's content.
- returned: if I(state) is C(present) and I(return_content) is C(true)
+ returned: if O(state) is V(present) and O(return_content) is V(true)
type: str
version_added: "1.0.0"
'''
diff --git a/ansible_collections/community/crypto/plugins/modules/openssl_csr_info.py b/ansible_collections/community/crypto/plugins/modules/openssl_csr_info.py
index 1ef07e733..fc7eaf18e 100644
--- a/ansible_collections/community/crypto/plugins/modules/openssl_csr_info.py
+++ b/ansible_collections/community/crypto/plugins/modules/openssl_csr_info.py
@@ -32,19 +32,19 @@ options:
path:
description:
- Remote absolute path where the CSR file is loaded from.
- - Either I(path) or I(content) must be specified, but not both.
+ - Either O(path) or O(content) must be specified, but not both.
type: path
content:
description:
- Content of the CSR file.
- - Either I(path) or I(content) must be specified, but not both.
+ - Either O(path) or O(content) must be specified, but not both.
type: str
version_added: "1.0.0"
select_crypto_backend:
description:
- Determines which crypto backend to use.
- - The default choice is C(auto), which tries to use C(cryptography) if available.
- - If set to C(cryptography), will try to use the L(cryptography,https://cryptography.io/) library.
+ - The default choice is V(auto), which tries to use C(cryptography) if available.
+ - If set to V(cryptography), will try to use the L(cryptography,https://cryptography.io/) library.
type: str
default: auto
choices: [ auto, cryptography ]
@@ -52,10 +52,11 @@ options:
seealso:
- module: community.crypto.openssl_csr
- module: community.crypto.openssl_csr_pipe
- - ref: community.crypto.openssl_csr_info filter <ansible_collections.community.crypto.openssl_csr_info_filter>
- # - plugin: community.crypto.openssl_csr_info
- # plugin_type: filter
+ - plugin: community.crypto.openssl_csr_info
+ plugin_type: filter
description: A filter variant of this module.
+ - plugin: community.crypto.to_serial
+ plugin_type: filter
'''
EXAMPLES = r'''
@@ -79,11 +80,11 @@ RETURN = r'''
signature_valid:
description:
- Whether the CSR's signature is valid.
- - In case the check returns C(false), the module will fail.
+ - In case the check returns V(false), the module will fail.
returned: success
type: bool
basic_constraints:
- description: Entries in the C(basic_constraints) extension, or C(none) if extension is not present.
+ description: Entries in the C(basic_constraints) extension, or V(none) if extension is not present.
returned: success
type: list
elements: str
@@ -93,7 +94,7 @@ basic_constraints_critical:
returned: success
type: bool
extended_key_usage:
- description: Entries in the C(extended_key_usage) extension, or C(none) if extension is not present.
+ description: Entries in the C(extended_key_usage) extension, or V(none) if extension is not present.
returned: success
type: list
elements: str
@@ -124,7 +125,7 @@ extensions_by_oid:
sample: "MAMCAQU="
sample: {"1.3.6.1.5.5.7.1.24": { "critical": false, "value": "MAMCAQU="}}
key_usage:
- description: Entries in the C(key_usage) extension, or C(none) if extension is not present.
+ description: Entries in the C(key_usage) extension, or V(none) if extension is not present.
returned: success
type: str
sample: [Key Agreement, Data Encipherment]
@@ -134,8 +135,8 @@ key_usage_critical:
type: bool
subject_alt_name:
description:
- - Entries in the C(subject_alt_name) extension, or C(none) if extension is not present.
- - See I(name_encoding) for how IDNs are handled.
+ - Entries in the C(subject_alt_name) extension, or V(none) if extension is not present.
+ - See O(name_encoding) for how IDNs are handled.
returned: success
type: list
elements: str
@@ -145,7 +146,7 @@ subject_alt_name_critical:
returned: success
type: bool
ocsp_must_staple:
- description: C(true) if the OCSP Must Staple extension is present, C(none) otherwise.
+ description: V(true) if the OCSP Must Staple extension is present, V(none) otherwise.
returned: success
type: bool
ocsp_must_staple_critical:
@@ -162,8 +163,8 @@ name_constraints_permitted:
name_constraints_excluded:
description:
- List of excluded subtrees the CA cannot sign certificates for.
- - Is C(none) if extension is not present.
- - See I(name_encoding) for how IDNs are handled.
+ - Is V(none) if extension is not present.
+ - See O(name_encoding) for how IDNs are handled.
returned: success
type: list
elements: str
@@ -172,7 +173,7 @@ name_constraints_excluded:
name_constraints_critical:
description:
- Whether the C(name_constraints) extension is critical.
- - Is C(none) if extension is not present.
+ - Is V(none) if extension is not present.
returned: success
type: bool
version_added: 1.1.0
@@ -197,8 +198,8 @@ public_key:
public_key_type:
description:
- The CSR's public key's type.
- - One of C(RSA), C(DSA), C(ECC), C(Ed25519), C(X25519), C(Ed448), or C(X448).
- - Will start with C(unknown) if the key type cannot be determined.
+ - One of V(RSA), V(DSA), V(ECC), V(Ed25519), V(X25519), V(Ed448), or V(X448).
+ - Will start with V(unknown) if the key type cannot be determined.
returned: success
type: str
version_added: 1.7.0
@@ -214,57 +215,57 @@ public_key_data:
description:
- Bit size of modulus (RSA) or prime number (DSA).
type: int
- returned: When C(public_key_type=RSA) or C(public_key_type=DSA)
+ returned: When RV(public_key_type=RSA) or RV(public_key_type=DSA)
modulus:
description:
- The RSA key's modulus.
type: int
- returned: When C(public_key_type=RSA)
+ returned: When RV(public_key_type=RSA)
exponent:
description:
- The RSA key's public exponent.
type: int
- returned: When C(public_key_type=RSA)
+ returned: When RV(public_key_type=RSA)
p:
description:
- The C(p) value for DSA.
- This is the prime modulus upon which arithmetic takes place.
type: int
- returned: When C(public_key_type=DSA)
+ returned: When RV(public_key_type=DSA)
q:
description:
- The C(q) value for DSA.
- This is a prime that divides C(p - 1), and at the same time the order of the subgroup of the
multiplicative group of the prime field used.
type: int
- returned: When C(public_key_type=DSA)
+ returned: When RV(public_key_type=DSA)
g:
description:
- The C(g) value for DSA.
- This is the element spanning the subgroup of the multiplicative group of the prime field used.
type: int
- returned: When C(public_key_type=DSA)
+ returned: When RV(public_key_type=DSA)
curve:
description:
- The curve's name for ECC.
type: str
- returned: When C(public_key_type=ECC)
+ returned: When RV(public_key_type=ECC)
exponent_size:
description:
- The maximum number of bits of a private key. This is basically the bit size of the subgroup used.
type: int
- returned: When C(public_key_type=ECC)
+ returned: When RV(public_key_type=ECC)
x:
description:
- The C(x) coordinate for the public point on the elliptic curve.
type: int
- returned: When C(public_key_type=ECC)
+ returned: When RV(public_key_type=ECC)
y:
description:
- - For C(public_key_type=ECC), this is the C(y) coordinate for the public point on the elliptic curve.
- - For C(public_key_type=DSA), this is the publicly known group element whose discrete logarithm w.r.t. C(g) is the private key.
+ - For RV(public_key_type=ECC), this is the C(y) coordinate for the public point on the elliptic curve.
+ - For RV(public_key_type=DSA), this is the publicly known group element whose discrete logarithm w.r.t. C(g) is the private key.
type: int
- returned: When C(public_key_type=DSA) or C(public_key_type=ECC)
+ returned: When RV(public_key_type=DSA) or RV(public_key_type=ECC)
public_key_fingerprints:
description:
- Fingerprints of CSR's public key.
@@ -276,24 +277,24 @@ public_key_fingerprints:
subject_key_identifier:
description:
- The CSR's subject key identifier.
- - The identifier is returned in hexadecimal, with C(:) used to separate bytes.
- - Is C(none) if the C(SubjectKeyIdentifier) extension is not present.
+ - The identifier is returned in hexadecimal, with V(:) used to separate bytes.
+ - Is V(none) if the C(SubjectKeyIdentifier) extension is not present.
returned: success
type: str
sample: '00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00:11:22:33'
authority_key_identifier:
description:
- The CSR's authority key identifier.
- - The identifier is returned in hexadecimal, with C(:) used to separate bytes.
- - Is C(none) if the C(AuthorityKeyIdentifier) extension is not present.
+ - The identifier is returned in hexadecimal, with V(:) used to separate bytes.
+ - Is V(none) if the C(AuthorityKeyIdentifier) extension is not present.
returned: success
type: str
sample: '00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00:11:22:33'
authority_cert_issuer:
description:
- The CSR's authority cert issuer as a list of general names.
- - Is C(none) if the C(AuthorityKeyIdentifier) extension is not present.
- - See I(name_encoding) for how IDNs are handled.
+ - Is V(none) if the C(AuthorityKeyIdentifier) extension is not present.
+ - See O(name_encoding) for how IDNs are handled.
returned: success
type: list
elements: str
@@ -301,7 +302,9 @@ authority_cert_issuer:
authority_cert_serial_number:
description:
- The CSR's authority cert serial number.
- - Is C(none) if the C(AuthorityKeyIdentifier) extension is not present.
+ - Is V(none) if the C(AuthorityKeyIdentifier) extension is not present.
+ - This return value is an B(integer). If you need the serial numbers as a colon-separated hex string,
+ such as C(11:22:33), you need to convert it to that form with P(community.crypto.to_serial#filter).
returned: success
type: int
sample: 12345
diff --git a/ansible_collections/community/crypto/plugins/modules/openssl_csr_pipe.py b/ansible_collections/community/crypto/plugins/modules/openssl_csr_pipe.py
index 66cc67354..0c42d5e78 100644
--- a/ansible_collections/community/crypto/plugins/modules/openssl_csr_pipe.py
+++ b/ansible_collections/community/crypto/plugins/modules/openssl_csr_pipe.py
@@ -27,6 +27,12 @@ extends_documentation_fragment:
attributes:
check_mode:
support: full
+ details:
+ - Currently in check mode, private keys will not be (re-)generated, only the changed status is
+ set. This will change in community.crypto 3.0.0.
+ - From community.crypto 3.0.0 on, the module will ignore check mode and always behave as if
+ check mode is not active. If you think this breaks your use-case of this module, please
+ create an issue in the community.crypto repository.
diff_mode:
support: full
options:
@@ -34,6 +40,14 @@ options:
description:
- The existing CSR.
type: str
+ privatekey_path:
+ description:
+ - The path to the private key to use when signing the certificate signing request.
+ - Either O(privatekey_path) or O(privatekey_content) must be specified, but not both.
+ privatekey_content:
+ description:
+ - The content of the private key to use when signing the certificate signing request.
+ - Either O(privatekey_path) or O(privatekey_content) must be specified, but not both.
seealso:
- module: community.crypto.openssl_csr
'''
@@ -50,7 +64,7 @@ EXAMPLES = r'''
- name: Generate an OpenSSL Certificate Signing Request with an inline CSR
community.crypto.openssl_csr:
- content: "{{ lookup('file', '/etc/ssl/csr/www.ansible.com.csr') }}"
+ content: "{{ lookup('ansible.builtin.file', '/etc/ssl/csr/www.ansible.com.csr') }}"
privatekey_content: "{{ private_key_content }}"
common_name: www.ansible.com
register: result
@@ -65,7 +79,7 @@ RETURN = r'''
privatekey:
description:
- Path to the TLS/SSL private key the CSR was generated for
- - Will be C(none) if the private key has been provided in I(privatekey_content).
+ - Will be V(none) if the private key has been provided in O(privatekey_content).
returned: changed or success
type: str
sample: /etc/ssl/private/ansible.com.pem
@@ -138,6 +152,7 @@ from ansible_collections.community.crypto.plugins.module_utils.crypto.basic impo
class CertificateSigningRequestModule(object):
def __init__(self, module, module_backend):
self.check_mode = module.check_mode
+ self.module = module
self.module_backend = module_backend
self.changed = False
if module.params['content'] is not None:
@@ -148,6 +163,16 @@ class CertificateSigningRequestModule(object):
if self.module_backend.needs_regeneration():
if not self.check_mode:
self.module_backend.generate_csr()
+ else:
+ self.module.deprecate(
+ 'Check mode support for openssl_csr_pipe will change in community.crypto 3.0.0'
+ ' to behave the same as without check mode. You can get that behavior right now'
+ ' by adding `check_mode: false` to the openssl_csr_pipe task. If you think this'
+ ' breaks your use-case of this module, please create an issue in the'
+ ' community.crypto repository',
+ version='3.0.0',
+ collection_name='community.crypto',
+ )
self.changed = True
def dump(self):
diff --git a/ansible_collections/community/crypto/plugins/modules/openssl_dhparam.py b/ansible_collections/community/crypto/plugins/modules/openssl_dhparam.py
index d9e1e982e..2c7d93541 100644
--- a/ansible_collections/community/crypto/plugins/modules/openssl_dhparam.py
+++ b/ansible_collections/community/crypto/plugins/modules/openssl_dhparam.py
@@ -18,10 +18,10 @@ description:
- This module uses file common arguments to specify generated file permissions.
- "Please note that the module regenerates existing DH params if they do not
match the module's options. If you are concerned that this could overwrite
- your existing DH params, consider using the I(backup) option."
+ your existing DH params, consider using the O(backup) option."
- The module can use the cryptography Python library, or the C(openssl) executable.
By default, it tries to detect which one is available. This can be overridden
- with the I(select_crypto_backend) option.
+ with the O(select_crypto_backend) option.
requirements:
- Either cryptography >= 2.0
- Or OpenSSL binary C(openssl)
@@ -70,16 +70,16 @@ options:
select_crypto_backend:
description:
- Determines which crypto backend to use.
- - The default choice is C(auto), which tries to use C(cryptography) if available, and falls back to C(openssl).
- - If set to C(openssl), will try to use the OpenSSL C(openssl) executable.
- - If set to C(cryptography), will try to use the L(cryptography,https://cryptography.io/) library.
+ - The default choice is V(auto), which tries to use C(cryptography) if available, and falls back to C(openssl).
+ - If set to V(openssl), will try to use the OpenSSL C(openssl) executable.
+ - If set to V(cryptography), will try to use the L(cryptography,https://cryptography.io/) library.
type: str
default: auto
choices: [ auto, cryptography, openssl ]
version_added: "1.0.0"
return_content:
description:
- - If set to C(true), will return the (current or generated) DH parameter's content as I(dhparams).
+ - If set to V(true), will return the (current or generated) DH parameter's content as RV(dhparams).
type: bool
default: false
version_added: "1.0.0"
@@ -120,12 +120,12 @@ filename:
sample: /etc/ssl/dhparams.pem
backup_file:
description: Name of backup file created.
- returned: changed and if I(backup) is C(true)
+ returned: changed and if O(backup) is V(true)
type: str
sample: /path/to/dhparams.pem.2019-03-09@11:22~
dhparams:
description: The (current or generated) DH params' content.
- returned: if I(state) is C(present) and I(return_content) is C(true)
+ returned: if O(state) is V(present) and O(return_content) is V(true)
type: str
version_added: "1.0.0"
'''
@@ -193,7 +193,7 @@ class DHParameterBase(object):
"""Generate DH params."""
changed = False
- # ony generate when necessary
+ # only generate when necessary
if self.force or not self._check_params_valid(module):
self._do_generate(module)
changed = True
@@ -341,7 +341,7 @@ class DHParameterCryptography(DHParameterBase):
try:
with open(self.path, 'rb') as f:
data = f.read()
- params = self.crypto_backend.load_pem_parameters(data)
+ params = cryptography.hazmat.primitives.serialization.load_pem_parameters(data, backend=self.crypto_backend)
except Exception as dummy:
return False
# Check parameters
diff --git a/ansible_collections/community/crypto/plugins/modules/openssl_pkcs12.py b/ansible_collections/community/crypto/plugins/modules/openssl_pkcs12.py
index e74553b58..e3b993083 100644
--- a/ansible_collections/community/crypto/plugins/modules/openssl_pkcs12.py
+++ b/ansible_collections/community/crypto/plugins/modules/openssl_pkcs12.py
@@ -19,12 +19,12 @@ description:
- This module allows one to (re-)generate PKCS#12.
- The module can use the cryptography Python library, or the pyOpenSSL Python
library. By default, it tries to detect which one is available, assuming none of the
- I(iter_size) and I(maciter_size) options are used. This can be overridden with the
- I(select_crypto_backend) option.
+ O(iter_size) and O(maciter_size) options are used. This can be overridden with the
+ O(select_crypto_backend) option.
# Please note that the C(pyopenssl) backend has been deprecated in community.crypto x.y.0,
# and will be removed in community.crypto (x+1).0.0.
requirements:
- - PyOpenSSL >= 0.15 or cryptography >= 3.0
+ - PyOpenSSL >= 0.15, < 23.3.0 or cryptography >= 3.0
extends_documentation_fragment:
- ansible.builtin.files
- community.crypto.attributes
@@ -39,21 +39,21 @@ attributes:
options:
action:
description:
- - C(export) or C(parse) a PKCS#12.
+ - V(export) or V(parse) a PKCS#12.
type: str
default: export
choices: [ export, parse ]
other_certificates:
description:
- - List of other certificates to include. Pre Ansible 2.8 this parameter was called I(ca_certificates).
+ - List of other certificates to include. Pre Ansible 2.8 this parameter was called O(ca_certificates).
- Assumes there is one PEM-encoded certificate per file. If a file contains multiple PEM certificates,
- set I(other_certificates_parse_all) to C(true).
+ set O(other_certificates_parse_all) to V(true).
type: list
elements: path
aliases: [ ca_certificates ]
other_certificates_parse_all:
description:
- - If set to C(true), assumes that the files mentioned in I(other_certificates) can contain more than one
+ - If set to V(true), assumes that the files mentioned in O(other_certificates) can contain more than one
certificate per file (or even none per file).
type: bool
default: false
@@ -77,21 +77,21 @@ options:
description:
- Number of times to repeat the encryption step.
- This is B(not considered during idempotency checks).
- - This is only used by the C(pyopenssl) backend, or when I(encryption_level=compatibility2022).
- - When using it, the default is C(2048) for C(pyopenssl) and C(50000) for C(cryptography).
+ - This is only used by the C(pyopenssl) backend, or when O(encryption_level=compatibility2022).
+ - When using it, the default is V(2048) for C(pyopenssl) and V(50000) for C(cryptography).
type: int
maciter_size:
description:
- Number of times to repeat the MAC step.
- This is B(not considered during idempotency checks).
- - This is only used by the C(pyopenssl) backend. When using it, the default is C(1).
+ - This is only used by the C(pyopenssl) backend. When using it, the default is V(1).
type: int
encryption_level:
description:
- Determines the encryption level used.
- - C(auto) uses the default of the selected backend. For C(cryptography), this is what the
+ - V(auto) uses the default of the selected backend. For C(cryptography), this is what the
cryptography library's specific version considers the best available encryption.
- - C(compatibility2022) uses compatibility settings for older software in 2022.
+ - V(compatibility2022) uses compatibility settings for older software in 2022.
This is only supported by the C(cryptography) backend if cryptography >= 38.0.0 is available.
- B(Note) that this option is B(not used for idempotency).
choices:
@@ -119,18 +119,18 @@ options:
privatekey_path:
description:
- File to read private key from.
- - Mutually exclusive with I(privatekey_content).
+ - Mutually exclusive with O(privatekey_content).
type: path
privatekey_content:
description:
- Content of the private key file.
- - Mutually exclusive with I(privatekey_path).
+ - Mutually exclusive with O(privatekey_path).
type: str
version_added: "2.3.0"
state:
description:
- Whether the file should exist or not.
- All parameters except C(path) are ignored when state is C(absent).
+ All parameters except O(path) are ignored when state is V(absent).
choices: [ absent, present ]
default: present
type: str
@@ -146,18 +146,18 @@ options:
default: false
return_content:
description:
- - If set to C(true), will return the (current or generated) PKCS#12's content as I(pkcs12).
+ - If set to V(true), will return the (current or generated) PKCS#12's content as RV(pkcs12).
type: bool
default: false
version_added: "1.0.0"
select_crypto_backend:
description:
- Determines which crypto backend to use.
- - The default choice is C(auto), which tries to use C(cryptography) if available, and falls back to C(pyopenssl).
- If I(iter_size) is used together with I(encryption_level != compatibility2022), or if I(maciter_size) is used,
- C(auto) will always result in C(pyopenssl) to be chosen for backwards compatibility.
- - If set to C(pyopenssl), will try to use the L(pyOpenSSL,https://pypi.org/project/pyOpenSSL/) library.
- - If set to C(cryptography), will try to use the L(cryptography,https://cryptography.io/) library.
+ - The default choice is V(auto), which tries to use C(cryptography) if available, and falls back to C(pyopenssl).
+ If O(iter_size) is used together with O(encryption_level) is not V(compatibility2022), or if O(maciter_size) is used,
+ V(auto) will always result in C(pyopenssl) to be chosen for backwards compatibility.
+ - If set to V(pyopenssl), will try to use the L(pyOpenSSL,https://pypi.org/project/pyOpenSSL/) library.
+ - If set to V(cryptography), will try to use the L(cryptography,https://cryptography.io/) library.
# - Please note that the C(pyopenssl) backend has been deprecated in community.crypto x.y.0, and will be
# removed in community.crypto (x+1).0.0.
# From that point on, only the C(cryptography) backend will be available.
@@ -255,12 +255,12 @@ privatekey:
sample: /etc/ssl/private/ansible.com.pem
backup_file:
description: Name of backup file created.
- returned: changed and if I(backup) is C(true)
+ returned: changed and if O(backup) is V(true)
type: str
sample: /path/to/ansible.com.pem.2019-03-09@11:22~
pkcs12:
description: The (current or generated) PKCS#12's content Base64 encoded.
- returned: if I(state) is C(present) and I(return_content) is C(true)
+ returned: if O(state) is V(present) and O(return_content) is V(true)
type: str
version_added: "1.0.0"
'''
@@ -302,11 +302,13 @@ from ansible_collections.community.crypto.plugins.module_utils.crypto.pem import
MINIMAL_CRYPTOGRAPHY_VERSION = '3.0'
MINIMAL_PYOPENSSL_VERSION = '0.15'
+MAXIMAL_PYOPENSSL_VERSION = '23.3.0'
PYOPENSSL_IMP_ERR = None
try:
import OpenSSL
from OpenSSL import crypto
+ from OpenSSL.crypto import load_pkcs12 as _load_pkcs12 # this got removed in pyOpenSSL 23.3.0
PYOPENSSL_VERSION = LooseVersion(OpenSSL.__version__)
except (ImportError, AttributeError):
PYOPENSSL_IMP_ERR = traceback.format_exc()
@@ -711,7 +713,11 @@ def select_backend(module, backend):
if backend == 'auto':
# Detection what is possible
can_use_cryptography = CRYPTOGRAPHY_FOUND and CRYPTOGRAPHY_VERSION >= LooseVersion(MINIMAL_CRYPTOGRAPHY_VERSION)
- can_use_pyopenssl = PYOPENSSL_FOUND and PYOPENSSL_VERSION >= LooseVersion(MINIMAL_PYOPENSSL_VERSION)
+ can_use_pyopenssl = (
+ PYOPENSSL_FOUND and
+ PYOPENSSL_VERSION >= LooseVersion(MINIMAL_PYOPENSSL_VERSION) and
+ PYOPENSSL_VERSION < LooseVersion(MAXIMAL_PYOPENSSL_VERSION)
+ )
# If no restrictions are provided, first try cryptography, then pyOpenSSL
if (
@@ -728,14 +734,17 @@ def select_backend(module, backend):
# Success?
if backend == 'auto':
module.fail_json(msg=("Cannot detect any of the required Python libraries "
- "cryptography (>= {0}) or PyOpenSSL (>= {1})").format(
+ "cryptography (>= {0}) or PyOpenSSL (>= {1}, < {2})").format(
MINIMAL_CRYPTOGRAPHY_VERSION,
- MINIMAL_PYOPENSSL_VERSION))
+ MINIMAL_PYOPENSSL_VERSION,
+ MAXIMAL_PYOPENSSL_VERSION))
if backend == 'pyopenssl':
if not PYOPENSSL_FOUND:
- module.fail_json(msg=missing_required_lib('pyOpenSSL >= {0}'.format(MINIMAL_PYOPENSSL_VERSION)),
- exception=PYOPENSSL_IMP_ERR)
+ msg = missing_required_lib(
+ 'pyOpenSSL >= {0}, < {1}'.format(MINIMAL_PYOPENSSL_VERSION, MAXIMAL_PYOPENSSL_VERSION)
+ )
+ module.fail_json(msg=msg, exception=PYOPENSSL_IMP_ERR)
# module.deprecate('The module is using the PyOpenSSL backend. This backend has been deprecated',
# version='x.0.0', collection_name='community.crypto')
return backend, PkcsPyOpenSSL(module)
diff --git a/ansible_collections/community/crypto/plugins/modules/openssl_privatekey.py b/ansible_collections/community/crypto/plugins/modules/openssl_privatekey.py
index 7b50caff7..a55395d3f 100644
--- a/ansible_collections/community/crypto/plugins/modules/openssl_privatekey.py
+++ b/ansible_collections/community/crypto/plugins/modules/openssl_privatekey.py
@@ -15,7 +15,12 @@ module: openssl_privatekey
short_description: Generate OpenSSL private keys
description:
- This module allows one to (re)generate OpenSSL private keys.
- - The default mode for the private key file will be C(0600) if I(mode) is not explicitly set.
+ - The default mode for the private key file will be V(0600) if O(mode) is not explicitly set.
+ - "Please note that the module regenerates private keys if they do not match
+ the module's options. In particular, if you provide another passphrase
+ (or specify none), change the keysize, etc., the private key will be
+ regenerated. If you are concerned that this could B(overwrite your private key),
+ consider using the O(backup) option."
author:
- Yanis Guenane (@Spredzy)
- Felix Fontein (@felixfontein)
@@ -45,8 +50,8 @@ options:
default: false
path:
description:
- - Name of the file in which the generated TLS/SSL private key will be written. It will have C(0600) mode
- if I(mode) is not explicitly set.
+ - Name of the file in which the generated TLS/SSL private key will be written. It will have V(0600) mode
+ if O(mode) is not explicitly set.
type: path
required: true
format:
@@ -61,10 +66,10 @@ options:
default: false
return_content:
description:
- - If set to C(true), will return the (current or generated) private key's content as I(privatekey).
+ - If set to V(true), will return the (current or generated) private key's content as RV(privatekey).
- Note that especially if the private key is not encrypted, you have to make sure that the returned
value is treated appropriately and not accidentally written to logs etc.! Use with care!
- - Use Ansible's I(no_log) task option to avoid the output being shown. See also
+ - Use Ansible's C(no_log) task option to avoid the output being shown. See also
U(https://docs.ansible.com/ansible/latest/reference_appendices/faq.html#how-do-i-keep-secret-data-in-my-playbook).
type: bool
default: false
@@ -101,6 +106,12 @@ EXAMPLES = r'''
community.crypto.openssl_privatekey:
path: /etc/ssl/private/ansible.com.pem
type: DSA
+
+- name: Generate an OpenSSL private key with elliptic curve cryptography (ECC)
+ community.crypto.openssl_privatekey:
+ path: /etc/ssl/private/ansible.com.pem
+ type: ECC
+ curve: secp256r1
'''
RETURN = r'''
@@ -116,7 +127,7 @@ type:
sample: RSA
curve:
description: Elliptic curve used to generate the TLS/SSL private key.
- returned: changed or success, and I(type) is C(ECC)
+ returned: changed or success, and O(type) is V(ECC)
type: str
sample: secp256r1
filename:
@@ -138,14 +149,14 @@ fingerprint:
sha512: "fd:ed:5e:39:48:5f:9f:fe:7f:25:06:3f:79:08:cd:ee:a5:e7:b3:3d:13:82:87:1f:84:e1:f5:c7:28:77:53:94:86:56:38:69:f0:d9:35:22:01:1e:a6:60:...:0f:9b"
backup_file:
description: Name of backup file created.
- returned: changed and if I(backup) is C(true)
+ returned: changed and if O(backup) is V(true)
type: str
sample: /path/to/privatekey.pem.2019-03-09@11:22~
privatekey:
description:
- The (current or generated) private key's content.
- Will be Base64-encoded if the key is in raw format.
- returned: if I(state) is C(present) and I(return_content) is C(true)
+ returned: if O(state) is V(present) and O(return_content) is V(true)
type: str
version_added: '1.0.0'
'''
diff --git a/ansible_collections/community/crypto/plugins/modules/openssl_privatekey_convert.py b/ansible_collections/community/crypto/plugins/modules/openssl_privatekey_convert.py
index 5aec5cbe8..a09e3e10d 100644
--- a/ansible_collections/community/crypto/plugins/modules/openssl_privatekey_convert.py
+++ b/ansible_collections/community/crypto/plugins/modules/openssl_privatekey_convert.py
@@ -16,7 +16,7 @@ short_description: Convert OpenSSL private keys
version_added: 2.1.0
description:
- This module allows one to convert OpenSSL private keys.
- - The default mode for the private key file will be C(0600) if I(mode) is not explicitly set.
+ - The default mode for the private key file will be V(0600) if O(mode) is not explicitly set.
author:
- Felix Fontein (@felixfontein)
extends_documentation_fragment:
@@ -34,8 +34,8 @@ attributes:
options:
dest_path:
description:
- - Name of the file in which the generated TLS/SSL private key will be written. It will have C(0600) mode
- if I(mode) is not explicitly set.
+ - Name of the file in which the generated TLS/SSL private key will be written. It will have V(0600) mode
+ if O(mode) is not explicitly set.
type: path
required: true
backup:
@@ -59,7 +59,7 @@ EXAMPLES = r'''
RETURN = r'''
backup_file:
description: Name of backup file created.
- returned: changed and if I(backup) is C(true)
+ returned: changed and if O(backup) is V(true)
type: str
sample: /path/to/privatekey.pem.2019-03-09@11:22~
'''
diff --git a/ansible_collections/community/crypto/plugins/modules/openssl_privatekey_info.py b/ansible_collections/community/crypto/plugins/modules/openssl_privatekey_info.py
index 7eaec2348..220bf988e 100644
--- a/ansible_collections/community/crypto/plugins/modules/openssl_privatekey_info.py
+++ b/ansible_collections/community/crypto/plugins/modules/openssl_privatekey_info.py
@@ -18,8 +18,8 @@ description:
- This module allows one to query information on OpenSSL private keys.
- In case the key consistency checks fail, the module will fail as this indicates a faked
private key. In this case, all return variables are still returned. Note that key consistency
- checks are not available all key types; if none is available, C(none) is returned for
- C(key_is_consistent).
+ checks are not available all key types; if none is available, V(none) is returned for
+ RV(key_is_consistent).
- It uses the cryptography python library to interact with OpenSSL.
requirements:
- cryptography >= 1.2.3
@@ -37,7 +37,7 @@ options:
content:
description:
- Content of the private key file.
- - Either I(path) or I(content) must be specified, but not both.
+ - Either O(path) or O(content) must be specified, but not both.
type: str
version_added: '1.0.0'
passphrase:
@@ -47,7 +47,7 @@ options:
return_private_key_data:
description:
- Whether to return private key data.
- - Only set this to C(true) when you want private information about this key to
+ - Only set this to V(true) when you want private information about this key to
leave the remote machine.
- "B(WARNING:) you have to make sure that private key data is not accidentally logged!"
type: bool
@@ -60,6 +60,9 @@ options:
avoid private key material to be transported around and computed with, and only do
so when requested explicitly. This can potentially prevent
L(side-channel attacks,https://en.wikipedia.org/wiki/Side-channel_attack).
+ - Note that consistency checks only work for certain key types, and might depend on the
+ version of the cryptography library. For example, with cryptography 42.0.0 and newer
+ consistency of RSA keys can no longer be checked.
type: bool
default: false
version_added: 2.0.0
@@ -67,8 +70,8 @@ options:
select_crypto_backend:
description:
- Determines which crypto backend to use.
- - The default choice is C(auto), which tries to use C(cryptography) if available.
- - If set to C(cryptography), will try to use the L(cryptography,https://cryptography.io/) library.
+ - The default choice is V(auto), which tries to use C(cryptography) if available.
+ - If set to V(cryptography), will try to use the L(cryptography,https://cryptography.io/) library.
type: str
default: auto
choices: [ auto, cryptography ]
@@ -76,9 +79,8 @@ options:
seealso:
- module: community.crypto.openssl_privatekey
- module: community.crypto.openssl_privatekey_pipe
- - ref: community.crypto.openssl_privatekey_info filter <ansible_collections.community.crypto.openssl_privatekey_info_filter>
- # - plugin: community.crypto.openssl_privatekey_info
- # plugin_type: filter
+ - plugin: community.crypto.openssl_privatekey_info
+ plugin_type: filter
description: A filter variant of this module.
'''
@@ -108,10 +110,10 @@ can_parse_key:
type: bool
key_is_consistent:
description:
- - Whether the key is consistent. Can also return C(none) next to C(true) and
- C(false), to indicate that consistency could not be checked.
- - In case the check returns C(false), the module will fail.
- returned: when I(check_consistency=true)
+ - Whether the key is consistent. Can also return V(none) next to V(true) and
+ V(false), to indicate that consistency could not be checked.
+ - In case the check returns V(false), the module will fail.
+ returned: when O(check_consistency=true)
type: bool
public_key:
description: Private key's public key in PEM format.
@@ -129,8 +131,8 @@ public_key_fingerprints:
type:
description:
- The key's type.
- - One of C(RSA), C(DSA), C(ECC), C(Ed25519), C(X25519), C(Ed448), or C(X448).
- - Will start with C(unknown) if the key type cannot be determined.
+ - One of V(RSA), V(DSA), V(ECC), V(Ed25519), V(X25519), V(Ed448), or V(X448).
+ - Will start with V(unknown) if the key type cannot be determined.
returned: success
type: str
sample: RSA
@@ -144,61 +146,61 @@ public_data:
description:
- Bit size of modulus (RSA) or prime number (DSA).
type: int
- returned: When C(type=RSA) or C(type=DSA)
+ returned: When RV(type=RSA) or RV(type=DSA)
modulus:
description:
- The RSA key's modulus.
type: int
- returned: When C(type=RSA)
+ returned: When RV(type=RSA)
exponent:
description:
- The RSA key's public exponent.
type: int
- returned: When C(type=RSA)
+ returned: When RV(type=RSA)
p:
description:
- The C(p) value for DSA.
- This is the prime modulus upon which arithmetic takes place.
type: int
- returned: When C(type=DSA)
+ returned: When RV(type=DSA)
q:
description:
- The C(q) value for DSA.
- This is a prime that divides C(p - 1), and at the same time the order of the subgroup of the
multiplicative group of the prime field used.
type: int
- returned: When C(type=DSA)
+ returned: When RV(type=DSA)
g:
description:
- The C(g) value for DSA.
- This is the element spanning the subgroup of the multiplicative group of the prime field used.
type: int
- returned: When C(type=DSA)
+ returned: When RV(type=DSA)
curve:
description:
- The curve's name for ECC.
type: str
- returned: When C(type=ECC)
+ returned: When RV(type=ECC)
exponent_size:
description:
- The maximum number of bits of a private key. This is basically the bit size of the subgroup used.
type: int
- returned: When C(type=ECC)
+ returned: When RV(type=ECC)
x:
description:
- The C(x) coordinate for the public point on the elliptic curve.
type: int
- returned: When C(type=ECC)
+ returned: When RV(type=ECC)
y:
description:
- - For C(type=ECC), this is the C(y) coordinate for the public point on the elliptic curve.
- - For C(type=DSA), this is the publicly known group element whose discrete logarithm w.r.t. C(g) is the private key.
+ - For RV(type=ECC), this is the C(y) coordinate for the public point on the elliptic curve.
+ - For RV(type=DSA), this is the publicly known group element whose discrete logarithm w.r.t. C(g) is the private key.
type: int
- returned: When C(type=DSA) or C(type=ECC)
+ returned: When RV(type=DSA) or RV(type=ECC)
private_data:
description:
- Private key data. Depends on key type.
- returned: success and when I(return_private_key_data) is set to C(true)
+ returned: success and when O(return_private_key_data) is set to V(true)
type: dict
'''
diff --git a/ansible_collections/community/crypto/plugins/modules/openssl_privatekey_pipe.py b/ansible_collections/community/crypto/plugins/modules/openssl_privatekey_pipe.py
index 41432840d..6c921a306 100644
--- a/ansible_collections/community/crypto/plugins/modules/openssl_privatekey_pipe.py
+++ b/ansible_collections/community/crypto/plugins/modules/openssl_privatekey_pipe.py
@@ -17,7 +17,7 @@ version_added: 1.3.0
description:
- This module allows one to (re)generate OpenSSL private keys without disk access.
- This allows to read and write keys to vaults without having to write intermediate versions to disk.
- - Make sure to not write the result of this module into logs or to the console, as it contains private key data! Use the I(no_log) task option to be sure.
+ - Make sure to not write the result of this module into logs or to the console, as it contains private key data! Use the C(no_log) task option to be sure.
- Note that this module is implemented as an L(action plugin,https://docs.ansible.com/ansible/latest/plugins/action.html)
and will always be executed on the controller.
author:
@@ -36,6 +36,12 @@ attributes:
- This action runs completely on the controller.
check_mode:
support: full
+ details:
+ - Currently in check mode, private keys will not be (re-)generated, only the changed status is
+ set. This will change in community.crypto 3.0.0.
+ - From community.crypto 3.0.0 on, the module will ignore check mode and always behave as if
+ check mode is not active. If you think this breaks your use-case of this module, please
+ create an issue in the community.crypto repository.
diff_mode:
support: full
options:
@@ -47,16 +53,39 @@ options:
type: str
content_base64:
description:
- - Set to C(true) if the content is base64 encoded.
+ - Set to V(true) if the content is base64 encoded.
type: bool
default: false
return_current_key:
description:
- - Set to C(true) to return the current private key when the module did not generate a new one.
- - Note that in case of check mode, when this option is not set to C(true), the module always returns the
+ - Set to V(true) to return the current private key when the module did not generate a new one.
+ - Note that in case of check mode, when this option is not set to V(true), the module always returns the
current key (if it was provided) and Ansible will replace it by C(VALUE_SPECIFIED_IN_NO_LOG_PARAMETER).
type: bool
default: false
+ regenerate:
+ description:
+ - Allows to configure in which situations the module is allowed to regenerate private keys.
+ The module will always generate a new key if the destination file does not exist.
+ - By default, the key will be regenerated when it does not match the module's options,
+ except when the key cannot be read or the passphrase does not match. Please note that
+ this B(changed) for Ansible 2.10. For Ansible 2.9, the behavior was as if V(full_idempotence)
+ is specified.
+ - If set to V(never), the module will fail if the key cannot be read or the passphrase
+ is not matching, and will never regenerate an existing key.
+ - If set to V(fail), the module will fail if the key does not correspond to the module's
+ options.
+ - If set to V(partial_idempotence), the key will be regenerated if it does not conform to
+ the module's options. The key is B(not) regenerated if it cannot be read (broken file),
+ the key is protected by an unknown passphrase, or when they key is not protected by a
+ passphrase, but a passphrase is specified.
+ - If set to V(full_idempotence), the key will be regenerated if it does not conform to the
+ module's options. This is also the case if the key cannot be read (broken file), the key
+ is protected by an unknown passphrase, or when they key is not protected by a passphrase,
+ but a passphrase is specified. Make sure you have a B(backup) when using this option!
+ - If set to V(always), the module will always regenerate the key.
+ - Note that if O(format_mismatch) is set to V(convert) and everything matches except the
+ format, the key will always be converted, except if O(regenerate) is set to V(always).
seealso:
- module: community.crypto.openssl_privatekey
- module: community.crypto.openssl_privatekey_info
@@ -106,7 +135,7 @@ type:
sample: RSA
curve:
description: Elliptic curve used to generate the TLS/SSL private key.
- returned: changed or success, and I(type) is C(ECC)
+ returned: changed or success, and O(type) is V(ECC)
type: str
sample: secp256r1
fingerprint:
@@ -125,8 +154,8 @@ privatekey:
description:
- The generated private key's content.
- Please note that if the result is not changed, the current private key will only be returned
- if the I(return_current_key) option is set to C(true).
+ if the O(return_current_key) option is set to V(true).
- Will be Base64-encoded if the key is in raw format.
- returned: changed, or I(return_current_key) is C(true)
+ returned: changed, or O(return_current_key) is V(true)
type: str
'''
diff --git a/ansible_collections/community/crypto/plugins/modules/openssl_publickey.py b/ansible_collections/community/crypto/plugins/modules/openssl_publickey.py
index da01d1fb4..98eca22ac 100644
--- a/ansible_collections/community/crypto/plugins/modules/openssl_publickey.py
+++ b/ansible_collections/community/crypto/plugins/modules/openssl_publickey.py
@@ -16,11 +16,11 @@ short_description: Generate an OpenSSL public key from its private key.
description:
- This module allows one to (re)generate public keys from their private keys.
- Public keys are generated in PEM or OpenSSH format. Private keys must be OpenSSL PEM keys.
- OpenSSH private keys are not supported, use the M(community.crypto.openssh_keypair) module to manage these.
+ B(OpenSSH private keys are not supported), use the M(community.crypto.openssh_keypair) module to manage these.
- The module uses the cryptography Python library.
requirements:
- cryptography >= 1.2.3 (older versions might work as well)
- - Needs cryptography >= 1.4 if I(format) is C(OpenSSH)
+ - Needs cryptography >= 1.4 if O(format) is C(OpenSSH)
author:
- Yanis Guenane (@Spredzy)
- Felix Fontein (@felixfontein)
@@ -61,14 +61,14 @@ options:
privatekey_path:
description:
- Path to the TLS/SSL private key from which to generate the public key.
- - Either I(privatekey_path) or I(privatekey_content) must be specified, but not both.
- If I(state) is C(present), one of them is required.
+ - Either O(privatekey_path) or O(privatekey_content) must be specified, but not both.
+ If O(state) is V(present), one of them is required.
type: path
privatekey_content:
description:
- The content of the TLS/SSL private key from which to generate the public key.
- - Either I(privatekey_path) or I(privatekey_content) must be specified, but not both.
- If I(state) is C(present), one of them is required.
+ - Either O(privatekey_path) or O(privatekey_content) must be specified, but not both.
+ If O(state) is V(present), one of them is required.
type: str
version_added: '1.0.0'
privatekey_passphrase:
@@ -84,14 +84,14 @@ options:
select_crypto_backend:
description:
- Determines which crypto backend to use.
- - The default choice is C(auto), which tries to use C(cryptography) if available.
- - If set to C(cryptography), will try to use the L(cryptography,https://cryptography.io/) library.
+ - The default choice is V(auto), which tries to use C(cryptography) if available.
+ - If set to V(cryptography), will try to use the L(cryptography,https://cryptography.io/) library.
type: str
default: auto
choices: [ auto, cryptography ]
return_content:
description:
- - If set to C(true), will return the (current or generated) public key's content as I(publickey).
+ - If set to V(true), will return the (current or generated) public key's content as RV(publickey).
type: bool
default: false
version_added: '1.0.0'
@@ -145,7 +145,7 @@ RETURN = r'''
privatekey:
description:
- Path to the TLS/SSL private key the public key was generated from.
- - Will be C(none) if the private key has been provided in I(privatekey_content).
+ - Will be V(none) if the private key has been provided in O(privatekey_content).
returned: changed or success
type: str
sample: /etc/ssl/private/ansible.com.pem
@@ -173,12 +173,12 @@ fingerprint:
sha512: "fd:ed:5e:39:48:5f:9f:fe:7f:25:06:3f:79:08:cd:ee:a5:e7:b3:3d:13:82:87:1f:84:e1:f5:c7:28:77:53:94:86:56:38:69:f0:d9:35:22:01:1e:a6:60:...:0f:9b"
backup_file:
description: Name of backup file created.
- returned: changed and if I(backup) is C(true)
+ returned: changed and if O(backup) is V(true)
type: str
sample: /path/to/publickey.pem.2019-03-09@11:22~
publickey:
description: The (current or generated) public key's content.
- returned: if I(state) is C(present) and I(return_content) is C(true)
+ returned: if O(state) is V(present) and O(return_content) is V(true)
type: str
version_added: '1.0.0'
'''
diff --git a/ansible_collections/community/crypto/plugins/modules/openssl_publickey_info.py b/ansible_collections/community/crypto/plugins/modules/openssl_publickey_info.py
index 7b0610065..d6e28fdd0 100644
--- a/ansible_collections/community/crypto/plugins/modules/openssl_publickey_info.py
+++ b/ansible_collections/community/crypto/plugins/modules/openssl_publickey_info.py
@@ -32,14 +32,14 @@ options:
content:
description:
- Content of the public key file.
- - Either I(path) or I(content) must be specified, but not both.
+ - Either O(path) or O(content) must be specified, but not both.
type: str
select_crypto_backend:
description:
- Determines which crypto backend to use.
- - The default choice is C(auto), which tries to use C(cryptography) if available.
- - If set to C(cryptography), will try to use the L(cryptography,https://cryptography.io/) library.
+ - The default choice is V(auto), which tries to use C(cryptography) if available.
+ - If set to V(cryptography), will try to use the L(cryptography,https://cryptography.io/) library.
type: str
default: auto
choices: [ auto, cryptography ]
@@ -47,9 +47,8 @@ options:
seealso:
- module: community.crypto.openssl_publickey
- module: community.crypto.openssl_privatekey_info
- - ref: community.crypto.openssl_publickey_info filter <ansible_collections.community.crypto.openssl_publickey_info_filter>
- # - plugin: community.crypto.openssl_publickey_info
- # plugin_type: filter
+ - plugin: community.crypto.openssl_publickey_info
+ plugin_type: filter
description: A filter variant of this module.
'''
@@ -85,8 +84,8 @@ fingerprints:
type:
description:
- The key's type.
- - One of C(RSA), C(DSA), C(ECC), C(Ed25519), C(X25519), C(Ed448), or C(X448).
- - Will start with C(unknown) if the key type cannot be determined.
+ - One of V(RSA), V(DSA), V(ECC), V(Ed25519), V(X25519), V(Ed448), or V(X448).
+ - Will start with V(unknown) if the key type cannot be determined.
returned: success
type: str
sample: RSA
@@ -100,57 +99,57 @@ public_data:
description:
- Bit size of modulus (RSA) or prime number (DSA).
type: int
- returned: When C(type=RSA) or C(type=DSA)
+ returned: When RV(type=RSA) or RV(type=DSA)
modulus:
description:
- The RSA key's modulus.
type: int
- returned: When C(type=RSA)
+ returned: When RV(type=RSA)
exponent:
description:
- The RSA key's public exponent.
type: int
- returned: When C(type=RSA)
+ returned: When RV(type=RSA)
p:
description:
- The C(p) value for DSA.
- This is the prime modulus upon which arithmetic takes place.
type: int
- returned: When C(type=DSA)
+ returned: When RV(type=DSA)
q:
description:
- The C(q) value for DSA.
- This is a prime that divides C(p - 1), and at the same time the order of the subgroup of the
multiplicative group of the prime field used.
type: int
- returned: When C(type=DSA)
+ returned: When RV(type=DSA)
g:
description:
- The C(g) value for DSA.
- This is the element spanning the subgroup of the multiplicative group of the prime field used.
type: int
- returned: When C(type=DSA)
+ returned: When RV(type=DSA)
curve:
description:
- The curve's name for ECC.
type: str
- returned: When C(type=ECC)
+ returned: When RV(type=ECC)
exponent_size:
description:
- The maximum number of bits of a private key. This is basically the bit size of the subgroup used.
type: int
- returned: When C(type=ECC)
+ returned: When RV(type=ECC)
x:
description:
- The C(x) coordinate for the public point on the elliptic curve.
type: int
- returned: When C(type=ECC)
+ returned: When RV(type=ECC)
y:
description:
- - For C(type=ECC), this is the C(y) coordinate for the public point on the elliptic curve.
- - For C(type=DSA), this is the publicly known group element whose discrete logarithm w.r.t. C(g) is the private key.
+ - For RV(type=ECC), this is the C(y) coordinate for the public point on the elliptic curve.
+ - For RV(type=DSA), this is the publicly known group element whose discrete logarithm w.r.t. C(g) is the private key.
type: int
- returned: When C(type=DSA) or C(type=ECC)
+ returned: When RV(type=DSA) or RV(type=ECC)
'''
diff --git a/ansible_collections/community/crypto/plugins/modules/openssl_signature.py b/ansible_collections/community/crypto/plugins/modules/openssl_signature.py
index 43503bd1d..8236839c2 100644
--- a/ansible_collections/community/crypto/plugins/modules/openssl_signature.py
+++ b/ansible_collections/community/crypto/plugins/modules/openssl_signature.py
@@ -35,12 +35,12 @@ options:
privatekey_path:
description:
- The path to the private key to use when signing.
- - Either I(privatekey_path) or I(privatekey_content) must be specified, but not both.
+ - Either O(privatekey_path) or O(privatekey_content) must be specified, but not both.
type: path
privatekey_content:
description:
- The content of the private key to use when signing the certificate signing request.
- - Either I(privatekey_path) or I(privatekey_content) must be specified, but not both.
+ - Either O(privatekey_path) or O(privatekey_content) must be specified, but not both.
type: str
privatekey_passphrase:
description:
@@ -56,8 +56,8 @@ options:
select_crypto_backend:
description:
- Determines which crypto backend to use.
- - The default choice is C(auto), which tries to use C(cryptography) if available.
- - If set to C(cryptography), will try to use the L(cryptography,https://cryptography.io/) library.
+ - The default choice is V(auto), which tries to use C(cryptography) if available.
+ - If set to V(cryptography), will try to use the L(cryptography,https://cryptography.io/) library.
type: str
default: auto
choices: [ auto, cryptography ]
diff --git a/ansible_collections/community/crypto/plugins/modules/openssl_signature_info.py b/ansible_collections/community/crypto/plugins/modules/openssl_signature_info.py
index b83f3e693..2a5d3b3d9 100644
--- a/ansible_collections/community/crypto/plugins/modules/openssl_signature_info.py
+++ b/ansible_collections/community/crypto/plugins/modules/openssl_signature_info.py
@@ -35,12 +35,12 @@ options:
certificate_path:
description:
- The path to the certificate used to verify the signature.
- - Either I(certificate_path) or I(certificate_content) must be specified, but not both.
+ - Either O(certificate_path) or O(certificate_content) must be specified, but not both.
type: path
certificate_content:
description:
- The content of the certificate used to verify the signature.
- - Either I(certificate_path) or I(certificate_content) must be specified, but not both.
+ - Either O(certificate_path) or O(certificate_content) must be specified, but not both.
type: str
signature:
description: Base64 encoded signature.
@@ -49,8 +49,8 @@ options:
select_crypto_backend:
description:
- Determines which crypto backend to use.
- - The default choice is C(auto), which tries to use C(cryptography) if available.
- - If set to C(cryptography), will try to use the L(cryptography,https://cryptography.io/) library.
+ - The default choice is V(auto), which tries to use C(cryptography) if available.
+ - If set to V(cryptography), will try to use the L(cryptography,https://cryptography.io/) library.
type: str
default: auto
choices: [ auto, cryptography ]
@@ -87,7 +87,7 @@ EXAMPLES = r'''
RETURN = r'''
valid:
- description: C(true) means the signature was valid for the given file, C(false) means it was not.
+ description: V(true) means the signature was valid for the given file, V(false) means it was not.
returned: success
type: bool
'''
diff --git a/ansible_collections/community/crypto/plugins/modules/x509_certificate.py b/ansible_collections/community/crypto/plugins/modules/x509_certificate.py
index 1b4ece5cb..f1c7d6b00 100644
--- a/ansible_collections/community/crypto/plugins/modules/x509_certificate.py
+++ b/ansible_collections/community/crypto/plugins/modules/x509_certificate.py
@@ -15,16 +15,16 @@ DOCUMENTATION = r'''
module: x509_certificate
short_description: Generate and/or check OpenSSL certificates
description:
- - It implements a notion of provider (one of C(selfsigned), C(ownca), C(acme), and C(entrust))
+ - It implements a notion of provider (one of V(selfsigned), V(ownca), V(acme), and V(entrust))
for your certificate.
- "Please note that the module regenerates existing certificate if it does not match the module's
options, or if it seems to be corrupt. If you are concerned that this could overwrite
- your existing certificate, consider using the I(backup) option."
+ your existing certificate, consider using the O(backup) option."
- Note that this module was called C(openssl_certificate) when included directly in Ansible up to version 2.9.
When moved to the collection C(community.crypto), it was renamed to
M(community.crypto.x509_certificate). From Ansible 2.10 on, it can still be used by the
old short name (or by C(ansible.builtin.openssl_certificate)), which redirects to
- C(community.crypto.x509_certificate). When using FQCNs or when using the
+ M(community.crypto.x509_certificate). When using FQCNs or when using the
L(collections,https://docs.ansible.com/ansible/latest/user_guide/collections_using.html#using-collections-in-a-playbook)
keyword, the new name M(community.crypto.x509_certificate) should be used to avoid
a deprecation warning.
@@ -67,15 +67,15 @@ options:
Please see the examples on how to emulate it with
M(community.crypto.x509_certificate_info), M(community.crypto.openssl_csr_info),
M(community.crypto.openssl_privatekey_info) and M(ansible.builtin.assert).
- - "The C(entrust) provider was added for Ansible 2.9 and requires credentials for the
+ - "The V(entrust) provider was added for Ansible 2.9 and requires credentials for the
L(Entrust Certificate Services,https://www.entrustdatacard.com/products/categories/ssl-certificates) (ECS) API."
- - Required if I(state) is C(present).
+ - Required if O(state) is V(present).
type: str
choices: [ acme, entrust, ownca, selfsigned ]
return_content:
description:
- - If set to C(true), will return the (current or generated) certificate's content as I(certificate).
+ - If set to V(true), will return the (current or generated) certificate's content as RV(certificate).
type: bool
default: false
version_added: '1.0.0'
@@ -222,12 +222,12 @@ filename:
sample: /etc/ssl/crt/www.ansible.com.crt
backup_file:
description: Name of backup file created.
- returned: changed and if I(backup) is C(true)
+ returned: changed and if O(backup) is V(true)
type: str
sample: /path/to/www.ansible.com.crt.2019-03-09@11:22~
certificate:
description: The (current or generated) certificate's content.
- returned: if I(state) is C(present) and I(return_content) is C(true)
+ returned: if O(state) is V(present) and O(return_content) is V(true)
type: str
version_added: '1.0.0'
'''
diff --git a/ansible_collections/community/crypto/plugins/modules/x509_certificate_info.py b/ansible_collections/community/crypto/plugins/modules/x509_certificate_info.py
index 145cd2195..d89f610c5 100644
--- a/ansible_collections/community/crypto/plugins/modules/x509_certificate_info.py
+++ b/ansible_collections/community/crypto/plugins/modules/x509_certificate_info.py
@@ -21,7 +21,7 @@ description:
up to version 2.9. When moved to the collection C(community.crypto), it was renamed to
M(community.crypto.x509_certificate_info). From Ansible 2.10 on, it can still be used by the
old short name (or by C(ansible.builtin.openssl_certificate_info)), which redirects to
- C(community.crypto.x509_certificate_info). When using FQCNs or when using the
+ M(community.crypto.x509_certificate_info). When using FQCNs or when using the
L(collections,https://docs.ansible.com/ansible/latest/user_guide/collections_using.html#using-collections-in-a-playbook)
keyword, the new name M(community.crypto.x509_certificate_info) should be used to avoid
a deprecation warning.
@@ -39,31 +39,31 @@ options:
path:
description:
- Remote absolute path where the certificate file is loaded from.
- - Either I(path) or I(content) must be specified, but not both.
+ - Either O(path) or O(content) must be specified, but not both.
- PEM and DER formats are supported.
type: path
content:
description:
- Content of the X.509 certificate in PEM format.
- - Either I(path) or I(content) must be specified, but not both.
+ - Either O(path) or O(content) must be specified, but not both.
type: str
version_added: '1.0.0'
valid_at:
description:
- A dict of names mapping to time specifications. Every time specified here
will be checked whether the certificate is valid at this point. See the
- C(valid_at) return value for informations on the result.
+ RV(valid_at) return value for information on the result.
- Time can be specified either as relative time or as absolute timestamp.
- Time will always be interpreted as UTC.
- Valid format is C([+-]timespec | ASN.1 TIME) where timespec can be an integer
- + C([w | d | h | m | s]) (for example C(+32w1d2h)), and ASN.1 TIME (in other words, pattern C(YYYYMMDDHHMMSSZ)).
+ + C([w | d | h | m | s]) (for example V(+32w1d2h)), and ASN.1 TIME (in other words, pattern C(YYYYMMDDHHMMSSZ)).
Note that all timestamps will be treated as being in UTC.
type: dict
select_crypto_backend:
description:
- Determines which crypto backend to use.
- - The default choice is C(auto), which tries to use C(cryptography) if available.
- - If set to C(cryptography), will try to use the L(cryptography,https://cryptography.io/) library.
+ - The default choice is V(auto), which tries to use C(cryptography) if available.
+ - If set to V(cryptography), will try to use the L(cryptography,https://cryptography.io/) library.
type: str
default: auto
choices: [ auto, cryptography ]
@@ -74,10 +74,11 @@ notes:
seealso:
- module: community.crypto.x509_certificate
- module: community.crypto.x509_certificate_pipe
- - ref: community.crypto.x509_certificate_info filter <ansible_collections.community.crypto.x509_certificate_info_filter>
- # - plugin: community.crypto.x509_certificate_info
- # plugin_type: filter
+ - plugin: community.crypto.x509_certificate_info
+ plugin_type: filter
description: A filter variant of this module.
+ - plugin: community.crypto.to_serial
+ plugin_type: filter
'''
EXAMPLES = r'''
@@ -127,7 +128,7 @@ expired:
returned: success
type: bool
basic_constraints:
- description: Entries in the C(basic_constraints) extension, or C(none) if extension is not present.
+ description: Entries in the C(basic_constraints) extension, or V(none) if extension is not present.
returned: success
type: list
elements: str
@@ -137,7 +138,7 @@ basic_constraints_critical:
returned: success
type: bool
extended_key_usage:
- description: Entries in the C(extended_key_usage) extension, or C(none) if extension is not present.
+ description: Entries in the C(extended_key_usage) extension, or V(none) if extension is not present.
returned: success
type: list
elements: str
@@ -168,7 +169,7 @@ extensions_by_oid:
sample: "MAMCAQU="
sample: {"1.3.6.1.5.5.7.1.24": { "critical": false, "value": "MAMCAQU="}}
key_usage:
- description: Entries in the C(key_usage) extension, or C(none) if extension is not present.
+ description: Entries in the C(key_usage) extension, or V(none) if extension is not present.
returned: success
type: str
sample: [Key Agreement, Data Encipherment]
@@ -178,8 +179,8 @@ key_usage_critical:
type: bool
subject_alt_name:
description:
- - Entries in the C(subject_alt_name) extension, or C(none) if extension is not present.
- - See I(name_encoding) for how IDNs are handled.
+ - Entries in the C(subject_alt_name) extension, or V(none) if extension is not present.
+ - See O(name_encoding) for how IDNs are handled.
returned: success
type: list
elements: str
@@ -189,7 +190,7 @@ subject_alt_name_critical:
returned: success
type: bool
ocsp_must_staple:
- description: C(true) if the OCSP Must Staple extension is present, C(none) otherwise.
+ description: V(true) if the OCSP Must Staple extension is present, V(none) otherwise.
returned: success
type: bool
ocsp_must_staple_critical:
@@ -240,8 +241,8 @@ public_key:
public_key_type:
description:
- The certificate's public key's type.
- - One of C(RSA), C(DSA), C(ECC), C(Ed25519), C(X25519), C(Ed448), or C(X448).
- - Will start with C(unknown) if the key type cannot be determined.
+ - One of V(RSA), V(DSA), V(ECC), V(Ed25519), V(X25519), V(Ed448), or V(X448).
+ - Will start with V(unknown) if the key type cannot be determined.
returned: success
type: str
version_added: 1.7.0
@@ -257,57 +258,57 @@ public_key_data:
description:
- Bit size of modulus (RSA) or prime number (DSA).
type: int
- returned: When C(public_key_type=RSA) or C(public_key_type=DSA)
+ returned: When RV(public_key_type=RSA) or RV(public_key_type=DSA)
modulus:
description:
- The RSA key's modulus.
type: int
- returned: When C(public_key_type=RSA)
+ returned: When RV(public_key_type=RSA)
exponent:
description:
- The RSA key's public exponent.
type: int
- returned: When C(public_key_type=RSA)
+ returned: When RV(public_key_type=RSA)
p:
description:
- The C(p) value for DSA.
- This is the prime modulus upon which arithmetic takes place.
type: int
- returned: When C(public_key_type=DSA)
+ returned: When RV(public_key_type=DSA)
q:
description:
- The C(q) value for DSA.
- This is a prime that divides C(p - 1), and at the same time the order of the subgroup of the
multiplicative group of the prime field used.
type: int
- returned: When C(public_key_type=DSA)
+ returned: When RV(public_key_type=DSA)
g:
description:
- The C(g) value for DSA.
- This is the element spanning the subgroup of the multiplicative group of the prime field used.
type: int
- returned: When C(public_key_type=DSA)
+ returned: When RV(public_key_type=DSA)
curve:
description:
- The curve's name for ECC.
type: str
- returned: When C(public_key_type=ECC)
+ returned: When RV(public_key_type=ECC)
exponent_size:
description:
- The maximum number of bits of a private key. This is basically the bit size of the subgroup used.
type: int
- returned: When C(public_key_type=ECC)
+ returned: When RV(public_key_type=ECC)
x:
description:
- The C(x) coordinate for the public point on the elliptic curve.
type: int
- returned: When C(public_key_type=ECC)
+ returned: When RV(public_key_type=ECC)
y:
description:
- - For C(public_key_type=ECC), this is the C(y) coordinate for the public point on the elliptic curve.
- - For C(public_key_type=DSA), this is the publicly known group element whose discrete logarithm w.r.t. C(g) is the private key.
+ - For RV(public_key_type=ECC), this is the C(y) coordinate for the public point on the elliptic curve.
+ - For RV(public_key_type=DSA), this is the publicly known group element whose discrete logarithm w.r.t. C(g) is the private key.
type: int
- returned: When C(public_key_type=DSA) or C(public_key_type=ECC)
+ returned: When RV(public_key_type=DSA) or RV(public_key_type=ECC)
public_key_fingerprints:
description:
- Fingerprints of certificate's public key.
@@ -331,7 +332,10 @@ signature_algorithm:
type: str
sample: sha256WithRSAEncryption
serial_number:
- description: The certificate's serial number.
+ description:
+ - The certificate's serial number.
+ - This return value is an B(integer). If you need the serial numbers as a colon-separated hex string,
+ such as C(11:22:33), you need to convert it to that form with P(community.crypto.to_serial#filter).
returned: success
type: int
sample: 1234
@@ -341,7 +345,7 @@ version:
type: int
sample: 3
valid_at:
- description: For every time stamp provided in the I(valid_at) option, a
+ description: For every time stamp provided in the O(valid_at) option, a
boolean whether the certificate is valid at that point in time
or not.
returned: success
@@ -349,24 +353,24 @@ valid_at:
subject_key_identifier:
description:
- The certificate's subject key identifier.
- - The identifier is returned in hexadecimal, with C(:) used to separate bytes.
- - Is C(none) if the C(SubjectKeyIdentifier) extension is not present.
+ - The identifier is returned in hexadecimal, with V(:) used to separate bytes.
+ - Is V(none) if the C(SubjectKeyIdentifier) extension is not present.
returned: success
type: str
sample: '00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00:11:22:33'
authority_key_identifier:
description:
- The certificate's authority key identifier.
- - The identifier is returned in hexadecimal, with C(:) used to separate bytes.
- - Is C(none) if the C(AuthorityKeyIdentifier) extension is not present.
+ - The identifier is returned in hexadecimal, with V(:) used to separate bytes.
+ - Is V(none) if the C(AuthorityKeyIdentifier) extension is not present.
returned: success
type: str
sample: '00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00:11:22:33'
authority_cert_issuer:
description:
- The certificate's authority cert issuer as a list of general names.
- - Is C(none) if the C(AuthorityKeyIdentifier) extension is not present.
- - See I(name_encoding) for how IDNs are handled.
+ - Is V(none) if the C(AuthorityKeyIdentifier) extension is not present.
+ - See O(name_encoding) for how IDNs are handled.
returned: success
type: list
elements: str
@@ -374,18 +378,20 @@ authority_cert_issuer:
authority_cert_serial_number:
description:
- The certificate's authority cert serial number.
- - Is C(none) if the C(AuthorityKeyIdentifier) extension is not present.
+ - Is V(none) if the C(AuthorityKeyIdentifier) extension is not present.
+ - This return value is an B(integer). If you need the serial numbers as a colon-separated hex string,
+ such as C(11:22:33), you need to convert it to that form with P(community.crypto.to_serial#filter).
returned: success
type: int
sample: 12345
ocsp_uri:
description: The OCSP responder URI, if included in the certificate. Will be
- C(none) if no OCSP responder URI is included.
+ V(none) if no OCSP responder URI is included.
returned: success
type: str
issuer_uri:
description: The Issuer URI, if included in the certificate. Will be
- C(none) if no issuer URI is included.
+ V(none) if no issuer URI is included.
returned: success
type: str
version_added: 2.9.0
diff --git a/ansible_collections/community/crypto/plugins/modules/x509_certificate_pipe.py b/ansible_collections/community/crypto/plugins/modules/x509_certificate_pipe.py
index 440a2cdf1..a968ef4c3 100644
--- a/ansible_collections/community/crypto/plugins/modules/x509_certificate_pipe.py
+++ b/ansible_collections/community/crypto/plugins/modules/x509_certificate_pipe.py
@@ -17,11 +17,8 @@ module: x509_certificate_pipe
short_description: Generate and/or check OpenSSL certificates
version_added: 1.3.0
description:
- - It implements a notion of provider (ie. C(selfsigned), C(ownca), C(entrust))
+ - It implements a notion of provider (one of V(selfsigned), V(ownca), V(entrust))
for your certificate.
- - "Please note that the module regenerates an existing certificate if it does not match the module's
- options, or if it seems to be corrupt. If you are concerned that this could overwrite
- your existing certificate, consider using the I(backup) option."
author:
- Yanis Guenane (@Spredzy)
- Markus Teufelberger (@MarkusTeufelberger)
@@ -35,13 +32,19 @@ extends_documentation_fragment:
attributes:
check_mode:
support: full
+ details:
+ - Currently in check mode, private keys will not be (re-)generated, only the changed status is
+ set. This will change in community.crypto 3.0.0.
+ - From community.crypto 3.0.0 on, the module will ignore check mode and always behave as if
+ check mode is not active. If you think this breaks your use-case of this module, please
+ create an issue in the community.crypto repository.
diff_mode:
support: full
options:
provider:
description:
- Name of the provider to use to generate/retrieve the OpenSSL certificate.
- - "The C(entrust) provider requires credentials for the
+ - "The V(entrust) provider requires credentials for the
L(Entrust Certificate Services,https://www.entrustdatacard.com/products/categories/ssl-certificates) (ECS) API."
type: str
choices: [ entrust, ownca, selfsigned ]
@@ -74,8 +77,8 @@ EXAMPLES = r'''
- name: (1/2) Generate an OpenSSL Certificate with the CSR provided inline
community.crypto.x509_certificate_pipe:
provider: ownca
- content: "{{ lookup('file', '/etc/ssl/csr/www.ansible.com.crt') }}"
- csr_content: "{{ lookup('file', '/etc/ssl/csr/www.ansible.com.csr') }}"
+ content: "{{ lookup('ansible.builtin.file', '/etc/ssl/csr/www.ansible.com.crt') }}"
+ csr_content: "{{ lookup('ansible.builtin.file', '/etc/ssl/csr/www.ansible.com.csr') }}"
ownca_cert: /path/to/ca_cert.crt
ownca_privatekey: /path/to/ca_cert.key
ownca_privatekey_passphrase: hunter2
@@ -157,6 +160,7 @@ class GenericCertificate(object):
"""Retrieve a certificate using the given module backend."""
def __init__(self, module, module_backend):
self.check_mode = module.check_mode
+ self.module = module
self.module_backend = module_backend
self.changed = False
if module.params['content'] is not None:
@@ -166,6 +170,16 @@ class GenericCertificate(object):
if self.module_backend.needs_regeneration():
if not self.check_mode:
self.module_backend.generate_certificate()
+ else:
+ self.module.deprecate(
+ 'Check mode support for x509_certificate_pipe will change in community.crypto 3.0.0'
+ ' to behave the same as without check mode. You can get that behavior right now'
+ ' by adding `check_mode: false` to the x509_certificate_pipe task. If you think this'
+ ' breaks your use-case of this module, please create an issue in the'
+ ' community.crypto repository',
+ version='3.0.0',
+ collection_name='community.crypto',
+ )
self.changed = True
def dump(self, check_mode=False):
diff --git a/ansible_collections/community/crypto/plugins/modules/x509_crl.py b/ansible_collections/community/crypto/plugins/modules/x509_crl.py
index 824ed8310..1ac97005a 100644
--- a/ansible_collections/community/crypto/plugins/modules/x509_crl.py
+++ b/ansible_collections/community/crypto/plugins/modules/x509_crl.py
@@ -45,24 +45,24 @@ options:
crl_mode:
description:
- Defines how to process entries of existing CRLs.
- - If set to C(generate), makes sure that the CRL has the exact set of revoked certificates
- as specified in I(revoked_certificates).
- - If set to C(update), makes sure that the CRL contains the revoked certificates from
- I(revoked_certificates), but can also contain other revoked certificates. If the CRL file
+ - If set to V(generate), makes sure that the CRL has the exact set of revoked certificates
+ as specified in O(revoked_certificates).
+ - If set to V(update), makes sure that the CRL contains the revoked certificates from
+ O(revoked_certificates), but can also contain other revoked certificates. If the CRL file
already exists, all entries from the existing CRL will also be included in the new CRL.
- When using C(update), you might be interested in setting I(ignore_timestamps) to C(true).
- - The default value is C(generate).
- - This parameter was called I(mode) before community.crypto 2.13.0. It has been renamed to avoid
- a collision with the common I(mode) parameter for setting the CRL file's access mode.
+ When using V(update), you might be interested in setting O(ignore_timestamps) to V(true).
+ - The default value is V(generate).
+ - This parameter was called O(mode) before community.crypto 2.13.0. It has been renamed to avoid
+ a collision with the common O(mode) parameter for setting the CRL file's access mode.
type: str
# default: generate
choices: [ generate, update ]
version_added: 2.13.0
mode:
description:
- - This parameter has been renamed to I(crl_mode). The old name I(mode) is now deprecated and will
- be removed in community.crypto 3.0.0. Replace usage of this parameter with I(crl_mode).
- - Note that from community.crypto 3.0.0 on, I(mode) will be used for the CRL file's mode.
+ - This parameter has been renamed to O(crl_mode). The old name O(mode) is now deprecated and will
+ be removed in community.crypto 3.0.0. Replace usage of this parameter with O(crl_mode).
+ - Note that from community.crypto 3.0.0 on, O(mode) will be used for the CRL file's mode.
type: str
# default: generate
choices: [ generate, update ]
@@ -89,7 +89,7 @@ options:
format:
description:
- Whether the CRL file should be in PEM or DER format.
- - If an existing CRL file does match everything but I(format), it will be converted to the correct format
+ - If an existing CRL file does match everything but O(format), it will be converted to the correct format
instead of regenerated.
type: str
choices: [pem, der]
@@ -98,18 +98,18 @@ options:
privatekey_path:
description:
- Path to the CA's private key to use when signing the CRL.
- - Either I(privatekey_path) or I(privatekey_content) must be specified if I(state) is C(present), but not both.
+ - Either O(privatekey_path) or O(privatekey_content) must be specified if O(state) is V(present), but not both.
type: path
privatekey_content:
description:
- The content of the CA's private key to use when signing the CRL.
- - Either I(privatekey_path) or I(privatekey_content) must be specified if I(state) is C(present), but not both.
+ - Either O(privatekey_path) or O(privatekey_content) must be specified if O(state) is V(present), but not both.
type: str
privatekey_passphrase:
description:
- - The passphrase for the I(privatekey_path).
+ - The passphrase for the O(privatekey_path).
- This is required if the private key is password protected.
type: str
@@ -117,9 +117,9 @@ options:
description:
- Key/value pairs that will be present in the issuer name field of the CRL.
- If you need to specify more than one value with the same key, use a list as value.
- - If the order of the components is important, use I(issuer_ordered).
- - One of I(issuer) and I(issuer_ordered) is required if I(state) is C(present).
- - Mutually exclusive with I(issuer_ordered).
+ - If the order of the components is important, use O(issuer_ordered).
+ - One of O(issuer) and O(issuer_ordered) is required if O(state) is V(present).
+ - Mutually exclusive with O(issuer_ordered).
type: dict
issuer_ordered:
description:
@@ -127,8 +127,8 @@ options:
This key/value pair will be present in the issuer name field of the CRL.
- If you want to specify more than one value with the same key in a row, you can
use a list as value.
- - One of I(issuer) and I(issuer_ordered) is required if I(state) is C(present).
- - Mutually exclusive with I(issuer).
+ - One of O(issuer) and O(issuer_ordered) is required if O(state) is V(present).
+ - Mutually exclusive with O(issuer).
type: list
elements: dict
version_added: 2.0.0
@@ -139,23 +139,23 @@ options:
- Time can be specified either as relative time or as absolute timestamp.
- Time will always be interpreted as UTC.
- Valid format is C([+-]timespec | ASN.1 TIME) where timespec can be an integer
- + C([w | d | h | m | s]) (for example C(+32w1d2h)).
+ + C([w | d | h | m | s]) (for example V(+32w1d2h)).
- Note that if using relative time this module is NOT idempotent, except when
- I(ignore_timestamps) is set to C(true).
+ O(ignore_timestamps) is set to V(true).
type: str
default: "+0s"
next_update:
description:
- - "The absolute latest point in time by which this I(issuer) is expected to have issued
- another CRL. Many clients will treat a CRL as expired once I(next_update) occurs."
+ - "The absolute latest point in time by which this O(issuer) is expected to have issued
+ another CRL. Many clients will treat a CRL as expired once O(next_update) occurs."
- Time can be specified either as relative time or as absolute timestamp.
- Time will always be interpreted as UTC.
- Valid format is C([+-]timespec | ASN.1 TIME) where timespec can be an integer
- + C([w | d | h | m | s]) (for example C(+32w1d2h)).
+ + C([w | d | h | m | s]) (for example V(+32w1d2h)).
- Note that if using relative time this module is NOT idempotent, except when
- I(ignore_timestamps) is set to C(true).
- - Required if I(state) is C(present).
+ O(ignore_timestamps) is set to V(true).
+ - Required if O(state) is V(present).
type: str
digest:
@@ -164,10 +164,25 @@ options:
type: str
default: sha256
+ serial_numbers:
+ description:
+ - This option determines which values will be accepted for O(revoked_certificates[].serial_number).
+ - If set to V(integer) (default), serial numbers are assumed to be integers, for example V(66223).
+ (This example value is equivalent to the hex octet string V(01:02:AF).)
+ - If set to V(hex-octets), serial numbers are assumed to be colon-separated hex octet strings,
+ for example V(01:02:AF).
+ (This example value is equivalent to the integer V(66223).)
+ type: str
+ choices:
+ - integer
+ - hex-octets
+ default: integer
+ version_added: 2.18.0
+
revoked_certificates:
description:
- List of certificates to be revoked.
- - Required if I(state) is C(present).
+ - Required if O(state) is V(present).
type: list
elements: dict
suboptions:
@@ -175,37 +190,46 @@ options:
description:
- Path to a certificate in PEM format.
- The serial number and issuer will be extracted from the certificate.
- - Mutually exclusive with I(content) and I(serial_number). One of these three options
+ - Mutually exclusive with O(revoked_certificates[].content) and
+ O(revoked_certificates[].serial_number). One of these three options
must be specified.
type: path
content:
description:
- Content of a certificate in PEM format.
- The serial number and issuer will be extracted from the certificate.
- - Mutually exclusive with I(path) and I(serial_number). One of these three options
+ - Mutually exclusive with O(revoked_certificates[].path) and
+ O(revoked_certificates[].serial_number). One of these three options
must be specified.
type: str
serial_number:
description:
- Serial number of the certificate.
- - Mutually exclusive with I(path) and I(content). One of these three options must
+ - Mutually exclusive with O(revoked_certificates[].path) and
+ O(revoked_certificates[].content). One of these three options must
be specified.
- type: int
+ - This option accepts integers or hex octet strings, depending on the value
+ of O(serial_numbers).
+ - If O(serial_numbers=integer), integers such as V(66223) must be provided.
+ - If O(serial_numbers=hex-octets), strings such as V(01:02:AF) must be provided.
+ - You can use the filters P(community.crypto.parse_serial#filter) and
+ P(community.crypto.to_serial#filter) to convert these two representations.
+ type: raw
revocation_date:
description:
- The point in time the certificate was revoked.
- Time can be specified either as relative time or as absolute timestamp.
- Time will always be interpreted as UTC.
- Valid format is C([+-]timespec | ASN.1 TIME) where timespec can be an integer
- + C([w | d | h | m | s]) (for example C(+32w1d2h)).
+ + C([w | d | h | m | s]) (for example V(+32w1d2h)).
- Note that if using relative time this module is NOT idempotent, except when
- I(ignore_timestamps) is set to C(true).
+ O(ignore_timestamps) is set to V(true).
type: str
default: "+0s"
issuer:
description:
- The certificate's issuer.
- - "Example: C(DNS:ca.example.org)"
+ - "Example: V(DNS:ca.example.org)"
type: list
elements: str
issuer_critical:
@@ -240,9 +264,9 @@ options:
- Time can be specified either as relative time or as absolute timestamp.
- Time will always be interpreted as UTC.
- Valid format is C([+-]timespec | ASN.1 TIME) where timespec can be an integer
- + C([w | d | h | m | s]) (for example C(+32w1d2h)).
+ + C([w | d | h | m | s]) (for example V(+32w1d2h)).
- Note that if using relative time this module is NOT idempotent. This will NOT
- change when I(ignore_timestamps) is set to C(true).
+ change when O(ignore_timestamps) is set to V(true).
type: str
invalidity_date_critical:
description:
@@ -252,22 +276,28 @@ options:
ignore_timestamps:
description:
- - Whether the timestamps I(last_update), I(next_update) and I(revocation_date) (in
- I(revoked_certificates)) should be ignored for idempotency checks. The timestamp
- I(invalidity_date) in I(revoked_certificates) will never be ignored.
+ - Whether the timestamps O(last_update), O(next_update) and
+ O(revoked_certificates[].revocation_date) should be ignored for idempotency checks.
+ The timestamp O(revoked_certificates[].invalidity_date) will never be ignored.
- Use this in combination with relative timestamps for these values to get idempotency.
type: bool
default: false
return_content:
description:
- - If set to C(true), will return the (current or generated) CRL's content as I(crl).
+ - If set to V(true), will return the (current or generated) CRL's content as RV(crl).
type: bool
default: false
notes:
- All ASN.1 TIME values should be specified following the YYYYMMDDHHMMSSZ pattern.
- Date specified should be UTC. Minutes and seconds are mandatory.
+
+seealso:
+ - plugin: community.crypto.parse_serial
+ plugin_type: filter
+ - plugin: community.crypto.to_serial
+ plugin_type: filter
'''
EXAMPLES = r'''
@@ -300,7 +330,7 @@ filename:
sample: /path/to/my-ca.crl
backup_file:
description: Name of backup file created.
- returned: changed and if I(backup) is C(true)
+ returned: changed and if O(backup) is V(true)
type: str
sample: /path/to/my-ca.crl.2019-03-09@11:22~
privatekey:
@@ -310,15 +340,18 @@ privatekey:
sample: /path/to/my-ca.pem
format:
description:
- - Whether the CRL is in PEM format (C(pem)) or in DER format (C(der)).
+ - Whether the CRL is in PEM format (V(pem)) or in DER format (V(der)).
returned: success
type: str
sample: pem
+ choices:
+ - pem
+ - der
issuer:
description:
- The CRL's issuer.
- Note that for repeated values, only the last one will be returned.
- - See I(name_encoding) for how IDNs are handled.
+ - See O(name_encoding) for how IDNs are handled.
returned: success
type: dict
sample: {"organizationName": "Ansible", "commonName": "ca.example.com"}
@@ -350,7 +383,10 @@ revoked_certificates:
elements: dict
contains:
serial_number:
- description: Serial number of the certificate.
+ description:
+ - Serial number of the certificate.
+ - This return value is an B(integer). If you need the serial numbers as a colon-separated hex string,
+ such as C(11:22:33), you need to convert it to that form with P(community.crypto.to_serial#filter).
type: int
sample: 1234
revocation_date:
@@ -360,7 +396,7 @@ revoked_certificates:
issuer:
description:
- The certificate's issuer.
- - See I(name_encoding) for how IDNs are handled.
+ - See O(name_encoding) for how IDNs are handled.
type: list
elements: str
sample: ["DNS:ca.example.org"]
@@ -371,11 +407,19 @@ revoked_certificates:
reason:
description:
- The value for the revocation reason extension.
- - One of C(unspecified), C(key_compromise), C(ca_compromise), C(affiliation_changed), C(superseded),
- C(cessation_of_operation), C(certificate_hold), C(privilege_withdrawn), C(aa_compromise), and
- C(remove_from_crl).
type: str
sample: key_compromise
+ choices:
+ - unspecified
+ - key_compromise
+ - ca_compromise
+ - affiliation_changed
+ - superseded
+ - cessation_of_operation
+ - certificate_hold
+ - privilege_withdrawn
+ - aa_compromise
+ - remove_from_crl
reason_critical:
description: Whether the revocation reason extension is critical.
type: bool
@@ -393,9 +437,9 @@ revoked_certificates:
crl:
description:
- The (current or generated) CRL's content.
- - Will be the CRL itself if I(format) is C(pem), and Base64 of the
- CRL if I(format) is C(der).
- returned: if I(state) is C(present) and I(return_content) is C(true)
+ - Will be the CRL itself if O(format) is V(pem), and Base64 of the
+ CRL if O(format) is V(der).
+ returned: if O(state) is V(present) and O(return_content) is V(true)
type: str
'''
@@ -406,7 +450,9 @@ import traceback
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
from ansible.module_utils.common.text.converters import to_native, to_text
+from ansible.module_utils.common.validation import check_type_int, check_type_str
+from ansible_collections.community.crypto.plugins.module_utils.serial import parse_serial
from ansible_collections.community.crypto.plugins.module_utils.version import LooseVersion
from ansible_collections.community.crypto.plugins.module_utils.io import (
@@ -495,6 +541,7 @@ class CRL(OpenSSLObject):
self.ignore_timestamps = module.params['ignore_timestamps']
self.return_content = module.params['return_content']
self.name_encoding = module.params['name_encoding']
+ self.serial_numbers_format = module.params['serial_numbers']
self.crl_content = None
self.privatekey_path = module.params['privatekey_path']
@@ -520,6 +567,8 @@ class CRL(OpenSSLObject):
if self.digest is None:
raise CRLError('The digest "{0}" is not supported'.format(module.params['digest']))
+ self.module = module
+
self.revoked_certificates = []
for i, rc in enumerate(module.params['revoked_certificates']):
result = {
@@ -551,7 +600,7 @@ class CRL(OpenSSLObject):
)
else:
# Specify serial_number (and potentially issuer) directly
- result['serial_number'] = rc['serial_number']
+ result['serial_number'] = self._parse_serial_number(rc['serial_number'], i)
# All other options
if rc['issuer']:
result['issuer'] = [cryptography_get_name(issuer, 'issuer') for issuer in rc['issuer']]
@@ -571,8 +620,6 @@ class CRL(OpenSSLObject):
result['invalidity_date_critical'] = rc['invalidity_date_critical']
self.revoked_certificates.append(result)
- self.module = module
-
self.backup = module.params['backup']
self.backup_file = None
@@ -606,6 +653,25 @@ class CRL(OpenSSLObject):
self.diff_after = self.diff_before = self._get_info(data)
+ def _parse_serial_number(self, value, index):
+ if self.serial_numbers_format == 'integer':
+ try:
+ return check_type_int(value)
+ except TypeError as exc:
+ self.module.fail_json(msg='Error while parsing revoked_certificates[{idx}].serial_number as an integer: {exc}'.format(
+ idx=index + 1,
+ exc=to_native(exc),
+ ))
+ if self.serial_numbers_format == 'hex-octets':
+ try:
+ return parse_serial(check_type_str(value))
+ except (TypeError, ValueError) as exc:
+ self.module.fail_json(msg='Error while parsing revoked_certificates[{idx}].serial_number as an colon-separated hex octet string: {exc}'.format(
+ idx=index + 1,
+ exc=to_native(exc),
+ ))
+ raise RuntimeError('Unexpected value %s of serial_numbers' % (self.serial_numbers_format, ))
+
def _get_info(self, data):
if data is None:
return dict()
@@ -871,7 +937,7 @@ def main():
options=dict(
path=dict(type='path'),
content=dict(type='str'),
- serial_number=dict(type='int'),
+ serial_number=dict(type='raw'),
revocation_date=dict(type='str', default='+0s'),
issuer=dict(type='list', elements='str'),
issuer_critical=dict(type='bool', default=False),
@@ -891,6 +957,7 @@ def main():
mutually_exclusive=[['path', 'content', 'serial_number']],
),
name_encoding=dict(type='str', default='ignore', choices=['ignore', 'idna', 'unicode']),
+ serial_numbers=dict(type='str', default='integer', choices=['integer', 'hex-octets']),
),
required_if=[
('state', 'present', ['privatekey_path', 'privatekey_content'], True),
diff --git a/ansible_collections/community/crypto/plugins/modules/x509_crl_info.py b/ansible_collections/community/crypto/plugins/modules/x509_crl_info.py
index 7b0ebcac9..2cf25f530 100644
--- a/ansible_collections/community/crypto/plugins/modules/x509_crl_info.py
+++ b/ansible_collections/community/crypto/plugins/modules/x509_crl_info.py
@@ -28,16 +28,16 @@ options:
path:
description:
- Remote absolute path where the generated CRL file should be created or is already located.
- - Either I(path) or I(content) must be specified, but not both.
+ - Either O(path) or O(content) must be specified, but not both.
type: path
content:
description:
- Content of the X.509 CRL in PEM format, or Base64-encoded X.509 CRL.
- - Either I(path) or I(content) must be specified, but not both.
+ - Either O(path) or O(content) must be specified, but not both.
type: str
list_revoked_certificates:
description:
- - If set to C(false), the list of revoked certificates is not included in the result.
+ - If set to V(false), the list of revoked certificates is not included in the result.
- This is useful when retrieving information on large CRL files. Enumerating all revoked
certificates can take some time, including serializing the result as JSON, sending it to
the Ansible controller, and decoding it again.
@@ -50,10 +50,11 @@ notes:
They are all in UTC.
seealso:
- module: community.crypto.x509_crl
- - ref: community.crypto.x509_crl_info filter <ansible_collections.community.crypto.x509_crl_info_filter>
- # - plugin: community.crypto.x509_crl_info
- # plugin_type: filter
+ - plugin: community.crypto.x509_crl_info
+ plugin_type: filter
description: A filter variant of this module.
+ - plugin: community.crypto.to_serial
+ plugin_type: filter
'''
EXAMPLES = r'''
@@ -76,15 +77,18 @@ EXAMPLES = r'''
RETURN = r'''
format:
description:
- - Whether the CRL is in PEM format (C(pem)) or in DER format (C(der)).
+ - Whether the CRL is in PEM format (V(pem)) or in DER format (V(der)).
returned: success
type: str
sample: pem
+ choices:
+ - pem
+ - der
issuer:
description:
- The CRL's issuer.
- Note that for repeated values, only the last one will be returned.
- - See I(name_encoding) for how IDNs are handled.
+ - See O(name_encoding) for how IDNs are handled.
returned: success
type: dict
sample: {"organizationName": "Ansible", "commonName": "ca.example.com"}
@@ -111,12 +115,15 @@ digest:
sample: sha256WithRSAEncryption
revoked_certificates:
description: List of certificates to be revoked.
- returned: success if I(list_revoked_certificates=true)
+ returned: success if O(list_revoked_certificates=true)
type: list
elements: dict
contains:
serial_number:
- description: Serial number of the certificate.
+ description:
+ - Serial number of the certificate.
+ - This return value is an B(integer). If you need the serial numbers as a colon-separated hex string,
+ such as C(11:22:33), you need to convert it to that form with P(community.crypto.to_serial#filter).
type: int
sample: 1234
revocation_date:
@@ -126,7 +133,7 @@ revoked_certificates:
issuer:
description:
- The certificate's issuer.
- - See I(name_encoding) for how IDNs are handled.
+ - See O(name_encoding) for how IDNs are handled.
type: list
elements: str
sample: ["DNS:ca.example.org"]
@@ -137,11 +144,19 @@ revoked_certificates:
reason:
description:
- The value for the revocation reason extension.
- - One of C(unspecified), C(key_compromise), C(ca_compromise), C(affiliation_changed), C(superseded),
- C(cessation_of_operation), C(certificate_hold), C(privilege_withdrawn), C(aa_compromise), and
- C(remove_from_crl).
type: str
sample: key_compromise
+ choices:
+ - unspecified
+ - key_compromise
+ - ca_compromise
+ - affiliation_changed
+ - superseded
+ - cessation_of_operation
+ - certificate_hold
+ - privilege_withdrawn
+ - aa_compromise
+ - remove_from_crl
reason_critical:
description: Whether the revocation reason extension is critical.
type: bool