W3cubDocs

/Ansible

openssl_publickey - Generate an OpenSSL public key from its private key.

New in version 2.3.

Synopsis

This module allows one to (re)generate OpenSSL public keys from their private keys. It uses the pyOpenSSL python library to interact with openssl. Keys are generated in PEM format. This module works only if the version of PyOpenSSL is recent enough (> 16.0.0)

Requirements (on host that executes module)

  • python-pyOpenSSL

Options

parameter required default choices comments
force
no
  • True
  • False
Should the key be regenerated even it it already exists
path
yes
Name of the file in which the generated TLS/SSL public key will be written.
privatekey_path
yes
Path to the TLS/SSL private key from which to genereate the public key.
state
no present
  • present
  • absent
Whether the public key should exist or not, taking action if the state is different from what is stated.

Examples

# Generate an OpenSSL public key.
- openssl_publickey: path=/etc/ssl/public/ansible.com.pem
                     privatekey_path=/etc/ssl/private/ansible.com.pem

# Force regenerate an OpenSSL public key if it already exists
- openssl_publickey: path=/etc/ssl/public/ansible.com.pem
                     privatekey_path=/etc/ssl/private/ansible.com.pem
                     force=True

# Remove an OpenSSL public key
- openssl_publickey: path=/etc/ssl/public/ansible.com.pem
                     privatekey_path=/etc/ssl/private/ansible.com.pem
                     state=absent

Return Values

Common return values are documented here Common Return Values, the following are the fields unique to this module:

name description returned type sample
privatekey Path to the TLS/SSL private key the public key was generated from ['changed', 'success'] string /etc/ssl/private/ansible.com.pem
filename Path to the generated TLS/SSL public key file ['changed', 'success'] string /etc/ssl/public/ansible.com.pem

This is an Extras Module

For more information on what this means please read Extras Modules

For help in developing on modules, should you be so inclined, please read Community Information & Contributing, developing_test_pr and Developing Modules.

© 2012–2016 Michael DeHaan
© 2016 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/openssl_publickey_module.html