You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.7 KiB

  1. ---
  2. - name: bootstrap/start_vault_temp | Ensure vault-temp isn't already running
  3. shell: if docker rm -f {{ vault_temp_container_name }} 2>&1 1>/dev/null;then echo true;else echo false;fi
  4. register: vault_temp_stop_check
  5. changed_when: "{{ 'true' in vault_temp_stop_check.stdout }}"
  6. - name: bootstrap/start_vault_temp | Start single node Vault with file backend
  7. command: >
  8. docker run -d --cap-add=IPC_LOCK --name {{ vault_temp_container_name }}
  9. -p {{ vault_port }}:{{ vault_port }}
  10. -e 'VAULT_LOCAL_CONFIG={{ vault_temp_config|to_json }}'
  11. -v /etc/vault:/etc/vault
  12. {{ vault_image_repo }}:{{ vault_version }} server
  13. - name: bootstrap/start_vault_temp | Initialize vault-temp
  14. uri:
  15. url: "http://localhost:{{ vault_port }}/v1/sys/init"
  16. headers: "{{ vault_client_headers }}"
  17. method: PUT
  18. body_format: json
  19. body:
  20. secret_shares: 1
  21. secret_threshold: 1
  22. register: vault_temp_init
  23. # NOTE: vault_headers and vault_url are used by subsequent issue calls
  24. - name: bootstrap/start_vault_temp | Set needed vault facts
  25. set_fact:
  26. vault_leader_url: "http://{{ inventory_hostname }}:{{ vault_port }}"
  27. vault_temp_unseal_keys: "{{ vault_temp_init.json['keys'] }}"
  28. vault_temp_root_token: "{{ vault_temp_init.json.root_token }}"
  29. vault_headers: "{{ vault_client_headers|combine({'X-Vault-Token': vault_temp_init.json.root_token}) }}"
  30. - name: bootstrap/start_vault_temp | Unseal vault-temp
  31. uri:
  32. url: "http://localhost:{{ vault_port }}/v1/sys/unseal"
  33. headers: "{{ vault_headers }}"
  34. method: POST
  35. body_format: json
  36. body:
  37. key: "{{ item }}"
  38. with_items: "{{ vault_temp_unseal_keys|default([]) }}"