PARALLAX

consul_agent_service

Add, modify and delete services within a Consul cluster

Collection: community.general

Full Name: community.general.consul_agent_service

Synopsis

Add, modify and delete services within a Consul cluster

Parameters

NameTypeRequiredDefaultDescription
addressstringThe address to advertise that the service listens 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.
ca_pathstringTarget PEM CA bundle path.
enable_tag_overrideboolfalseSpecifies to disable the anti-entropy feature for this service’s tags. If C(EnableTagOverride) is set to true then external agents can update this service in the catalog and modify the tags.
hoststringlocalhostConsul agent hostname.
idstringSpecifies a unique ID for this service. This must be unique per agent. This defaults to the O(name) parameter if not provided. If O(state=absent), defaults to the service name if supplied.
metadictOptional meta data used for filtering. For keys, the characters C(A-Z), C(a-z), C(0-9), C(_), C(-) are allowed. Not allowed characters are replaced with underscores.
namestringUnique name for the service on a node, must be unique per node, required if registering a service.
portint8500Consul agent HTTP port.
schemestringhttpHTTP or HTTPS protocol.
service_portintThe port on which the service is listening. Can optionally be supplied for registration of a service, that is if O(name) or O(id) is set.
statestringpresentWhether the service should be present or absent.
tagslistTags that are attached to the service registration.
tokenstringConsul ACL token; private argument.
validate_certsbooltrueValidate the server certificate.
weightsdictmap[passing:1 warning:1]Specifies weights for the service.

Example

yaml
- community.general.consul_agent_service:
    host: consul1.example.com
    name: nginx
    service_port: 80
    token: some_management_acl
  name: Register nginx service with the local Consul agent

- community.general.consul_agent_service:
    host: consul1.example.com
    name: nginx
    service_port: 80
    token: some_management_acl
  name: Register nginx with a tcp check

- community.general.consul_agent_service:
    host: consul1.example.com
    name: nginx
    service_port: 80
    token: some_management_acl
  name: Register nginx with an http check

- community.general.consul_agent_service:
    address: 10.1.5.23
    host: consul1.example.com
    name: nginx
    service_port: 80
    token: some_management_acl
  name: Register external service nginx available at 10.1.5.23

- community.general.consul_agent_service:
    host: consul1.example.com
    name: nginx
    service_port: 80
    tags:
        - prod
        - webservers
    token: some_management_acl
  name: Register nginx with some service tags

- community.general.consul_agent_service:
    host: consul1.example.com
    meta:
        nginx_version: 1.25.3
    name: nginx
    service_port: 80
    token: some_management_acl
  name: Register nginx with some service meta

- community.general.consul_agent_service:
    host: consul1.example.com
    id: nginx
    state: absent
    token: some_management_acl
  name: Remove nginx service

- community.general.consul_agent_service:
    host: consul1.example.com
    name: celery-worker
    tags:
        - prod
        - worker
    token: some_management_acl
  name: Register celery worker service
Search
    ↑ ↓ move↵ openesc close