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 的值。 | 
属性
| 属性 | 支持 | 描述 | 
|---|---|---|
| 支持:不支持 | 可以在  | |
| 支持:不支持 | 在差异模式下,将返回有关已更改内容(或可能需要更改的内容,在  | 
示例
- 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
