renew_nomad_certificates/README.md

118 lines
5.3 KiB
Markdown
Raw Permalink Normal View History

renew_nomad_certificates
2023-05-01 18:21:06 +00:00
=========
2023-07-11 20:56:39 +00:00
> This repository is only a mirror. Development and testing is done on a private gitea server.
2023-05-01 17:55:28 +00:00
2023-05-01 18:21:06 +00:00
This role install consul-template and configure a service to automate renewal of TLS certificates for Hashicorp Nomad on **debian-based** distributions.
2023-05-01 17:55:28 +00:00
2023-05-01 18:21:06 +00:00
Requirements
------------
2023-05-01 17:55:28 +00:00
2023-05-01 18:21:06 +00:00
This role assume that you already have installed a nomad server/client on the host, and is only here to assist in automating the certificate renewal process.
2023-05-01 17:55:28 +00:00
2023-05-01 18:21:06 +00:00
Role Variables
--------------
2023-05-01 21:02:35 +00:00
Available variables are listed below, along with default values. A sample file for the default values is available in `default/renew_nomad_certificates.yml.sample` in case you need it for any `group_vars` or `host_vars` configuration.
2023-05-01 17:55:28 +00:00
2023-05-01 18:21:06 +00:00
```yaml
2023-05-01 21:02:35 +00:00
renew_nomad_certificates_config_dir: /etc/consul-template.d/nomad # by default, set to /etc/consul-template.d/nomad
2023-05-01 17:55:28 +00:00
```
2023-05-01 18:21:06 +00:00
This variable defines where the files for the role are stored (consul-template configuration + templates).
2023-05-01 17:55:28 +00:00
2023-05-01 18:21:06 +00:00
```yaml
2023-05-01 21:02:35 +00:00
renew_nomad_certificates_consul_user: nomad # by default, set to nomad
2023-05-01 18:21:06 +00:00
```
2023-05-01 21:02:35 +00:00
This variable defines the user that'll be running the certificate renewal service. Defaults to `nomad`, and should be present on the host prior to playing this role (ideally when installing nomad).
2023-05-01 17:55:28 +00:00
2023-05-01 18:21:06 +00:00
```yaml
2023-05-01 21:02:35 +00:00
renew_nomad_certificates_consul_group: nomad # by default, set to nomad
2023-05-01 18:21:06 +00:00
```
2023-05-01 21:02:35 +00:00
This variable defines the group that'll be running the certificate renewal service. Defaults to `nomad`, and should be present on the host prior to playing this role (ideally when installing nomad).
2023-05-01 17:55:28 +00:00
2023-05-01 18:21:06 +00:00
```yaml
2023-05-01 21:02:35 +00:00
renew_nomad_certificates_vault_addr: https://vault.example.com # by default, set to https://vault.example.com
2023-05-01 18:21:06 +00:00
```
This variable defines the address the consul-template service will query to get the new certificates. Defaults to localhost, but can be changed if vault isnt reachable on localhost.
2023-05-01 17:55:28 +00:00
2023-05-01 18:21:06 +00:00
```yaml
2023-05-01 21:02:35 +00:00
renew_nomad_certificates_vault_token: mysupersecretvaulttokenthatyoushouldchange # by default, set to a dummy string
2023-05-01 18:21:06 +00:00
```
This variable defines the vault token top use to access vault and renew the certificate. Default is a dummy string to pass unit tests.
2023-05-01 17:55:28 +00:00
2023-05-01 18:21:06 +00:00
```yaml
2023-05-01 21:02:35 +00:00
renew_nomad_certificates_vault_token_unwrap: false # by default, set to false
2023-05-01 18:21:06 +00:00
```
Defines whether or not the token is wrapped and should be unwrapped (this is an enterprise-only feature of vault at the moment).
2023-05-01 17:55:28 +00:00
2023-05-01 18:21:06 +00:00
```yaml
2023-05-01 21:02:35 +00:00
renew_nomad_certificates_vault_token_renew: true # by default, set to true
2023-05-01 18:21:06 +00:00
```
This variable defines whether or not to renew the vault token. It should probably be `true`, and you should have a periodic token to handle this.
2023-05-01 17:55:28 +00:00
2023-05-01 18:21:06 +00:00
```yaml
2023-05-01 21:02:35 +00:00
renew_nomad_certificates_ca_dest: /opt/nomad/tls/ca.pem # by default, set to /opt/nomad/tls/ca.pem
2023-05-01 18:21:06 +00:00
```
2023-05-01 21:02:35 +00:00
This variable defines where to copy the certificate authority upon renewal. Default to `/opt/nomad/tls/ca.pem` but should be changed depending on where you store the certificate authority.
2023-05-01 17:55:28 +00:00
2023-05-01 18:21:06 +00:00
```yaml
2023-05-01 21:02:35 +00:00
renew_nomad_certificates_cert_dest: /opt/nomad/tls/cert.pem # by default, set to /opt/nomad/tls/cert.pem
2023-05-01 18:21:06 +00:00
```
2023-05-01 21:02:35 +00:00
This variable defines where to copy the certificates upon renewal. Default to `/opt/nomad/tls/cert.pem` but should be changed depending on where you store the certificates.
2023-05-01 17:55:28 +00:00
2023-05-01 18:21:06 +00:00
```yaml
2023-05-01 21:02:35 +00:00
renew_nomad_certificates_key_dest: /opt/nomad/tls/key.pem # by default, set to /opt/nomad/tls/cert.pem
2023-05-01 18:21:06 +00:00
```
2023-05-01 21:02:35 +00:00
This variable defines where to copy the private keys upon renewal. Default to `/opt/nomad/tls/key.pem` but should be changed depending on where you store the keys.
2023-05-01 18:21:06 +00:00
```yaml
2023-05-06 21:26:25 +00:00
renew_nomad_certificates_info: # by default, set to the following
2023-05-01 18:21:06 +00:00
issuer_path: pki/issue/your-issuer
common_name: consul01.example.com
ttl: 90d
is_server: false
2023-05-01 21:02:35 +00:00
is_client: false
2023-05-01 18:21:06 +00:00
include_consul_service: false
```
2023-05-01 21:02:35 +00:00
This variable defines the path on vault to retrieve the certificates, as well as the common name and TTL to use for it. It can also include nomad aliases in case you have registered nomad services in consul (`nomad.service.consul`). It also handles whether or not to append the server/client.yourdc.consul SAN, in case you're enforcing hostname checking.
2023-05-01 17:55:28 +00:00
2023-05-01 18:21:06 +00:00
```yaml
2023-05-01 21:02:35 +00:00
renew_nomad_certificates_nomad_dc_name: dc1.nomad # by default, set to dc1.nomad
2023-05-01 18:21:06 +00:00
```
2023-05-01 21:02:35 +00:00
In case you enforce hostname checking, set this variable to your desired dc and nomad domain. This is used to forge the SAN that will be checked by nomad to only allow specific nodes to be managers.
2023-05-01 17:55:28 +00:00
2023-05-01 18:21:06 +00:00
```yaml
2023-05-01 21:02:35 +00:00
renew_nomad_certificates_consul_service_name: nomad.service.consul # by default, set to nomad.service.consul
2023-05-01 18:21:06 +00:00
```
2023-05-01 21:02:35 +00:00
This variable defines the nomad service name in consul. Default is `nomad.service.consul`
2023-05-01 17:55:28 +00:00
2023-05-01 18:21:06 +00:00
```yaml
2023-05-01 21:02:35 +00:00
renew_nomad_certificates_start_service: false
2023-05-01 18:21:06 +00:00
```
This variable defines whether or not to start the service after creating it. By default, it is only enabled, but not started, in case you're building golden images (in which case you probably don't want a certificate generated during the build process).
2023-05-01 17:55:28 +00:00
2023-05-01 18:21:06 +00:00
Dependencies
------------
2023-05-01 17:55:28 +00:00
2024-02-05 21:59:31 +00:00
`ednz_cloud.manage_repositories` to configure hashicorp apt repository.
`ednz_cloud.manage_apt_packages` to install consul-template.
2023-05-01 17:55:28 +00:00
2023-05-01 18:21:06 +00:00
Example Playbook
----------------
2023-05-01 17:55:28 +00:00
2023-05-01 18:21:06 +00:00
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
```yaml
# calling the role inside a playbook with either the default or group_vars/host_vars
- hosts: servers
roles:
2024-02-05 21:59:31 +00:00
- ednz_cloud.renew_nomad_certificates
2023-05-01 18:21:06 +00:00
```
2023-05-01 17:55:28 +00:00
2023-05-01 18:21:06 +00:00
License
-------
2023-05-01 17:55:28 +00:00
2023-05-01 18:21:06 +00:00
MIT / BSD
2023-05-01 17:55:28 +00:00
2023-05-01 18:21:06 +00:00
Author Information
------------------
2023-05-01 17:55:28 +00:00
2023-05-01 18:21:06 +00:00
This role was created by Bertrand Lanson in 2023.