2023-07-12 19:25:22 +02:00
|
|
|
---
|
2023-10-08 17:48:49 +02:00
|
|
|
- name: certificate_from_private_ca | Create the certificate using the private CA
|
2023-07-12 19:25:22 +02:00
|
|
|
tags: [pki, tls, tls_certificate]
|
|
|
|
block:
|
2023-10-08 17:48:49 +02:00
|
|
|
- name: certificate_from_private_ca | Set the common group between mkcert-ca and ansible
|
2023-07-13 11:31:24 +02:00
|
|
|
ansible.builtin.set_fact:
|
|
|
|
ansible_common_remote_group: ansible
|
|
|
|
|
2023-10-08 17:48:49 +02:00
|
|
|
- name: certificate_from_private_ca | Create the certificate (delegate to the CA vm)
|
2023-07-13 11:43:28 +02:00
|
|
|
ansible.builtin.command:
|
2023-07-13 11:45:02 +02:00
|
|
|
cmd: mkcert -cert-file /srv/mkcert-ca/{{ mkcert_cert_name }} -key-file /srv/mkcert-ca/{{ mkcert_key_name }} {{ mkcert_dsn_and_ip_list }}
|
2023-07-12 19:25:22 +02:00
|
|
|
args:
|
2023-07-13 11:18:18 +02:00
|
|
|
chdir: /srv/mkcert-ca
|
2023-07-12 19:25:22 +02:00
|
|
|
creates: "/srv/mkcert-ca/{{ mkcert_cert_name }}"
|
2023-07-13 11:43:28 +02:00
|
|
|
environment:
|
|
|
|
CAROOT: /srv/mkcert-ca/.local/share/mkcert
|
2023-07-12 19:25:22 +02:00
|
|
|
delegate_to: "{{ mkcert_ca_host }}"
|
|
|
|
|
2023-10-08 17:48:49 +02:00
|
|
|
- name: certificate_from_private_ca | Manage the certificate installation
|
2023-07-12 19:25:22 +02:00
|
|
|
tags: [pki, tls, tls_certificate]
|
|
|
|
block:
|
2023-10-08 17:48:49 +02:00
|
|
|
- name: certificate_from_private_ca | Get the certificate and its key from the CA server
|
2023-07-12 19:25:22 +02:00
|
|
|
ansible.builtin.fetch:
|
|
|
|
src: "/srv/mkcert-ca/{{ item }}"
|
2023-07-13 12:05:12 +02:00
|
|
|
dest: "files/"
|
|
|
|
flat: true
|
2023-07-12 19:25:22 +02:00
|
|
|
loop:
|
|
|
|
- "{{ mkcert_cert_name }}"
|
|
|
|
- "{{ mkcert_key_name }}"
|
|
|
|
delegate_to: "{{ mkcert_ca_host }}"
|
|
|
|
|
2023-10-08 17:48:49 +02:00
|
|
|
- name: certificate_from_private_ca | Copy the certificate to the destination server
|
2023-07-12 19:25:22 +02:00
|
|
|
ansible.builtin.copy:
|
|
|
|
src: "files/{{ mkcert_cert_name }}"
|
2023-07-13 13:00:10 +02:00
|
|
|
dest: "{{ mkcert_cert_dest_path }}"
|
2023-07-12 19:25:22 +02:00
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0444
|
|
|
|
|
2023-10-08 17:48:49 +02:00
|
|
|
- name: certificate_from_private_ca | Copy the certificate to the destination server
|
2023-07-12 19:25:22 +02:00
|
|
|
ansible.builtin.copy:
|
|
|
|
src: "files/{{ mkcert_key_name }}"
|
2023-07-13 13:00:10 +02:00
|
|
|
dest: "{{ mkcert_key_dest_path }}"
|
2023-07-12 19:25:22 +02:00
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0440
|