New in version 2.0.
The below requirements are needed on the host that executes this module.
Parameter | Choices/Defaults | Comments |
---|---|---|
check_id | an ID for the service check, defaults to the check name, ignored if part of a service definition. | |
check_name | a name for the service check, defaults to the check id. required if standalone, ignored if part of service definition. | |
host | Default: localhost | host of the consul agent defaults to localhost |
http (added in 2.0) | checks can be registered with an http endpoint. This means that consul will check that the http endpoint returns a successful http status. Interval must also be provided with this option. | |
interval | the interval at which the service check will be run. This is a number with a s or m suffix to signify the units of seconds or minutes e.g 15s or 1m. If no suffix is supplied, m will be used by default e.g. 1 will be 1m. Required if the script param is specified. | |
notes | Notes to attach to check when registering it. | |
port | Default: 8500 | the port on which the consul agent is running |
scheme (added in 2.1) | Default: http | the protocol scheme on which the consul agent is running |
script | the script/command that will be run periodically to check the health of the service. Scripts require an interval and vise versa | |
service_address (added in 2.1) | the address to advertise that the service will be listening on. This value will be passed as the Address parameter to Consul's /v1/agent/service/register API method, so refer to the Consul API documentation for further details. | |
service_id | Default: service_name if supplied | the ID for the service, must be unique per node, defaults to the service name if the service name is supplied |
service_name | Unique name for the service on a node, must be unique per node, required if registering a service. May be omitted if registering a node level check | |
service_port | the port on which the service is listening. Can optionally be supplied for registration of a service, i.e. if service_name or service_id is set | |
state required |
| register or deregister the consul service, defaults to present |
tags | a list of tags that will be attached to the service registration. | |
timeout (added in 2.0) | A custom HTTP check timeout. The consul default is 10 seconds. Similar to the interval this is a number with a s or m suffix to signify the units of seconds or minutes, e.g. 15s or 1m. | |
token | the token key indentifying an ACL rule set. May be required to register services. | |
ttl | checks can be registered with a ttl instead of a script and interval this means that the service will check in with the agent before the ttl expires. If it doesn't the check will be considered failed. Required if registering a check and the script an interval are missing Similar to the interval this is a number with a s or m suffix to signify the units of seconds or minutes e.g 15s or 1m. If no suffix is supplied, m will be used by default e.g. 1 will be 1m | |
validate_certs bool (added in 2.1) |
| whether to verify the tls certificate of the consul agent |
- name: register nginx service with the local consul agent consul: service_name: nginx service_port: 80 - name: register nginx service with curl check consul: service_name: nginx service_port: 80 script: curl http://localhost interval: 60s - name: register nginx with an http check consul: service_name: nginx service_port: 80 interval: 60s http: http://localhost:80/status - name: register external service nginx available at 10.1.5.23 consul: service_name: nginx service_port: 80 service_address: 10.1.5.23 - name: register nginx with some service tags consul: service_name: nginx service_port: 80 tags: - prod - webservers - name: remove nginx service consul: service_name: nginx state: absent - name: register celery worker service consul: service_name: celery-worker tags: - prod - worker - name: create a node level check to test disk usage consul: check_name: Disk usage check_id: disk_usage script: /opt/disk_usage.py interval: 5m - name: register an http check against a service that's already registered consul: check_name: nginx-check2 check_id: nginx-check2 service_id: nginx interval: 60s http: http://localhost:80/morestatus
This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.
This module is flagged as community which means that it is maintained by the Ansible Community. See Module Maintenance & Support for more info.
For a list of other modules that are also maintained by the Ansible Community, see here.
Hint
If you notice any issues in this documentation you can edit this document to improve it.
© 2012–2018 Michael DeHaan
© 2018 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.7/modules/consul_module.html