community.general.znode 模块 – 使用 ZooKeeper 创建、删除、检索和更新 znode

注意

此模块是 community.general 集合(版本 10.1.0)的一部分。

如果您正在使用 ansible 包,您可能已经安装了此集合。它不包含在 ansible-core 中。要检查是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用:ansible-galaxy collection install community.general。您需要进一步的要求才能使用此模块,请参阅 要求 以了解详细信息。

要在剧本中使用它,请指定:community.general.znode

概要

  • 使用 ZooKeeper 创建、删除、检索和更新 znode。

要求

以下要求需要在执行此模块的主机上满足。

  • kazoo >= 2.1

参数

参数

注释

auth_credential

字符串

在 community.general 5.8.0 中添加

身份验证凭据值。取决于 auth_scheme

auth_scheme=digest 的格式是 user:passwordauth_scheme=sasl 的格式是 user:password

auth_scheme

字符串

在 community.general 5.8.0 中添加

身份验证方案。

选择

  • "digest" ← (默认)

  • "sasl"

hosts

字符串 / 必需

ZooKeeper 服务器列表(格式为“[服务器]:[端口]”)。

name

字符串 / 必需

znode 的路径。

op

字符串

要执行的操作。与 state 互斥。

选择

  • "get"

  • "wait"

  • "list"

recursive

布尔值

递归删除节点及其所有子节点。

选择

  • false ← (默认)

  • true

state

字符串

要强制执行的状态。与 op 互斥。

选择

  • "present"

  • "absent"

timeout

整数

等待节点出现的时间量。

默认值: 300

use_tls

布尔值

在 community.general 6.5.0 中添加

是否使用 TLS/SSL。

选择

  • false ← (默认)

  • true

value

字符串

分配给 znode 的值。

属性

属性

支持

描述

check_mode

支持:

可以在 check_mode 中运行,并在不修改目标的情况下返回更改状态预测。

diff_mode

支持:

在 diff 模式下运行时,将返回有关已更改(或可能需要在 check_mode 中更改)的详细信息。

示例

- 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: Getting the value and stat structure for a znode using digest authentication
  community.general.znode:
    hosts: 'localhost:2181'
    auth_credential: 'user1:s3cr3t'
    name: /secretmypath
    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

作者

  • Trey Perry (@treyperry)