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.

50 lines
1.6 KiB

  1. ---
  2. - name: restart vault
  3. command: /bin/true
  4. notify:
  5. - restart vault service
  6. - wait for vault up
  7. - unseal vault
  8. - name: wait for vault up
  9. uri:
  10. url: "{{ vault_leader_url | default('https://localhost:8200') }}/v1/sys/health"
  11. headers: "{{ vault_client_headers }}"
  12. status_code: "{{ vault_successful_http_codes | join(',') }}"
  13. register: vault_health_check
  14. until: vault_health_check is succeeded
  15. retries: 10
  16. delay: "{{ retry_stagger | random + 3 }}"
  17. run_once: yes
  18. notify: set facts about local Vault health
  19. - name: wait for vault up nowait
  20. uri:
  21. url: "{{ vault_leader_url | default('https://localhost:8200') }}/v1/sys/health"
  22. headers: "{{ vault_client_headers }}"
  23. status_code: "{{ vault_successful_http_codes | join(',') }}"
  24. register: vault_health_check
  25. run_once: yes
  26. failed_when: false
  27. notify: set facts about local Vault health
  28. - name: set facts about local Vault health
  29. set_fact:
  30. vault_is_running: "{{ vault_health_check.get('status', '-1') in vault_successful_http_codes }}"
  31. vault_cluster_is_initialized: "{{ vault_health_check.get('json', {}).get('initialized', false) }}"
  32. vault_is_sealed: "{{ vault_health_check.get('json', {}).get('sealed', true) }}"
  33. - name: restart vault service
  34. systemd:
  35. daemon_reload: true
  36. enabled: yes
  37. name: vault
  38. state: restarted
  39. - name: unseal vault
  40. hashivault_unseal:
  41. url: "{{ vault_leader_url | default('https://localhost:8200') }}"
  42. token: "{{ vault_root_token }}"
  43. ca_cert: "{{ vault_cert_dir }}/ca.pem"
  44. keys: "{{ item }}"
  45. with_items: "{{ vault_unseal_keys|default([]) }}"