Last active
August 27, 2015 23:07
-
-
Save denzuko/9a39094b7ad0fcfd02b2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
163: ==> default: ^M | |
164: ==> default: TASK: [(feature) Monitor Cluster Health and send email on poor health] ******** ^M | |
165: ==> default: fatal: [localhost] => error while evaluating conditional: payload.status == 200^M | |
166: ==> default: ^M | |
167: ==> default: FATAL: all hosts have already failed -- aborting^M | |
168: ==> default: ^M | |
169: ==> default: PLAY RECAP ******************************************************************** ^M | |
170: ==> default: to retry, use: --limit @/root/provisioning.retry^M | |
171: ==> default: ^M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"trigger": { | |
"schedule": { "interval": "10s" } | |
}, | |
"input": { | |
"http": { | |
"request": { | |
"host": "localhost", | |
"port": "{{ es_http_port }}", | |
"path": "/_cluster/health" | |
} | |
} | |
}, | |
"condition": { | |
"compare": { | |
"ctx.payload.status": { | |
"eq": "red" | |
} | |
} | |
}, | |
"actions": { | |
"send_email": { | |
"email": { | |
"to": "{{ alert_email }}", | |
"subject": "{{ alert_subject }}", | |
"body": "Cluster is in poor health." | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
cluster_health_watch_body: "{{ lookup('template', 'templates/cluster_health_watch.json.j2') }}" | |
es_http_port: 9200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- hosts: all | |
tasks: | |
- name: (feature) Monitor Cluster Health and send email on poor health | |
uri: | |
url: http://localhost:{{ es_http_port }}/_watcher/watch/cluster_health_watch | |
method: PUT | |
user: "{{ es_admin }}" | |
password: "{{ es_adminpw }}" | |
HEADER_Content-Type: "application/json" | |
return_content: yes | |
body_format: json | |
body: "{{ cluster_health_watch_body | to_json }}" | |
status_code: 200,201 | |
register: payload | |
failed_when: | |
- payload.status != 201 | |
- payload.status != 200 | |
changed_when: payload.content.find("created") == "true" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* edited for content ..., */ | |
{ | |
"created": "true" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment