ansible / ansible.builtin / v2.9.27 / module / consul_session Manipulate consul sessions | "added in version" 2.0 of ansible.builtin" Authors: Steve Gargan (@sgargan) preview | supported by communityansible.builtin.consul_session (v2.9.27) — module
pip
Install with pip install ansible==2.9.27
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
- name: register basic session with consul consul_session: name: session1
- name: register a session with an existing check consul_session: name: session_with_check checks: - existing_check_name
- name: register a session with lock_delay consul_session: name: session_with_delay delay: 20s
- name: retrieve info about session by id consul_session: id: session_id state: info
- name: retrieve active sessions consul_session: state: list
id: description: - ID of the session, required when I(state) is either C(info) or C(remove). type: str host: default: localhost description: - The host of the consul agent defaults to localhost. type: str name: description: - The name that should be associated with the session. Required when I(state=node) is used. type: str node: description: - The name of the node that with which the session will be associated. by default this is the name of the agent. type: str port: default: 8500 description: - The port on which the consul agent is running. type: int delay: default: 15 description: - 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. type: int state: choices: - absent - info - list - node - present default: present description: - Whether the session should be present i.e. created if it doesn't exist, or absent, removed if present. If created, the I(id) for the session is returned in the output. If C(absent), I(id) is required to remove the session. Info for a single session, all the sessions for a node or all available sessions can be retrieved by specifying C(info), C(node) or C(list) for the I(state); for C(node) or C(info), the node I(name) or session I(id) is required as parameter. type: str checks: description: - 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. type: list scheme: default: http description: - The protocol scheme on which the consul agent is running. type: str version_added: '2.1' version_added_collection: ansible.builtin behavior: choices: - delete - release default: release description: - The optional behavior that can be attached to the session when it is created. This controls the behavior when a session is invalidated. type: str version_added: '2.2' version_added_collection: ansible.builtin datacenter: description: - The name of the datacenter in which the session exists or should be created. type: str validate_certs: default: true description: - Whether to verify the TLS certificate of the consul agent. type: bool version_added: '2.1' version_added_collection: ansible.builtin