consul_session
Create, inspect or destroy Consul sessions
Collection: community.general
Full Name: community.general.consul_session
Synopsis
Create, inspect or destroy Consul sessions
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| behavior | string | release | The optional behavior that can be attached to the session when it is created. This controls the behavior when a session is invalidated. | |
| ca_path | string | Target PEM CA bundle path. | ||
| checks | list | Checks that are used to verify the session health. If all the checks fail, the session is invalidated and any locks associated with the session are released and can be acquired once the associated lock delay has expired. | ||
| datacenter | string | The name of the datacenter in which the session exists or should be created. | ||
| delay | int | 15 | 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. | |
| host | string | localhost | Consul agent hostname. | |
| id | string | ID of the session, required when O(state) is either V(info) or V(remove). | ||
| name | string | The name that should be associated with the session. Required when O(state=node) is used. | ||
| node | string | The name of the node that with which the session is associated. By default this is the name of the agent. | ||
| port | int | 8500 | Consul agent HTTP port. | |
| scheme | string | http | HTTP or HTTPS protocol. | |
| state | string | present | Whether the session should be present, in other words it should be created if it does not exist, or absent, removed if present. If created, the O(id) for the session is returned in the output. If V(absent), O(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 V(info), V(node) or V(list) for the O(state); for V(node) or V(info), the node O(name) or session O(id) is required as parameter. | |
| token | string | Consul ACL token; private argument. | ||
| ttl | int | Specifies the duration of a session in seconds (between 10 and 86400). | ||
| validate_certs | bool | true | Validate the server certificate. |
Example
yaml
- community.general.consul_session:
name: session1
name: Register basic session with Consul
- community.general.consul_session:
checks:
- existing_check_name
name: session_with_check
name: Register a session with an existing check
- community.general.consul_session:
delay: 20
name: session_with_delay
name: Register a session with lock_delay
- community.general.consul_session:
id: session_id
state: info
name: Retrieve info about session by id
- community.general.consul_session:
state: list
name: Retrieve active sessions
- community.general.consul_session:
name: session-with-ttl
ttl: 600
name: Register session with a ttl