Skip to content

Commit 27410af

Browse files
committed
feat: add playbook for generating pulp cert with OpenBao
1 parent 3ebdcbc commit 27410af

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
- name: Generate certificates
3+
hosts: seed
4+
run_once: true
5+
vars:
6+
openbao_api_addr: http://127.0.0.1:8200
7+
openbao_intermediate_ca_name: OS-TLS-INT
8+
tasks:
9+
- name: Include OpenBao keys
10+
ansible.builtin.include_vars:
11+
file: "{{ kayobe_env_config_path }}/openbao/seed-openbao-keys.json"
12+
name: openbao_keys
13+
14+
- name: Issue a certificate Pulp
15+
hashivault_pki_cert_issue: # noqa: fqcn
16+
url: "{{ openbao_api_addr }}"
17+
ca_cert: "{{ '/etc/pki/tls/certs/ca-bundle.crt' if ansible_facts.os_family == 'RedHat' else '/usr/local/share/ca-certificates/OS-TLS-ROOT.crt' }}"
18+
token: "{{ openbao_keys.root_token }}"
19+
mount_point: "{{ openbao_intermediate_ca_name }}"
20+
role: "{{ overcloud_openbao_pki_default_role_name }}"
21+
common_name: "{{ inventory_hostname }}"
22+
extra_params:
23+
ip_sans: "{{ admin_oc_net_name | net_ip(inventory_hostname=groups['seed'][0]) }}"
24+
register: pulp_certificate
25+
26+
- name: Ensure pulp certificates directory exists
27+
ansible.builtin.file:
28+
path: "{{ kayobe_env_config_path }}/pulp/certificates"
29+
state: directory
30+
delegate_to: localhost
31+
32+
- name: Write certificate to file
33+
no_log: true
34+
ansible.builtin.copy:
35+
dest: "{{ kayobe_env_config_path }}/pulp/certificates/pulp.crt"
36+
content: |
37+
{{ pulp_certificate.data.certificate }}
38+
{{ pulp_certificate.data.issuing_ca }}
39+
mode: "0600"
40+
delegate_to: localhost
41+
42+
- name: Write key to file
43+
no_log: true
44+
ansible.builtin.copy:
45+
dest: "{{ kayobe_env_config_path }}/pulp/certificates/pulp.key"
46+
content: |
47+
{{ pulp_certificate.data.private_key }}
48+
mode: "0600"
49+
delegate_to: localhost

0 commit comments

Comments
 (0)