Skip to content

Commit b6c101f

Browse files
committed
Add role and playbook to generate a certs tarball
Signed-off-by: Eric D. Helms <ericdhelms@gmail.com>
1 parent a75767e commit b6c101f

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed

playbooks/certificate-bundle.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
- name: Generate a certificate bundle for a hostname
2+
hosts:
3+
- quadlet
4+
become: true
5+
vars:
6+
certificates_ca: false
7+
certificates_hostnames:
8+
- "{{ hostname }}"
9+
roles:
10+
- certificates
11+
- role: certificate_bundle
12+
vars:
13+
certificate_bundle_hostname: "{{ hostname }}"
14+
certificate_bundle_ca_certificate: "{{ certificates_ca_directory }}/certs/ca.crt"
15+
certificate_bundle_server_certificate: "{{ certificates_ca_directory }}/certs/{{ hostname }}.crt"
16+
certificate_bundle_server_key: "{{ certificates_ca_directory }}/private/{{ hostname }}.key"
17+
certificate_bundle_client_certificate: "{{ certificates_ca_directory }}/certs/{{ hostname }}-client.crt"
18+
certificate_bundle_client_key: "{{ certificates_ca_directory }}/private/{{ hostname }}-client.key"
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
- name: Create temporary directory
3+
ansible.builtin.tempfile:
4+
state: directory
5+
suffix: certificate-build
6+
register: build_directory
7+
8+
- name: Create directory structure
9+
ansible.builtin.file:
10+
state: directory
11+
path: "{{ build_directory.path }}/ssl-build/{{ certificate_bundle_hostname }}"
12+
mode: '0755'
13+
14+
- name: Copy CA certificate
15+
ansible.builtin.copy:
16+
src: "{{ certificate_bundle_ca_certificate }}"
17+
dest: "{{ build_directory.path }}/ssl-build/{{ item }}"
18+
remote_src: true
19+
mode: '0444'
20+
loop:
21+
- katello-server-ca.crt
22+
- katello-default-ca.crt
23+
24+
- name: Copy server certificate
25+
ansible.builtin.copy:
26+
src: "{{ certificate_bundle_server_certificate }}"
27+
dest: "{{ build_directory.path }}/ssl-build/{{ certificate_bundle_hostname }}/{{ certificate_bundle_hostname }}-{{ item }}"
28+
remote_src: true
29+
mode: '0444'
30+
loop:
31+
- apache.crt
32+
- foreman-proxy.crt
33+
34+
- name: Copy server key
35+
ansible.builtin.copy:
36+
src: "{{ certificate_bundle_server_key }}"
37+
dest: "{{ build_directory.path }}/ssl-build/{{ certificate_bundle_hostname }}/{{ certificate_bundle_hostname }}-{{ item }}"
38+
remote_src: true
39+
mode: '0440'
40+
loop:
41+
- apache.key
42+
- foreman-proxy.key
43+
44+
- name: Copy client certificate
45+
ansible.builtin.copy:
46+
src: "{{ certificate_bundle_client_certificate }}"
47+
dest: "{{ build_directory.path }}/ssl-build/{{ certificate_bundle_hostname }}/{{ certificate_bundle_hostname }}-{{ item }}"
48+
remote_src: true
49+
mode: '0444'
50+
loop:
51+
- foreman-proxy-client.crt
52+
- puppet-client.crt
53+
54+
- name: Copy client key
55+
ansible.builtin.copy:
56+
src: "{{ certificate_bundle_client_key }}"
57+
dest: "{{ build_directory.path }}/ssl-build/{{ certificate_bundle_hostname }}/{{ certificate_bundle_hostname }}-{{ item }}"
58+
remote_src: true
59+
mode: '0440'
60+
loop:
61+
- foreman-proxy-client.key
62+
- puppet-client.key
63+
64+
- name: Create tarball
65+
community.general.archive:
66+
path: "{{ build_directory.path }}/ssl-build"
67+
dest: "/root/{{ certificate_bundle_hostname }}.tar.gz"

0 commit comments

Comments
 (0)