mirror of
https://github.com/ansible-collections/community.crypto.git
synced 2026-05-07 05:43:06 +00:00
Reformat documentation with 'andebox yaml-doc' (#828)
* Reformat documentation with 'andebox yaml-doc'. * Fix/improve. * Remaining fixes. * One more.
This commit is contained in:
@@ -9,197 +9,193 @@ from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
DOCUMENTATION = r"""
|
||||
module: openssh_cert
|
||||
author: "David Kainz (@lolcube)"
|
||||
short_description: Generate OpenSSH host or user certificates.
|
||||
short_description: Generate OpenSSH host or user certificates
|
||||
description:
|
||||
- Generate and regenerate OpenSSH host or user certificates.
|
||||
- Generate and regenerate OpenSSH host or user certificates.
|
||||
requirements:
|
||||
- "ssh-keygen"
|
||||
- "ssh-keygen"
|
||||
extends_documentation_fragment:
|
||||
- ansible.builtin.files
|
||||
- community.crypto.attributes
|
||||
- community.crypto.attributes.files
|
||||
- ansible.builtin.files
|
||||
- community.crypto.attributes
|
||||
- community.crypto.attributes.files
|
||||
attributes:
|
||||
check_mode:
|
||||
support: full
|
||||
diff_mode:
|
||||
support: full
|
||||
safe_file_operations:
|
||||
support: full
|
||||
check_mode:
|
||||
support: full
|
||||
diff_mode:
|
||||
support: full
|
||||
safe_file_operations:
|
||||
support: full
|
||||
options:
|
||||
state:
|
||||
description:
|
||||
- Whether the host or user certificate should exist or not, taking action if the state is different
|
||||
from what is stated.
|
||||
type: str
|
||||
default: "present"
|
||||
choices: [ 'present', 'absent' ]
|
||||
type:
|
||||
description:
|
||||
- Whether the module should generate a host or a user certificate.
|
||||
- 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 O(regenerate=always).
|
||||
type: bool
|
||||
default: false
|
||||
path:
|
||||
description:
|
||||
- Path of the file containing the certificate.
|
||||
type: path
|
||||
required: true
|
||||
regenerate:
|
||||
description:
|
||||
- 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 V(fail) the task will fail if a certificate already exists at O(path) and does not
|
||||
match the module's options.
|
||||
- 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.
|
||||
- V(always) is equivalent to O(force=true).
|
||||
type: str
|
||||
choices:
|
||||
- never
|
||||
- fail
|
||||
- partial_idempotence
|
||||
- full_idempotence
|
||||
- always
|
||||
default: partial_idempotence
|
||||
version_added: 1.8.0
|
||||
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 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, 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 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 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.
|
||||
type: str
|
||||
choices:
|
||||
- ssh-rsa
|
||||
- rsa-sha2-256
|
||||
- rsa-sha2-512
|
||||
version_added: 1.10.0
|
||||
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 (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, 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:
|
||||
description:
|
||||
- Should the ssh-keygen use a CA key residing in a ssh-agent.
|
||||
type: bool
|
||||
default: false
|
||||
version_added: 1.3.0
|
||||
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 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 V(+32w1d2h)).
|
||||
Note that if using relative time this module is NOT idempotent."
|
||||
- "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 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 V(+32w1d2h)).
|
||||
Note that if using relative time this module is NOT idempotent."
|
||||
- "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 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 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
|
||||
version_added: 2.2.0
|
||||
principals:
|
||||
description:
|
||||
- "Certificates may be limited to be valid for a set of principal (user/host) names.
|
||||
By default, generated certificates are valid for all users or hosts."
|
||||
type: list
|
||||
elements: str
|
||||
options:
|
||||
description:
|
||||
- "Specify certificate options when signing a key. The option that are valid for user certificates are:"
|
||||
- "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."
|
||||
- "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
|
||||
elements: str
|
||||
identifier:
|
||||
description:
|
||||
- Specify the key identity when signing a public key. The identifier that is logged by the server when the certificate is used for authentication.
|
||||
type: str
|
||||
serial_number:
|
||||
description:
|
||||
- "Specify the certificate serial number.
|
||||
The serial number is logged by the server when the certificate is used for authentication.
|
||||
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
|
||||
state:
|
||||
description:
|
||||
- Whether the host or user certificate should exist or not, taking action if the state is different from what is stated.
|
||||
type: str
|
||||
default: "present"
|
||||
choices: ['present', 'absent']
|
||||
type:
|
||||
description:
|
||||
- Whether the module should generate a host or a user certificate.
|
||||
- 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 O(regenerate=always).
|
||||
type: bool
|
||||
default: false
|
||||
path:
|
||||
description:
|
||||
- Path of the file containing the certificate.
|
||||
type: path
|
||||
required: true
|
||||
regenerate:
|
||||
description:
|
||||
- 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 V(fail) the task will fail if a certificate already exists at O(path) and does not match the module's options.
|
||||
- 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.
|
||||
- V(always) is equivalent to O(force=true).
|
||||
type: str
|
||||
choices:
|
||||
- never
|
||||
- fail
|
||||
- partial_idempotence
|
||||
- full_idempotence
|
||||
- always
|
||||
default: partial_idempotence
|
||||
version_added: 1.8.0
|
||||
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 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, 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 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 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.
|
||||
type: str
|
||||
choices:
|
||||
- ssh-rsa
|
||||
- rsa-sha2-256
|
||||
- rsa-sha2-512
|
||||
version_added: 1.10.0
|
||||
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 (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, 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:
|
||||
description:
|
||||
- Should the ssh-keygen use a CA key residing in a ssh-agent.
|
||||
type: bool
|
||||
default: false
|
||||
version_added: 1.3.0
|
||||
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 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 V(+32w1d2h)). Note that
|
||||
if using relative time this module is NOT idempotent.'
|
||||
- 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 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 V(+32w1d2h)). Note that
|
||||
if using relative time this module is NOT idempotent.'
|
||||
- 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 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 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
|
||||
version_added: 2.2.0
|
||||
principals:
|
||||
description:
|
||||
- Certificates may be limited to be valid for a set of principal (user/host) names. By default, generated certificates
|
||||
are valid for all users or hosts.
|
||||
type: list
|
||||
elements: str
|
||||
options:
|
||||
description:
|
||||
- 'Specify certificate options when signing a key. The option that are valid for user certificates are:'
|
||||
- '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.'
|
||||
- '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
|
||||
elements: str
|
||||
identifier:
|
||||
description:
|
||||
- Specify the key identity when signing a public key. The identifier that is logged by the server when the certificate
|
||||
is used for authentication.
|
||||
type: str
|
||||
serial_number:
|
||||
description:
|
||||
- 'Specify the certificate serial number. The serial number is logged by the server when the certificate is used for
|
||||
authentication. 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
|
||||
'''
|
||||
- plugin: community.crypto.parse_serial
|
||||
plugin_type: filter
|
||||
"""
|
||||
|
||||
EXAMPLES = '''
|
||||
EXAMPLES = r"""
|
||||
- name: Generate an OpenSSH user certificate that is valid forever and for all users
|
||||
community.crypto.openssh_cert:
|
||||
type: user
|
||||
@@ -231,8 +227,8 @@ EXAMPLES = '''
|
||||
valid_from: always
|
||||
valid_to: forever
|
||||
principals:
|
||||
- example.com
|
||||
- examplehost
|
||||
- example.com
|
||||
- examplehost
|
||||
|
||||
- name: Generate an OpenSSH host Certificate that is valid from 21.1.2001 to 21.1.2019
|
||||
community.crypto.openssh_cert:
|
||||
@@ -252,8 +248,8 @@ EXAMPLES = '''
|
||||
valid_from: always
|
||||
valid_to: forever
|
||||
options:
|
||||
- "clear"
|
||||
- "force-command=/tmp/bla/foo"
|
||||
- "clear"
|
||||
- "force-command=/tmp/bla/foo"
|
||||
|
||||
- name: Generate an OpenSSH user certificate using a PKCS#11 token
|
||||
community.crypto.openssh_cert:
|
||||
@@ -264,27 +260,25 @@ EXAMPLES = '''
|
||||
path: /path/to/certificate
|
||||
valid_from: always
|
||||
valid_to: forever
|
||||
"""
|
||||
|
||||
'''
|
||||
|
||||
RETURN = '''
|
||||
RETURN = r"""
|
||||
type:
|
||||
description: type of the certificate (host or user)
|
||||
returned: changed or success
|
||||
type: str
|
||||
sample: host
|
||||
description: Type of the certificate (host or user).
|
||||
returned: changed or success
|
||||
type: str
|
||||
sample: host
|
||||
filename:
|
||||
description: path to the certificate
|
||||
returned: changed or success
|
||||
type: str
|
||||
sample: /tmp/certificate-cert.pub
|
||||
description: Path to the certificate.
|
||||
returned: changed or success
|
||||
type: str
|
||||
sample: /tmp/certificate-cert.pub
|
||||
info:
|
||||
description: Information about the certificate. Output of C(ssh-keygen -L -f).
|
||||
returned: change or success
|
||||
type: list
|
||||
elements: str
|
||||
|
||||
'''
|
||||
description: Information about the certificate. Output of C(ssh-keygen -L -f).
|
||||
returned: change or success
|
||||
type: list
|
||||
elements: str
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
|
||||
Reference in New Issue
Block a user