feat(variables): start polishing variables for customization
This commit is contained in:
parent
97a4752dbe
commit
878f97244b
@ -5,51 +5,56 @@
|
|||||||
gather_facts: true
|
gather_facts: true
|
||||||
become: true
|
become: true
|
||||||
tasks:
|
tasks:
|
||||||
- name: "Include ednxzu.hashicorp_vault"
|
- name: "Vault"
|
||||||
ansible.builtin.include_role:
|
when: enable_vault | bool
|
||||||
name: ednxzu.hashistack.hashicorp_vault
|
tags:
|
||||||
|
- vault
|
||||||
|
block:
|
||||||
|
- name: "Include ednxzu.hashicorp_vault"
|
||||||
|
ansible.builtin.include_role:
|
||||||
|
name: ednxzu.hashistack.hashicorp_vault
|
||||||
|
|
||||||
- name: "Initialize vault cluster"
|
- name: "Initialize vault cluster"
|
||||||
ednxzu.hashistack.vault_init:
|
ednxzu.hashistack.vault_init:
|
||||||
api_url: "http://127.0.0.1:8200"
|
api_url: "http://127.0.0.1:8200"
|
||||||
key_shares: 3
|
key_shares: 3
|
||||||
key_threshold: 2
|
key_threshold: 2
|
||||||
run_once: true
|
run_once: true
|
||||||
retries: 5
|
retries: 5
|
||||||
delay: 5
|
delay: 5
|
||||||
delegate_to: "{{ groups['vault_servers'] | first }}"
|
delegate_to: "{{ groups['vault_servers'] | first }}"
|
||||||
register: _vault_init_secret
|
register: _vault_init_secret
|
||||||
until: not _vault_init_secret.failed
|
until: not _vault_init_secret.failed
|
||||||
|
|
||||||
- name: "Write vault configuration to file"
|
- name: "Write vault configuration to file"
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
content: "{{ _vault_init_secret.state | to_nice_yaml}}"
|
content: "{{ _vault_init_secret.state | to_nice_yaml}}"
|
||||||
dest: "{{ configuration_directory }}/vault/vault_config"
|
dest: "{{ configuration_directory }}/vault/vault_config"
|
||||||
mode: '0644'
|
mode: '0644'
|
||||||
when: _vault_init_secret.changed
|
when: _vault_init_secret.changed
|
||||||
run_once: true
|
run_once: true
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
|
|
||||||
- name: "Load vault cluster variables necessary for unseal operation"
|
- name: "Load vault cluster variables necessary for unseal operation"
|
||||||
ansible.builtin.include_vars:
|
ansible.builtin.include_vars:
|
||||||
file: "{{ configuration_directory }}/vault/vault_config"
|
file: "{{ configuration_directory }}/vault/vault_config"
|
||||||
name: _vault_cluster_config
|
name: _vault_cluster_config
|
||||||
|
|
||||||
- name: "Unseal the bootstrap node"
|
- name: "Unseal the bootstrap node"
|
||||||
ednxzu.hashistack.vault_unseal:
|
ednxzu.hashistack.vault_unseal:
|
||||||
api_url: "http://127.0.0.1:8200"
|
api_url: "http://127.0.0.1:8200"
|
||||||
key_shares: "{{ _vault_cluster_config['keys'] }}"
|
key_shares: "{{ _vault_cluster_config['keys'] }}"
|
||||||
max_retries: "{{ (_vault_cluster_config['keys'] | length) - 1 }}"
|
max_retries: "{{ (_vault_cluster_config['keys'] | length) - 1 }}"
|
||||||
run_once: true
|
run_once: true
|
||||||
delegate_to: "{{ groups['vault_servers'] | first }}"
|
delegate_to: "{{ groups['vault_servers'] | first }}"
|
||||||
when: _vault_init_secret.changed
|
when: _vault_init_secret.changed
|
||||||
|
|
||||||
- name: "Unseal all vault nodes"
|
- name: "Unseal all vault nodes"
|
||||||
ednxzu.hashistack.vault_unseal:
|
ednxzu.hashistack.vault_unseal:
|
||||||
api_url: "http://127.0.0.1:8200"
|
api_url: "http://127.0.0.1:8200"
|
||||||
key_shares: "{{ _vault_cluster_config['keys'] }}"
|
key_shares: "{{ _vault_cluster_config['keys'] }}"
|
||||||
max_retries: "{{ (_vault_cluster_config['keys'] | length) - 1 }}"
|
max_retries: "{{ (_vault_cluster_config['keys'] | length) - 1 }}"
|
||||||
retries: 5
|
retries: 5
|
||||||
delay: 5
|
delay: 5
|
||||||
register: _unseal_status
|
register: _unseal_status
|
||||||
until: not _unseal_status.failed
|
until: not _unseal_status.failed
|
||||||
|
@ -7,11 +7,12 @@ enable_vault: "yes"
|
|||||||
enable_consul: "yes"
|
enable_consul: "yes"
|
||||||
enable_nomad: "yes"
|
enable_nomad: "yes"
|
||||||
|
|
||||||
deployment_method: "docker"
|
deployment_method: "host"
|
||||||
api_interface: "eth0"
|
api_interface: "eth0"
|
||||||
api_interface_address: "{{ ansible_facts[api_interface]['ipv4']['address'] }}"
|
api_interface_address: "{{ ansible_facts[api_interface]['ipv4']['address'] }}"
|
||||||
|
|
||||||
configuration_directory: "{{ lookup('env', 'PWD') }}/etc/hashistack"
|
configuration_directory: "{{ lookup('env', 'PWD') }}/etc/hashistack"
|
||||||
|
configuration_global_vars_file: "globals.yml"
|
||||||
|
|
||||||
##########################
|
##########################
|
||||||
# Support options ########
|
# Support options ########
|
||||||
@ -93,7 +94,7 @@ default_container_extra_volumes:
|
|||||||
- "/etc/localtime:/etc/localtime"
|
- "/etc/localtime:/etc/localtime"
|
||||||
|
|
||||||
hashi_vault_start_service: true
|
hashi_vault_start_service: true
|
||||||
hashi_vault_version: "1.15.2"
|
hashi_vault_version: latest
|
||||||
hashi_vault_deploy_method: "{{ deployment_method }}" # deployment method, either host or docker
|
hashi_vault_deploy_method: "{{ deployment_method }}" # deployment method, either host or docker
|
||||||
hashi_vault_env_variables: {}
|
hashi_vault_env_variables: {}
|
||||||
hashi_vault_data_dir: "/opt/vault"
|
hashi_vault_data_dir: "/opt/vault"
|
||||||
|
21
playbooks/load_vars.yml
Normal file
21
playbooks/load_vars.yml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
---
|
||||||
|
# hashistack variable injection playbook
|
||||||
|
- name: "Deploy"
|
||||||
|
hosts: all
|
||||||
|
gather_facts: true
|
||||||
|
become: true
|
||||||
|
tasks:
|
||||||
|
- name: "Load global variables"
|
||||||
|
ansible.builtin.include_vars:
|
||||||
|
dir: "{{ configuration_directory }}"
|
||||||
|
files_matching: "{{ configuration_global_vars_file }}"
|
||||||
|
|
||||||
|
- name: "Load group specific variables"
|
||||||
|
ansible.builtin.include_vars:
|
||||||
|
dir: ""
|
||||||
|
files_matching: ""
|
||||||
|
|
||||||
|
- name: "Load host specific variables"
|
||||||
|
ansible.builtin.include_vars:
|
||||||
|
dir: ""
|
||||||
|
files_matching: ""
|
Loading…
Reference in New Issue
Block a user