ansible.builtin.consul_session (v2.4.0.0-1) — module

manipulate consul sessions

| "added in version" 2.0 of ansible.builtin"

Authors: Steve Gargan @sgargan

preview | supported by community

Install Ansible via pip

Install with pip install ansible==2.4.0.0.post1

Description

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 here http://www.consul.io/docs/internals/sessions.html


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: register basic session with consul
  consul_session:
    name: session1
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: register a session with an existing check
  consul_session:
    name: session_with_check
    checks:
      - existing_check_name
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: register a session with lock_delay
  consul_session:
    name: session_with_delay
    delay: 20s
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: retrieve info about session by id
  consul_session: id=session_id state=info
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: retrieve active sessions
  consul_session: state=list

Inputs

    
host:
    default: localhost
    description:
    - host of the consul agent defaults to localhost
    required: false

name:
    default: None
    description:
    - the name that should be associated with the session. This is opaque to Consul and
      not required.
    required: false

node:
    default: None
    description:
    - the name of the node that with which the session will be associated. by default
      this is the name of the agent.
    required: false

port:
    default: 8500
    description:
    - the port on which the consul agent is running
    required: false

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
    required: false

state:
    choices:
    - present
    - absent
    - info
    - node
    - list
    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 ID for the session is returned in the output.
      If absent, the name or 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
      info, node or list for the state; for node or info, the node name or session id
      is required as parameter.
    required: false

checks:
    default: None
    description:
    - a list of 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.
    required: false

scheme:
    default: http
    description:
    - the protocol scheme on which the consul agent is running
    required: false
    version_added: '2.1'
    version_added_collection: ansible.builtin

behavior:
    default: release
    description:
    - "the optional behavior that can be attached to the session when it is created. This\
      \ can be set to either \u2018release\u2019 or \u2018delete\u2019. This controls\
      \ the behavior when a session is invalidated."
    required: false
    version_added: '2.2'
    version_added_collection: ansible.builtin

datacenter:
    default: None
    description:
    - name of the datacenter in which the session exists or should be created.
    required: false

validate_certs:
    default: true
    description:
    - whether to verify the tls certificate of the consul agent
    required: false
    version_added: '2.1'
    version_added_collection: ansible.builtin