consul_agent_check
Add, modify, and delete checks within a Consul cluster
Collection: community.general
Full Name: community.general.consul_agent_check
Synopsis
Add, modify, and delete checks within a Consul cluster
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| args | list | Specifies command arguments to run to update the status of the check. Requires O(interval) to be provided. Mutually exclusive with O(ttl), O(tcp) and O(http). | ||
| ca_path | string | Target PEM CA bundle path. | ||
| host | string | localhost | Consul agent hostname. | |
| http | string | Checks can be registered with an HTTP endpoint. This means that Consul checks that the HTTP endpoint returns a successful HTTP status. Requires O(interval) to be provided. Mutually exclusive with O(args), O(ttl) and O(tcp). | ||
| id | string | Specifies a unique ID for this check on the node. This defaults to the O(name) parameter, but it may be necessary to provide an ID for uniqueness. This value is returned in the response as V(CheckId). | ||
| interval | string | The interval at which the service check is run. This is a number with a V(s) or V(m) suffix to signify the units of seconds or minutes, for example V(15s) or V(1m). If no suffix is supplied V(s) is used by default, for example V(10) is equivalent to V(10s). Required if one of the parameters O(args), O(http), or O(tcp) is specified. | ||
| name | string | Required name for the service check. | ||
| notes | string | Notes to attach to check when registering it. | ||
| port | int | 8500 | Consul agent HTTP port. | |
| scheme | string | http | HTTP or HTTPS protocol. | |
| service_id | string | The ID for the service, must be unique per node. If O(state=absent), defaults to the service name if supplied. | ||
| state | string | present | Whether the check should be present or absent. | |
| tcp | string | Checks can be registered with a TCP port. This means that Consul will check if the connection attempt to that port is successful (that is, the port is currently accepting connections). The format is V(host:port), for example V(localhost:80). Requires O(interval) to be provided. Mutually exclusive with O(args), O(ttl) and O(http). | ||
| timeout | string | A custom HTTP check timeout. The Consul default is 10 seconds. Similar to the interval this is a number with a V(s) or V(m) suffix to signify the units of seconds or minutes, for example V(15s) or V(1m). If no suffix is supplied V(s) is used by default, for example V(10) is equivalent to V(10s). | ||
| token | string | Consul ACL token; private argument. | ||
| ttl | string | Checks can be registered with a TTL instead of a O(args) and O(interval) this means that the service checks in with the agent before the TTL expires. If it does not the check is considered failed. Required if registering a check and the script an interval are missing Similar to the interval this is a number with a V(s) or V(m) suffix to signify the units of seconds or minutes, for example V(15s) or V(1m). If no suffix is supplied V(s) is used by default, for example V(10) is equivalent to V(10s). Mutually exclusive with O(args), O(tcp) and O(http). | ||
| validate_certs | bool | true | Validate the server certificate. |
Example
yaml
- community.general.consul_agent_check:
interval: 60s
name: nginx_tcp_check
notes: Nginx Check
service_id: nginx
tcp: localhost:80
name: Register tcp check for service 'nginx'
- community.general.consul_agent_check:
http: http://localhost:80/status
interval: 60s
name: nginx_http_check
notes: Nginx Check
service_id: nginx
name: Register http check for service 'nginx'
- community.general.consul_agent_check:
id: nginx_http_check
service_id: '{{ nginx_service.ID }}'
state: absent
name: Remove check for service 'nginx'