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:
|
2018-07-02 20:37:37 +08:00
|
|
|
url: "{{ vault_etcd_url.split(',') | first }}/health"
|
2017-02-09 05:41:36 +08:00
|
|
|
validate_certs: no
|
2018-05-12 00:11:38 +08:00
|
|
|
client_cert: "{{ etcd_cert_dir }}/node-{{ inventory_hostname }}.pem"
|
|
|
|
client_key: "{{ etcd_cert_dir }}/node-{{ inventory_hostname }}-key.pem"
|
|
|
|
|
2017-10-24 23:10:56 +08:00
|
|
|
return_content: yes
|
2017-08-18 20:09:45 +08:00
|
|
|
until: vault_etcd_health_check.status == 200 or vault_etcd_health_check.status == 401
|
2018-05-12 00:11:38 +08:00
|
|
|
retries: 3
|
2017-08-18 20:09:45 +08:00
|
|
|
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:
|
2017-10-24 23:10:56 +08:00
|
|
|
vault_etcd_available: "{{ vault_etcd_health_check.content }}"
|
|
|
|
- set_fact:
|
|
|
|
vault_etcd_available: "{{ vault_etcd_available.health|d()|bool }}"
|
2017-02-09 05:41:36 +08:00
|
|
|
|
|
|
|
- name: check_etcd | Fail if etcd is not available and needed
|
|
|
|
fail:
|
|
|
|
msg: >
|
|
|
|
Unable to start Vault cluster! Etcd is not available at
|
2018-07-02 20:37:37 +08:00
|
|
|
{{ vault_etcd_url.split(',') | first }} however it is needed by Vault as a backend.
|
2017-02-09 05:41:36 +08:00
|
|
|
when: vault_etcd_needed|d() and not vault_etcd_available
|