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.

46 lines
1.9 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. # FIXME(mattymo): Crashes on first start with aufs docker storage. See hashicorp/docker-vault#19
  14. - name: bootstrap/start_vault_temp | Start again single node Vault with file backend
  15. command: docker start {{ vault_temp_container_name }}
  16. - name: bootstrap/start_vault_temp | Initialize vault-temp
  17. uri:
  18. url: "http://localhost:{{ vault_port }}/v1/sys/init"
  19. headers: "{{ vault_client_headers }}"
  20. method: PUT
  21. body_format: json
  22. body:
  23. secret_shares: 1
  24. secret_threshold: 1
  25. register: vault_temp_init
  26. # NOTE: vault_headers and vault_url are used by subsequent issue calls
  27. - name: bootstrap/start_vault_temp | Set needed vault facts
  28. set_fact:
  29. vault_leader_url: "http://{{ inventory_hostname }}:{{ vault_port }}"
  30. vault_temp_unseal_keys: "{{ vault_temp_init.json['keys'] }}"
  31. vault_temp_root_token: "{{ vault_temp_init.json.root_token }}"
  32. vault_headers: "{{ vault_client_headers|combine({'X-Vault-Token': vault_temp_init.json.root_token}) }}"
  33. - name: bootstrap/start_vault_temp | Unseal vault-temp
  34. uri:
  35. url: "http://localhost:{{ vault_port }}/v1/sys/unseal"
  36. headers: "{{ vault_headers }}"
  37. method: POST
  38. body_format: json
  39. body:
  40. key: "{{ item }}"
  41. with_items: "{{ vault_temp_unseal_keys|default([]) }}"