community.general.znode – Create, delete, retrieve, and update znodes using ZooKeeper

Note

This plugin is part of the community.general collection (version 2.5.1).

To install it use: ansible-galaxy collection install community.general.

To use it in a playbook, specify: community.general.znode.

Synopsis

  • Create, delete, retrieve, and update znodes using ZooKeeper.

Requirements

The below requirements are needed on the host that executes this module.

  • kazoo >= 2.1

  • python >= 2.6

Parameters

Parameter Choices/Defaults Comments
hosts
string / required
A list of ZooKeeper servers (format '[server]:[port]').
name
string / required
The path of the znode.
op
string
    Choices:
  • get
  • wait
  • list
An operation to perform. Mutually exclusive with state.
recursive
boolean
    Choices:
  • no ←
  • yes
Recursively delete node and all its children.
state
string
    Choices:
  • present
  • absent
The state to enforce. Mutually exclusive with op.
timeout
integer
Default:
300
The amount of time to wait for a node to appear.
value
string
The value assigned to the znode.

Examples

- name: Creating or updating a znode with a given value
  community.general.znode:
    hosts: 'localhost:2181'
    name: /mypath
    value: myvalue
    state: present

- name: Getting the value and stat structure for a znode
  community.general.znode:
    hosts: 'localhost:2181'
    name: /mypath
    op: get

- name: Listing a particular znode's children
  community.general.znode:
    hosts: 'localhost:2181'
    name: /zookeeper
    op: list

- name: Waiting 20 seconds for a znode to appear at path /mypath
  community.general.znode:
    hosts: 'localhost:2181'
    name: /mypath
    op: wait
    timeout: 20

- name: Deleting a znode at path /mypath
  community.general.znode:
    hosts: 'localhost:2181'
    name: /mypath
    state: absent

- name: Creating or updating a znode with a given value on a remote Zookeeper
  community.general.znode:
    hosts: 'my-zookeeper-node:2181'
    name: /mypath
    value: myvalue
    state: present
  delegate_to: 127.0.0.1

Authors

  • Trey Perry (@treyperry)