ansible-role-generate-tls-c.../README.md

80 lines
1.9 KiB
Markdown
Raw Permalink Normal View History

2018-04-20 10:40:41 +02:00
Generate TLS certificates
=========================
Generates self-signed CA, client and server certificates. Runs locally on control machine.
2018-04-20 10:40:41 +02:00
Notes:
- Will not overwrite any files in output cert dir
2021-01-24 00:32:01 +01:00
- Will not copy the files to the remote servers if the local files are unchanged
2021-01-24 13:16:15 +01:00
- Will optionally (see `gen_tls_populate_etc_hosts` variable) add to each machine's `/etc/hosts`
2021-01-24 12:50:08 +01:00
a line for each host in the inventory.
2018-04-20 12:06:31 +02:00
2018-04-20 10:40:41 +02:00
Requirements
------------
- For server certificates, must specify Ansible inventory file; FQDN must also be set as hostname in inventory file
Role Variables
--------------
See `defaults/main.yml`
Dependencies
------------
2021-01-24 00:32:01 +01:00
Install dependencies via
2018-04-20 10:40:41 +02:00
```
2021-01-24 00:32:01 +01:00
$ ansible-galaxy collection install community.crypto
```
2018-04-20 10:40:41 +02:00
2021-01-24 00:32:01 +01:00
Example Playbook
----------------
2018-04-20 10:40:41 +02:00
2021-01-24 00:32:01 +01:00
The provided example `playbook.yml` targets two hosts (take a look at the
`Vagrantfile`).
All the cryptographic relevant operations are performed on the host machine and
the resulting relevant files are `copy`ed to the remote target machine.
- `playbook.yml`
```yaml
---
- name: Run role
hosts: all
roles:
- role: generate-tls-certs
```
- `inventory.yml`
```yaml
---
all:
hosts:
srv1:
ansible_host: 192.168.123.30
srv2:
ansible_host: 192.168.123.31
vars:
2021-01-24 13:16:15 +01:00
gen_tls_cert_dir: ./certs
gen_tls_generate_ca_cert: true
gen_tls_generate_client_cert: true
gen_tls_generate_server_cert: true
gen_tls_ca_email: me@example.org
gen_tls_ca_country: EU
gen_tls_ca_state: Italy
gen_tls_ca_locality: Rome
gen_tls_ca_organization: Example Inc.
gen_tls_ca_organizationalunit: SysAdmins
gen_tls_populate_etc_hosts: yes
2021-01-24 00:32:01 +01:00
```
If you want to tinker, you can use `vagrant` with the provided `Vagrantfile`.
It assumes `vagrant-libvirt` is installed (along with `libvirt`, of course).
Run it like this:
2018-04-20 10:40:41 +02:00
```
2021-01-24 00:32:01 +01:00
$ vagrant up --provider=libvirt --provision
2018-04-20 10:40:41 +02:00
```