2017-08-30 13:03:22 +00:00
|
|
|
---
|
2018-05-11 16:11:38 +00:00
|
|
|
- name: "bootstrap/gen_ca | Ensure cert_dir {{ gen_ca_cert_dir }} exists on necessary hosts"
|
2017-08-30 13:03:22 +00:00
|
|
|
file:
|
|
|
|
mode: 0755
|
|
|
|
path: "{{ gen_ca_cert_dir }}"
|
|
|
|
state: directory
|
2018-05-11 16:11:38 +00:00
|
|
|
delegate_to: "{{ item }}"
|
|
|
|
with_items: "{{ (groups[gen_ca_copy_group|default('vault')]) | union(groups['vault']) }}"
|
2017-08-30 13:03:22 +00:00
|
|
|
|
|
|
|
- name: "bootstrap/gen_ca | Generate {{ gen_ca_mount_path }} root CA"
|
2018-05-11 16:11:38 +00:00
|
|
|
hashivault_write:
|
|
|
|
url: "{{ vault_leader_url }}"
|
|
|
|
token: "{{ vault_root_token }}"
|
|
|
|
ca_cert: "{{ vault_cert_dir }}/ca.pem"
|
|
|
|
secret: "{{ gen_ca_mount_path }}/root/generate/exported"
|
|
|
|
data: "{{ gen_ca_vault_options }}"
|
2017-08-30 13:03:22 +00:00
|
|
|
run_once: true
|
2018-05-11 16:11:38 +00:00
|
|
|
no_log: true
|
|
|
|
register: vault_ca_gen
|
2017-08-30 13:03:22 +00:00
|
|
|
|
|
|
|
- name: "bootstrap/gen_ca | Copy {{ gen_ca_mount_path }} root CA cert locally"
|
|
|
|
copy:
|
2018-05-11 16:11:38 +00:00
|
|
|
content: "{{ vault_ca_gen['data']['data']['certificate'] }}"
|
2017-08-30 13:03:22 +00:00
|
|
|
dest: "{{ gen_ca_cert_dir }}/ca.pem"
|
|
|
|
mode: 0644
|
2018-05-11 16:11:38 +00:00
|
|
|
when: '"data" in vault_ca_gen.keys()'
|
|
|
|
delegate_to: "{{ item }}"
|
|
|
|
with_items: "{{ (groups[gen_ca_copy_group|default('vault')]) | union(groups['vault']) }}"
|
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:
|
2018-05-11 16:11:38 +00:00
|
|
|
content: "{{ vault_ca_gen['data']['data']['private_key']}}"
|
2017-08-30 13:03:22 +00:00
|
|
|
dest: "{{ gen_ca_cert_dir }}/ca-key.pem"
|
|
|
|
mode: 0640
|
2018-05-11 16:11:38 +00:00
|
|
|
when: '"data" in vault_ca_gen.keys()'
|
2018-04-10 16:55:28 +00:00
|
|
|
delegate_to: "{{ item }}"
|
|
|
|
with_items: "{{ (groups[gen_ca_copy_group|default('vault')]) | union(groups['vault']) }}"
|