Skip to content

PKI: Fix intermediate certificate idempotency #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions roles/vault_pki/tasks/intermediate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
{{ intermediate_ca_csr_signed.data.issuing_ca }}
when:
- not vault_pki_intermediate_export | bool
- intermediate_ca_csr.changed
- intermediate_ca_csr.data is defined

- name: "Set Exported Intermediate as signed"
hashivault_pki_ca_set:
Expand All @@ -78,6 +80,8 @@
delegate_to: "{{ vault_pki_write_certificates_host }}"
when:
- vault_pki_write_int_ca_to_file | bool
- intermediate_ca_csr.changed
- intermediate_ca_csr.data is defined

- name: "Write out Intermediate Certs and keys to file"
copy:
Expand Down
20 changes: 16 additions & 4 deletions tests/test_vault.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
vault_unseal_keys: "{{ vault_keys.keys_base64 }}"

- name: Configure PKI - create root/intermediate and generate certificates
include_role:
name: vault_pki
vars:
vault_pki_certificate_subject:
- role: 'ServerCert'
Expand Down Expand Up @@ -68,10 +66,16 @@
vault_pki_write_pem_bundle: false
vault_pki_write_root_ca_to_file: true
vault_token: "{{ vault_keys.root_token }}"
block:
- name: Configure PKI - create root/intermediate and generate certificates
include_role:
name: vault_pki

- name: Configure PKI - create root/intermediate and generate certificates (idempotence test)
include_role:
name: vault_pki

- name: Configure PKI - generate certificate pem bundle
include_role:
name: vault_pki
vars:
vault_pki_certificate_subject:
- role: 'ServerCert'
Expand All @@ -89,6 +93,14 @@
vault_pki_write_certificate_files: true
vault_pki_write_pem_bundle: true
vault_token: "{{ vault_keys.root_token }}"
block:
- name: Configure PKI - generate certificate pem bundle
include_role:
name: vault_pki

- name: Configure PKI - generate certificate pem bundle (idempotence test)
include_role:
name: vault_pki

- name: Validate if certificates exist
stat:
Expand Down