community.general.consul_session module – Manipulate consul sessions
Note
This module is part of the community.general collection (version 9.4.0).
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_session
.
Synopsis
Allows the addition, modification and deletion of sessions in a consul cluster. These sessions can then be used in conjunction with key value pairs to implement distributed locks. In depth documentation for working with sessions can be found at http://www.consul.io/docs/internals/sessions.html
Parameters
Parameter |
Comments |
---|---|
The optional behavior that can be attached to the session when it is created. This controls the behavior when a session is invalidated. Choices:
|
|
The CA bundle to use for https connections |
|
Checks that will be used to verify the session health. If all the checks fail, the session will be invalidated and any locks associated with the session will be release and can be acquired once the associated lock delay has expired. |
|
The name of the datacenter in which the session exists or should be created. |
|
The optional lock delay that can be attached to the session when it is created. Locks for invalidated sessions ar blocked from being acquired until this delay has expired. Durations are in seconds. Default: |
|
Host of the consul agent, defaults to Default: |
|
ID of the session, required when |
|
The name that should be associated with the session. Required when |
|
The name of the node that with which the session will be associated. by default this is the name of the agent. |
|
The port on which the consul agent is running. Default: |
|
The protocol scheme on which the consul agent is running. Defaults to Default: |
|
Whether the session should be present i.e. created if it doesn’t exist, or absent, removed if present. If created, the Choices:
|
|
The token to use for authorization. |
|
Specifies the duration of a session in seconds (between 10 and 86400). |
|
Whether to verify the TLS certificate of the consul agent. Choices:
|
Attributes
Attribute |
Support |
Description |
---|---|---|
Action group: community.general.consul added in community.general 8.3.0 |
Use |
|
Support: none |
Can run in |
|
Support: none |
Will return details on what has changed (or possibly needs changing in |
Examples
- name: Register basic session with consul
community.general.consul_session:
name: session1
- name: Register a session with an existing check
community.general.consul_session:
name: session_with_check
checks:
- existing_check_name
- name: Register a session with lock_delay
community.general.consul_session:
name: session_with_delay
delay: 20s
- name: Retrieve info about session by id
community.general.consul_session:
id: session_id
state: info
- name: Retrieve active sessions
community.general.consul_session:
state: list
- name: Register session with a ttl
community.general.consul_session:
name: session-with-ttl
ttl: 600 # sec