Skip to content

Commit f7e458c

Browse files
committed
Add playbook for updating Vault API TLS certificate
Unlike ``vault-deploy-seed.yml`` playbook, this playbook only updates ``overcloud.crt`` and ``overcloud.key`` which are used as Vault API TLS certificate.
1 parent bc562dd commit f7e458c

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
---
2+
- name: Update Overcloud Vault API certificate
3+
any_errors_fatal: true
4+
gather_facts: true
5+
hosts: seed
6+
vars:
7+
consul_bind_interface: "lo"
8+
vault_bind_address: "{{ ansible_facts[consul_bind_interface].ipv4.address }}"
9+
vault_api_addr: "http://{{ vault_bind_address }}:8200"
10+
tasks:
11+
- name: Set a fact about the virtualenv on the remote system
12+
set_fact:
13+
virtualenv: "{{ ansible_python_interpreter | dirname | dirname }}"
14+
when:
15+
- ansible_python_interpreter is defined
16+
- not ansible_python_interpreter.startswith('/bin/')
17+
- not ansible_python_interpreter.startswith('/usr/bin/')
18+
19+
- name: Ensure Python PyYAML and hvac modules are installed
20+
pip:
21+
name:
22+
- PyYAML
23+
- hvac
24+
state: latest
25+
extra_args: "{% if pip_upper_constraints_file %}-c {{ pip_upper_constraints_file }}{% endif %}"
26+
virtualenv: "{{ virtualenv is defined | ternary(virtualenv, omit) }}"
27+
become: "{{ virtualenv is not defined }}"
28+
29+
- name: Ensure vault directory exists in Kayobe configuration
30+
file:
31+
path: "{{ kayobe_env_config_path }}/vault/"
32+
state: directory
33+
delegate_to: localhost
34+
run_once: true
35+
36+
- name: Include Vault keys
37+
include_vars:
38+
file: "{{ kayobe_env_config_path }}/vault/seed-vault-keys.json"
39+
name: vault_keys
40+
41+
- import_role:
42+
name: stackhpc.hashicorp.vault_pki
43+
vars:
44+
vault_token: "{{ vault_keys.root_token }}"
45+
vault_pki_root_create: false
46+
vault_pki_intermediate_create: false
47+
vault_pki_certificates_directory: "{{ kayobe_env_config_path }}/vault"
48+
vault_pki_generate_certificates: true
49+
vault_pki_write_certificates: true
50+
vault_pki_certificate_subject:
51+
- common_name: "{% if kolla_internal_fqdn != kolla_internal_vip_address %}{{ kolla_internal_fqdn }}{% else %}overcloud{% endif %}"
52+
role: "{{ seed_vault_pki_role_name }}"
53+
extra_params:
54+
ip_sans: "{% for host in groups['controllers'] %}{{ internal_net_name | net_ip(host) }}{% if not loop.last %},{% endif %}{% endfor %},{{ kolla_internal_vip_address }}"
55+
vault_pki_write_certificate_files: true
56+
vault_pki_overwrite_certificates: true
57+
vault_pki_write_pem_bundle: false
58+
59+
- name: Copy new certificate and key to hosts
60+
any_errors_fatal: true
61+
gather_facts: true
62+
hosts: controllers
63+
tasks:
64+
- name: Template out TLS key and cert
65+
copy:
66+
# Within the Hashicorp Vault container these uids & gids map to the vault user
67+
src: "{{ kayobe_env_config_path }}/vault/{{ item }}"
68+
dest: "/opt/kayobe/vault/{{ item }}"
69+
owner: 100
70+
group: 1000
71+
mode: 0600
72+
loop:
73+
- "{% if kolla_internal_fqdn != kolla_internal_vip_address %}{{ kolla_internal_fqdn }}{% else %}overcloud{% endif %}.crt"
74+
- "{% if kolla_internal_fqdn != kolla_internal_vip_address %}{{ kolla_internal_fqdn }}{% else %}overcloud{% endif %}.key"
75+
become: True
76+
77+
- name: Restart Overcloud Vaults
78+
any_errors_fatal: true
79+
gather_facts: true
80+
hosts: controllers
81+
serial: 1
82+
tasks:
83+
community.docker.docker_container:
84+
name: vault
85+
state: started
86+
restart: true
87+
88+
- name: Unseal Overcloud Vaults
89+
import_playbook: "{{ kayobe_config_path }}/ansible/vault-unseal-overcloud.yml"

0 commit comments

Comments
 (0)