2023-05-22 18:23:57 +00:00
|
|
|
---
|
|
|
|
# task/import file for import_vault_root_ca
|
|
|
|
- name: "Download certificate file"
|
|
|
|
ansible.builtin.get_url:
|
|
|
|
url: "{{ item.url }}"
|
|
|
|
validate_certs: false
|
2023-05-24 21:00:18 +00:00
|
|
|
force: "{{ import_vault_root_ca_certificate_force_download }}"
|
2023-07-02 18:32:30 +00:00
|
|
|
dest: "/tmp/{{ item.cert_name }}.tmp"
|
2023-05-24 21:00:18 +00:00
|
|
|
mode: '0644'
|
2023-05-22 18:23:57 +00:00
|
|
|
loop: "{{ import_vault_root_ca_certificate_list }}"
|
2023-09-26 20:46:33 +00:00
|
|
|
register: download_results
|
|
|
|
|
|
|
|
- name: "Check certificate format"
|
|
|
|
ansible.builtin.command: >
|
|
|
|
openssl x509 -inform PEM -noout -in {{ item.dest }}
|
|
|
|
loop: "{{ download_results.results }}"
|
|
|
|
register: cert_format_results
|
|
|
|
changed_when: false
|
|
|
|
failed_when: false
|
2023-05-22 18:23:57 +00:00
|
|
|
|
|
|
|
- name: "Make sure certificate is in PEM format"
|
|
|
|
ansible.builtin.command:
|
2023-09-26 20:46:33 +00:00
|
|
|
cmd: openssl x509 -inform {{ 'PEM' if item.rc == 0 else 'DER' }} -in {{ item.item.dest }} -out {{ import_vault_root_ca_cert_dir }}/{{ item.item.item.cert_name }}.crt -outform pem
|
|
|
|
creates: "{{ import_vault_root_ca_cert_dir }}/{{ item.item.item.cert_name }}.crt"
|
|
|
|
loop: "{{ cert_format_results.results }}"
|
2023-05-22 18:23:57 +00:00
|
|
|
notify:
|
|
|
|
- update-ca-certificates
|