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
参数
参数 |
注释 |
---|---|
身份验证凭据值。取决于
|
|
身份验证方案。 选择
|
|
ZooKeeper 服务器列表(格式为“[服务器]:[端口]”)。 |
|
znode 的路径。 |
|
要执行的操作。与 state 互斥。 选择
|
|
递归删除节点及其所有子节点。 选择
|
|
要强制执行的状态。与 op 互斥。 选择
|
|
等待节点出现的时间量。 默认值: |
|
是否使用 TLS/SSL。 选择
|
|
分配给 znode 的值。 |
属性
属性 |
支持 |
描述 |
---|---|---|
支持:无 |
可以在 |
|
支持:无 |
在 diff 模式下运行时,将返回有关已更改(或可能需要在 |
示例
- 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