PARALLAX

consul

Add, modify & delete services within a Consul cluster

Collection: community.general

Full Name: community.general.consul

Synopsis

Add, modify & delete services within a Consul cluster

Parameters

NameTypeRequiredDefaultDescription
check_hoststringHost name.
check_idstringAn ID for the service check. If O(state=absent), defaults to O(check_name). Ignored if part of a service definition.
check_namestringName for the service check. Required if standalone, ignored if part of service definition.
check_nodestringNode name.
hoststringlocalhostHost of the Consul agent defaults to localhost.
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(script), O(ttl) and O(tcp).
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 V(10s). Required if one of the parameters O(script), O(http), or O(tcp) is specified.
notesstringNotes to attach to check when registering it.
portint8500The port on which the Consul agent is running.
schemestringhttpThe protocol scheme on which the Consul agent is running.
scriptstringThe script/command that is run periodically to check the health of the service. Requires O(interval) to be provided. Mutually exclusive with O(ttl), O(tcp) and O(http).
service_addressstringThe address to advertise that the service is listening on. This value is passed as the C(address) parameter to Consul’s C(/v1/agent/service/register) API method, so refer to the Consul API documentation for further details.
service_idstringThe ID for the service, must be unique per node. If O(state=absent), defaults to the service name if supplied.
service_namestringUnique 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_portintThe port on which the service is listening. Can optionally be supplied for registration of a service, that is if O(service_name) or O(service_id) is set.
statestringpresentRegister or deregister the Consul service, defaults to present.
tagslistTags that are attached to the service registration.
tcpstringChecks can be registered with a TCP port. This means that Consul checks 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(script), 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).
tokenstringThe token key identifying an ACL rule set. May be required to register services.
ttlstringChecks can be registered with a TTL instead of a O(script) 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(script), O(tcp) and O(http).
validate_certsbooltrueWhether to verify the TLS certificate of the Consul agent.

Example

yaml
- community.general.consul:
    service_name: nginx
    service_port: 80
  name: Register nginx service with the local Consul agent

- community.general.consul:
    interval: 60s
    script: curl http://localhost
    service_name: nginx
    service_port: 80
  name: Register nginx service with curl check

- community.general.consul:
    interval: 60s
    service_name: nginx
    service_port: 80
    tcp: localhost:80
  name: register nginx with a tcp check

- community.general.consul:
    http: http://localhost:80/status
    interval: 60s
    service_name: nginx
    service_port: 80
  name: Register nginx with an http check

- community.general.consul:
    service_address: 10.1.5.23
    service_name: nginx
    service_port: 80
  name: Register external service nginx available at 10.1.5.23

- community.general.consul:
    service_name: nginx
    service_port: 80
    tags:
        - prod
        - webservers
  name: Register nginx with some service tags

- community.general.consul:
    service_name: nginx
    state: absent
  name: Remove nginx service

- community.general.consul:
    service_name: celery-worker
    tags:
        - prod
        - worker
  name: Register celery worker service
Search
    ↑ ↓ move↵ openesc close