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
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| address | string | The 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_path | string | Target PEM CA bundle path. | ||
| enable_tag_override | bool | false | Specifies 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. | |
| host | string | localhost | Consul agent hostname. | |
| id | string | Specifies 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. | ||
| meta | dict | Optional 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. | ||
| name | string | Unique name for the service on a node, must be unique per node, required if registering a service. | ||
| port | int | 8500 | Consul agent HTTP port. | |
| scheme | string | http | HTTP or HTTPS protocol. | |
| service_port | int | The 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. | ||
| state | string | present | Whether the service should be present or absent. | |
| tags | list | Tags that are attached to the service registration. | ||
| token | string | Consul ACL token; private argument. | ||
| validate_certs | bool | true | Validate the server certificate. | |
| weights | dict | map[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