Skip to content
Health check module for Ansible.
Branch: master
Clone or download
nadavsr Merge pull request #2 from robbwagoner/readme_typo
fix delay_between_tries parameter typo in README
Latest commit 74f3860 Dec 31, 2014
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE Initial commit May 17, 2014 fix delay_between_tries parameter typo in README Dec 31, 2014
health_check Fix typo to 'library' as per ansible docs. Jun 19, 2014

Ansible health check module.

This module checks that an HTTP server is reachable and responding as expected.


Sends multiple HTTP requests to a URL until the expected response is received. The number of retries, the delay between retries as well as the expected response are configurable.


Install this module by placing the file health_check in a directory named library under your playbook or role directory.


parameter required default comments
url yes URLs to perform health checks on.
headers no Dictionary of HTTP headers to send in the request.
initial_delay no 0 Number of seconds to wait before sending the first request.
delay_between_tries no 5 Number of seconds to wait between tries.
max_retries no 10 Number of times to try before giving up.
timeout no 10 Number of seconds to wait for a response for each request. If a response is not received within this number of second, the attempt is considered to be a failure.
expected_status no 200 Expected HTTP status code. If the server responds with a different status code, then the attempt is considered to be a failure.
expected_regexp no An optional regular expectation that can be used to validate the response from the server. If the response body does not match the regular expression the attempt is considered as failed. Note that the regular expression tries to match from the beginning of the response. If you want to search anywhere within the response body use an expression like ".*OK"


# Performs a health check for a remote server from the machine running the
# play.

- name: Wait for server to pass health-checks
    url: "http://{{ inventory_name }}"

# Runs a health check for an HTTP server running on the current host.
# passes an Host header to reach the virtual host we want to test.

- name: Wait for API to pass health-check
    url: ""
    delay_between_tries: 5
    max_retries: 20
    expected_regexp: "ok"
You can’t perform that action at this time.