PARALLAX

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

NameTypeRequiredDefaultDescription
argslistSpecifies 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_pathstringTarget PEM CA bundle path.
hoststringlocalhostConsul agent hostname.
httpstringChecks 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).
idstringSpecifies 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).
intervalstringThe 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.
namestringRequired name for the service check.
notesstringNotes to attach to check when registering it.
portint8500Consul agent HTTP port.
schemestringhttpHTTP or HTTPS protocol.
service_idstringThe ID for the service, must be unique per node. If O(state=absent), defaults to the service name if supplied.
statestringpresentWhether the check should be present or absent.
tcpstringChecks 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).
timeoutstringA 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).
tokenstringConsul ACL token; private argument.
ttlstringChecks 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_certsbooltrueValidate 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'
Search
    ↑ ↓ move↵ openesc close