community.general.consul_agent_check module – Add, modify, and delete checks within a consul cluster
Note
This module is part of the community.general collection (version 10.0.1).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install community.general
.
To use it in a playbook, specify: community.general.consul_agent_check
.
New in community.general 9.1.0
Synopsis
Allows the addition, modification and deletion of checks in a consul cluster via the agent. For more details on using and configuring Checks, see https://developer.hashicorp.com/consul/api-docs/agent/check.
Currently, there is no complete way to retrieve the script, interval or TTL metadata for a registered check. Without this metadata it is not possible to tell if the data supplied with ansible represents a change to a check. As a result this does not attempt to determine changes and will always report a changed occurred. An API method is planned to supply this metadata so at that stage change management will be added.
Parameters
Parameter |
Comments |
---|---|
The CA bundle to use for https connections |
|
Host of the consul agent, defaults to Default: |
|
Specifies a unique ID for this check on the node. This defaults to the |
|
The interval at which the service check will be run. This is a number with a Required if one of the parameters |
|
Required name for the service check. |
|
Notes to attach to check when registering it. |
|
The port on which the consul agent is running. Default: |
|
The protocol scheme on which the consul agent is running. Defaults to Default: |
|
The ID for the service, must be unique per node. If |
|
Whether the check should be present or absent. Choices:
|
|
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 Requires |
|
A custom HTTP check timeout. The consul default is 10 seconds. Similar to the interval this is a number with a |
|
The token to use for authorization. |
|
Checks can be registered with a TTL instead of a |
|
Whether to verify the TLS certificate of the consul agent. Choices:
|
Attributes
Attribute |
Support |
Description |
---|---|---|
Action group: community.general.consul |
Use |
|
Support: full The result is the object as it is defined in the module options and not the object structure of the consul API. For a better overview of what the object structure looks like, take a look at https://developer.hashicorp.com/consul/api-docs/agent/check#list-checks. |
Can run in |
|
Support: partial In check mode the diff will show the object as it is defined in the module options and not the object structure of the consul API. |
Will return details on what has changed (or possibly needs changing in |
Examples
- name: Register tcp check for service 'nginx'
community.general.consul_agent_check:
name: nginx_tcp_check
service_id: nginx
interval: 60s
tcp: localhost:80
notes: "Nginx Check"
- name: Register http check for service 'nginx'
community.general.consul_agent_check:
name: nginx_http_check
service_id: nginx
interval: 60s
http: http://localhost:80/status
notes: "Nginx Check"
- name: Remove check for service 'nginx'
community.general.consul_agent_check:
state: absent
id: nginx_http_check
service_id: "{{ nginx_service.ID }}"
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
The check as returned by the consul HTTP API. Returned: always Sample: |
|
The operation performed. Returned: changed Sample: |