Skip to content

Commit 896243b

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

File tree

3 files changed

+101
-0
lines changed

3 files changed

+101
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
- name: Generate a certificate bundle for a hostname
3+
hosts:
4+
- quadlet
5+
become: true
6+
vars:
7+
certificates_ca: false
8+
certificates_hostnames:
9+
- "{{ hostname }}"
10+
certificate_source: default
11+
roles:
12+
- role: certificates
13+
when: "certificate_source == 'default'"
14+
- role: foreman_installer_certs
15+
when: "certificate_source == 'installer'"
16+
- role: certificate_bundle
17+
vars:
18+
certificate_bundle_hostname: "{{ hostname }}"
19+
certificate_bundle_ca_certificate: "{{ certificates_ca_directory }}/certs/ca.crt"
20+
certificate_bundle_server_certificate: "{{ certificates_ca_directory }}/certs/{{ hostname }}.crt"
21+
certificate_bundle_server_key: "{{ certificates_ca_directory }}/private/{{ hostname }}.key"
22+
certificate_bundle_client_certificate: "{{ certificates_ca_directory }}/certs/{{ hostname }}-client.crt"
23+
certificate_bundle_client_key: "{{ certificates_ca_directory }}/private/{{ hostname }}-client.key"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
help: |
3+
Generate a certificate bundle
4+
5+
variables:
6+
hostname:
7+
parameter: hostname
8+
help: Hostname to generate a certificate bundle for that will be the common name.
9+
certificate_source:
10+
help: What certificate source is being used.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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"
68+
mode: '0640'

0 commit comments

Comments
 (0)