2017-02-09 05:41:36 +08:00
|
|
|
---
|
|
|
|
|
2017-08-18 20:09:45 +08:00
|
|
|
- name: check_etcd | Check if etcd is up and reachable
|
2017-02-09 05:41:36 +08:00
|
|
|
uri:
|
|
|
|
url: "{{ vault_etcd_url }}/health"
|
|
|
|
validate_certs: no
|
2017-08-18 20:09:45 +08:00
|
|
|
until: vault_etcd_health_check.status == 200 or vault_etcd_health_check.status == 401
|
|
|
|
retries: 10
|
|
|
|
delay: 2
|
|
|
|
delegate_to: "{{groups['etcd'][0]}}"
|
|
|
|
run_once: true
|
2017-02-09 05:41:36 +08:00
|
|
|
failed_when: false
|
|
|
|
register: vault_etcd_health_check
|
|
|
|
|
|
|
|
- name: check_etcd | Set fact based off the etcd_health_check response
|
|
|
|
set_fact:
|
|
|
|
vault_etcd_available: "{{ vault_etcd_health_check.get('json', {}).get('health')|bool }}"
|
|
|
|
|
|
|
|
- name: check_etcd | Fail if etcd is not available and needed
|
|
|
|
fail:
|
|
|
|
msg: >
|
|
|
|
Unable to start Vault cluster! Etcd is not available at
|
|
|
|
{{ vault_etcd_url }} however it is needed by Vault as a backend.
|
|
|
|
when: vault_etcd_needed|d() and not vault_etcd_available
|