Este conteúdo não está disponível no idioma selecionado.
Chapter 18. Requesting certificates using RHEL System Roles
With the certificate System Role, you can use Red Hat Ansible Core to issue and manage certificates.
This chapter covers the following topics:
18.1. The certificate System Role Copiar o linkLink copiado para a área de transferência!
Using the certificate System Role, you can manage issuing and renewing TLS and SSL certificates using Ansible Core.
The role uses certmonger as the certificate provider, and currently supports issuing and renewing self-signed certificates and using the IdM integrated certificate authority (CA).
You can use the following variables in your Ansible playbook with the certificate System Role:
certificate_wait- to specify if the task should wait for the certificate to be issued.
certificate_requests- to represent each certificate to be issued and its parameters.
18.2. Requesting a new self-signed certificate using the certificate System Role Copiar o linkLink copiado para a área de transferência!
With the certificate System Role, you can use Ansible Core to issue self-signed certificates.
This process uses the certmonger provider and requests the certificate through the getcert command.
By default, certmonger automatically tries to renew the certificate before it expires. You can disable this by setting the auto_renew parameter in the Ansible playbook to no.
Prerequisites
- The Ansible Core package is installed on the control machine.
-
You have the
rhel-system-rolespackage installed on the system from which you want to run the playbook.
Procedure
Optional: Create an inventory file, for example
inventory.file:*touch inventory.file*
$ *touch inventory.file*Copy to Clipboard Copied! Toggle word wrap Toggle overflow Open your inventory file and define the hosts on which you want to request the certificate, for example:
[webserver] server.idm.example.com
[webserver] server.idm.example.comCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a playbook file, for example
request-certificate.yml:-
Set
hoststo include the hosts on which you want to request the certificate, such aswebserver. Set the
certificate_requestsvariable to include the following:-
Set the
nameparameter to the desired name of the certificate, such asmycert. -
Set the
dnsparameter to the domain to be included in the certificate, such as*.example.com. -
Set the
caparameter toself-sign.
-
Set the
Set the
rhel-system-roles.certificaterole underroles.This is the playbook file for this example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
-
Set
- Save the file.
Run the playbook:
*ansible-playbook -i inventory.file request-certificate.yml*
$ *ansible-playbook -i inventory.file request-certificate.yml*Copy to Clipboard Copied! Toggle word wrap Toggle overflow
18.3. Requesting a new certificate from IdM CA using the certificate System Role Copiar o linkLink copiado para a área de transferência!
With the certificate System Role, you can use anible-core to issue certificates while using an IdM server with an integrated certificate authority (CA). Therefore, you can efficiently and consistently manage the certificate trust chain for multiple systems when using IdM as the CA.
This process uses the certmonger provider and requests the certificate through the getcert command.
By default, certmonger automatically tries to renew the certificate before it expires. You can disable this by setting the auto_renew parameter in the Ansible playbook to no.
Prerequisites
- The Ansible Core package is installed on the control machine.
-
You have the
rhel-system-rolespackage installed on the system from which you want to run the playbook.
Procedure
Optional: Create an inventory file, for example
inventory.file:*touch inventory.file*
$ *touch inventory.file*Copy to Clipboard Copied! Toggle word wrap Toggle overflow Open your inventory file and define the hosts on which you want to request the certificate, for example:
[webserver] server.idm.example.com
[webserver] server.idm.example.comCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a playbook file, for example
request-certificate.yml:-
Set
hoststo include the hosts on which you want to request the certificate, such aswebserver. Set the
certificate_requestsvariable to include the following:-
Set the
nameparameter to the desired name of the certificate, such asmycert. -
Set the
dnsparameter to the domain to be included in the certificate, such aswww.example.com. -
Set the
principalparameter to specify the Kerberos principal, such asHTTP/www.example.com@EXAMPLE.COM. -
Set the
caparameter toipa.
-
Set the
Set the
rhel-system-roles.certificaterole underroles.This is the playbook file for this example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
-
Set
- Save the file.
Run the playbook:
*ansible-playbook -i inventory.file request-certificate.yml*
$ *ansible-playbook -i inventory.file request-certificate.yml*Copy to Clipboard Copied! Toggle word wrap Toggle overflow
18.4. Specifying commands to run before or after certificate issuance using the certificate System Role Copiar o linkLink copiado para a área de transferência!
With the certificate Role, you can use Ansible Core to execute a command before and after a certificate is issued or renewed.
In the following example, the administrator ensures stopping the httpd service before a self-signed certificate for www.example.com is issued or renewed, and restarting it afterwards.
By default, certmonger automatically tries to renew the certificate before it expires. You can disable this by setting the auto_renew parameter in the Ansible playbook to no.
Prerequisites
- The Ansible Core package is installed on the control machine.
-
You have the
rhel-system-rolespackage installed on the system from which you want to run the playbook.
Procedure
Optional: Create an inventory file, for example
inventory.file:*touch inventory.file*
$ *touch inventory.file*Copy to Clipboard Copied! Toggle word wrap Toggle overflow Open your inventory file and define the hosts on which you want to request the certificate, for example:
[webserver] server.idm.example.com
[webserver] server.idm.example.comCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a playbook file, for example
request-certificate.yml:-
Set
hoststo include the hosts on which you want to request the certificate, such aswebserver. Set the
certificate_requestsvariable to include the following:-
Set the
nameparameter to the desired name of the certificate, such asmycert. -
Set the
dnsparameter to the domain to be included in the certificate, such aswww.example.com. -
Set the
caparameter to the CA you want to use to issue the certificate, such asself-sign. -
Set the
run_beforeparameter to the command you want to execute before this certificate is issued or renewed, such assystemctl stop httpd.service. -
Set the
run_afterparameter to the command you want to execute after this certificate is issued or renewed, such assystemctl start httpd.service.
-
Set the
Set the
rhel-system-roles.certificaterole underroles.This is the playbook file for this example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
-
Set
- Save the file.
Run the playbook:
*ansible-playbook -i inventory.file request-certificate.yml*
$ *ansible-playbook -i inventory.file request-certificate.yml*Copy to Clipboard Copied! Toggle word wrap Toggle overflow