2022-07-25 22:40:22 +00:00
|
|
|
---
|
|
|
|
- name: Bootstrap Consul values
|
|
|
|
hosts: consul_instances
|
|
|
|
gather_facts: false
|
|
|
|
|
|
|
|
vars_files:
|
2022-11-02 21:20:09 +00:00
|
|
|
- vars/consul_values.yml
|
2022-07-25 22:40:22 +00:00
|
|
|
|
2022-07-27 18:11:03 +00:00
|
|
|
tasks:
|
2022-07-25 22:40:22 +00:00
|
|
|
- name: Add values
|
|
|
|
delegate_to: localhost
|
|
|
|
run_once: true
|
|
|
|
block:
|
|
|
|
- name: Install python-consul
|
|
|
|
pip:
|
|
|
|
name: python-consul
|
|
|
|
extra_args: --index-url https://pypi.org/simple
|
|
|
|
|
|
|
|
- name: Write values
|
|
|
|
consul_kv:
|
|
|
|
host: "{{ inventory_hostname }}"
|
|
|
|
key: "{{ item.key }}"
|
|
|
|
value: "{{ item.value }}"
|
|
|
|
loop: "{{ consul_values | default({}) | dict2items }}"
|
|
|
|
|
|
|
|
- name: Bootstrap value values
|
|
|
|
hosts: vault_instances
|
|
|
|
gather_facts: false
|
|
|
|
|
|
|
|
vars_files:
|
2022-11-02 21:20:09 +00:00
|
|
|
- vars/vault_hashi_vault_values.yml
|
2022-07-25 22:40:22 +00:00
|
|
|
|
|
|
|
tasks:
|
|
|
|
- name: Bootstrap Vault secrets
|
|
|
|
delegate_to: localhost
|
|
|
|
run_once: true
|
|
|
|
block:
|
|
|
|
- name: Install hvac
|
|
|
|
pip:
|
|
|
|
name: hvac
|
|
|
|
extra_args: --index-url https://pypi.org/simple
|
|
|
|
|
2022-09-28 04:59:37 +00:00
|
|
|
- name: Check mount
|
|
|
|
community.hashi_vault.vault_read:
|
|
|
|
url: "http://{{ inventory_hostname }}:8200"
|
|
|
|
token: "{{ root_token }}"
|
|
|
|
path: "/sys/mounts/kv"
|
|
|
|
ignore_errors: true
|
|
|
|
register: check_mount
|
|
|
|
|
|
|
|
- name: Create kv mount
|
|
|
|
community.hashi_vault.vault_write:
|
|
|
|
url: "http://{{ inventory_hostname }}:8200"
|
|
|
|
token: "{{ root_token }}"
|
|
|
|
path: "/sys/mounts/kv"
|
|
|
|
data:
|
|
|
|
type: kv-v2
|
|
|
|
when: check_mount is not succeeded
|
|
|
|
|
2022-07-25 22:40:22 +00:00
|
|
|
- name: Write values
|
2022-07-27 18:11:03 +00:00
|
|
|
no_log: true
|
2022-07-25 22:40:22 +00:00
|
|
|
community.hashi_vault.vault_write:
|
|
|
|
url: "http://{{ inventory_hostname }}:8200"
|
|
|
|
token: "{{ root_token }}"
|
|
|
|
path: "kv/data/{{ item.key }}"
|
|
|
|
data:
|
|
|
|
data:
|
|
|
|
"{{ item.value }}"
|
|
|
|
loop: "{{ hashi_vault_values | default({}) | dict2items }}"
|
2022-09-28 04:59:37 +00:00
|
|
|
retries: 2
|
2022-10-27 21:28:34 +00:00
|
|
|
delay: 10
|
2022-07-27 03:09:52 +00:00
|
|
|
|
|
|
|
- name: Write userpass
|
2022-07-27 18:11:03 +00:00
|
|
|
no_log: true
|
2022-07-27 03:09:52 +00:00
|
|
|
community.hashi_vault.vault_write:
|
|
|
|
url: "http://{{ inventory_hostname }}:8200"
|
|
|
|
token: "{{ root_token }}"
|
|
|
|
path: "auth/userpass/users/{{ item.name }}"
|
|
|
|
data: '{"password": "{{ item.password }}", "policies": "{{ item.policies }}"}'
|
|
|
|
loop: "{{ vault_userpass }}"
|