41 lines
1.6 KiB
YAML
41 lines
1.6 KiB
YAML
---
|
|
|
|
- name: "bootstrap/ca_trust | pull CA from cert from {{groups.vault|first}}"
|
|
command: "cat {{ vault_cert_dir }}/ca.pem"
|
|
register: vault_cert_file_cat
|
|
delegate_to: "{{ groups['vault']|first }}"
|
|
ignore_errors: "{{ vault_existent_crt is defined and vault_existent_key is defined }}"
|
|
|
|
# This part is mostly stolen from the etcd role
|
|
- name: bootstrap/ca_trust | target ca-certificate store file
|
|
set_fact:
|
|
ca_cert_path: >-
|
|
{% if ansible_os_family == "Debian" -%}
|
|
/usr/local/share/ca-certificates/kube-cluster-ca.crt
|
|
{%- elif ansible_os_family == "RedHat" -%}
|
|
/etc/pki/ca-trust/source/anchors/kube-cluster-ca.crt
|
|
{%- elif ansible_os_family in ["CoreOS", "Container Linux by CoreOS"] -%}
|
|
/etc/ssl/certs/kube-cluster-ca.pem
|
|
{%- endif %}
|
|
|
|
- set_fact:
|
|
ca_file_content: "{{ vault_cert_file_cat.get('stdout') }}"
|
|
when: not ( vault_existent_crt is defined and vault_existent_key is defined )
|
|
|
|
- set_fact:
|
|
ca_file_content: "{{ vault_existent_crt }}"
|
|
when: vault_existent_crt is defined and vault_existent_key is defined
|
|
|
|
- name: bootstrap/ca_trust | add CA to trusted CA dir
|
|
copy:
|
|
content: "{{ ca_file_content }}"
|
|
dest: "{{ ca_cert_path }}"
|
|
register: vault_ca_cert
|
|
|
|
- name: bootstrap/ca_trust | update ca-certificates (Debian/Ubuntu/CoreOS)
|
|
command: update-ca-certificates
|
|
when: vault_ca_cert.changed and ansible_os_family in ["Debian", "CoreOS", "Container Linux by CoreOS"]
|
|
|
|
- name: bootstrap/ca_trust | update ca-certificates (RedHat)
|
|
command: update-ca-trust extract
|
|
when: vault_ca_cert.changed and ansible_os_family == "RedHat"
|