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.

42 lines
1.8 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 | Start again single node Vault with file backend
  14. command: docker start {{ vault_temp_container_name }}
  15. - name: bootstrap/start_vault_temp | Initialize vault-temp
  16. hashivault_init:
  17. url: "http://localhost:{{ vault_port }}/"
  18. secret_shares: 1
  19. secret_threshold: 1
  20. until: "vault_temp_init|succeeded"
  21. retries: 4
  22. delay: "{{ retry_stagger | random + 3 }}"
  23. register: vault_temp_init
  24. # NOTE: vault_headers and vault_url are used by subsequent issue calls
  25. - name: bootstrap/start_vault_temp | Set needed vault facts
  26. set_fact:
  27. vault_leader_url: "http://{{ inventory_hostname }}:{{ vault_port }}"
  28. vault_temp_unseal_keys: "{{ vault_temp_init.keys_base64 }}"
  29. vault_root_token: "{{ vault_temp_init.root_token }}"
  30. vault_headers: "{{ vault_client_headers|combine({'X-Vault-Token': vault_temp_init.root_token}) }}"
  31. - name: bootstrap/start_vault_temp | Unseal vault-temp
  32. hashivault_unseal:
  33. url: "http://localhost:{{ vault_port }}/"
  34. token: "{{ vault_root_token }}"
  35. keys: "{{ item }}"
  36. with_items: "{{ vault_temp_unseal_keys|default([]) }}"
  37. no_log: true