2017-08-30 13:03:22 +00:00
|
|
|
---
|
|
|
|
- name: "bootstrap/gen_ca | Ensure cert_dir {{ gen_ca_cert_dir }} exists"
|
|
|
|
file:
|
|
|
|
mode: 0755
|
|
|
|
path: "{{ gen_ca_cert_dir }}"
|
|
|
|
state: directory
|
|
|
|
|
|
|
|
- name: "bootstrap/gen_ca | Generate {{ gen_ca_mount_path }} root CA"
|
|
|
|
uri:
|
|
|
|
url: "{{ vault_leader_url }}/v1/{{ gen_ca_mount_path }}/root/generate/exported"
|
2017-09-01 19:51:37 +00:00
|
|
|
headers: "{{ gen_ca_vault_headers }}"
|
2017-08-30 13:03:22 +00:00
|
|
|
method: POST
|
|
|
|
body_format: json
|
2017-09-01 19:51:37 +00:00
|
|
|
body: "{{ gen_ca_vault_options }}"
|
2017-09-13 03:38:11 +00:00
|
|
|
status_code: 200,204
|
2017-08-30 13:03:22 +00:00
|
|
|
register: vault_ca_gen
|
|
|
|
delegate_to: "{{ groups.vault|first }}"
|
|
|
|
run_once: true
|
|
|
|
|
|
|
|
- name: "bootstrap/gen_ca | Copy {{ gen_ca_mount_path }} root CA cert locally"
|
|
|
|
copy:
|
|
|
|
content: "{{ hostvars[groups.vault|first]['vault_ca_gen']['json']['data']['certificate'] }}"
|
|
|
|
dest: "{{ gen_ca_cert_dir }}/ca.pem"
|
|
|
|
mode: 0644
|
2017-09-13 03:38:11 +00:00
|
|
|
when: vault_ca_gen.status == 200
|
2017-08-30 13:03:22 +00:00
|
|
|
|
2018-04-10 16:55:28 +00:00
|
|
|
|
|
|
|
- name: "bootstrap/gen_ca | Copy {{ gen_ca_mount_path }} root CA key to necessary hosts"
|
2017-08-30 13:03:22 +00:00
|
|
|
copy:
|
|
|
|
content: "{{ hostvars[groups.vault|first]['vault_ca_gen']['json']['data']['private_key'] }}"
|
|
|
|
dest: "{{ gen_ca_cert_dir }}/ca-key.pem"
|
|
|
|
mode: 0640
|
2017-09-13 03:38:11 +00:00
|
|
|
when: vault_ca_gen.status == 200
|
2018-04-10 16:55:28 +00:00
|
|
|
delegate_to: "{{ item }}"
|
|
|
|
with_items: "{{ (groups[gen_ca_copy_group|default('vault')]) | union(groups['vault']) }}"
|