-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vault: Support generating external TLS certificates for testing
These should not generally be used in production, since the CA is self-signed.
- Loading branch information
1 parent
d883f21
commit 22eded5
Showing
3 changed files
with
92 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
--- | ||
- name: Generate external API certificate (for testing only) | ||
hosts: controllers | ||
run_once: true | ||
vars: | ||
vault_api_addr: "https://{{ kolla_internal_fqdn }}:8200" | ||
# NOTE: Using the same CA as internal TLS. | ||
vault_intermediate_ca_name: "OS-TLS-INT" | ||
tasks: | ||
- name: Include Vault keys | ||
include_vars: | ||
file: "{{ kayobe_env_config_path }}/vault/overcloud-vault-keys.json" | ||
name: vault_keys | ||
|
||
- name: Issue a certificate for external TLS | ||
hashivault_pki_cert_issue: | ||
url: "{{ vault_api_addr }}" | ||
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' }}" | ||
token: "{{ vault_keys.root_token }}" | ||
mount_point: "{{ vault_intermediate_ca_name }}" | ||
role: "{{ overcloud_vault_pki_external_tls_role_name }}" | ||
common_name: "{% if kolla_external_fqdn != kolla_external_vip_address %}{{ kolla_external_fqdn }}{% endif %}" | ||
extra_params: | ||
ip_sans: "{{ kolla_external_vip_address }}" | ||
register: external_cert | ||
|
||
- name: Ensure certificates directory exists | ||
file: | ||
path: "{{ kayobe_env_config_path }}/kolla/certificates" | ||
state: directory | ||
delegate_to: localhost | ||
|
||
- name: Ensure CA certificates directory exists | ||
file: | ||
path: "{{ kayobe_env_config_path }}/kolla/certificates/ca" | ||
state: directory | ||
delegate_to: localhost | ||
|
||
- name: Copy external API PEM bundle | ||
no_log: true | ||
copy: | ||
dest: "{{ kayobe_env_config_path }}/kolla/certificates/haproxy.pem" | ||
content: | | ||
{{ external_cert.data.certificate }} | ||
{{ external_cert.data.issuing_ca }} | ||
{{ external_cert.data.private_key }} | ||
mode: 0600 | ||
delegate_to: localhost | ||
|
||
- name: Copy root CA | ||
copy: | ||
src: "{{ kayobe_env_config_path }}/vault/OS-TLS-ROOT.pem" | ||
dest: "{{ kayobe_env_config_path }}/kolla/certificates/ca/vault.crt" | ||
mode: 0600 | ||
delegate_to: localhost |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters