diff --git a/changelogs/fragments/5306-add-options-for-authentication.yml b/changelogs/fragments/5306-add-options-for-authentication.yml new file mode 100644 index 0000000000..ba179a72b7 --- /dev/null +++ b/changelogs/fragments/5306-add-options-for-authentication.yml @@ -0,0 +1,2 @@ +minor_changes: + - znode - possibility to use ZooKeeper ACL authentication (https://github.com/ansible-collections/community.general/pull/5306). \ No newline at end of file diff --git a/plugins/modules/clustering/znode.py b/plugins/modules/clustering/znode.py index 07be85c145..d9d05c3170 100644 --- a/plugins/modules/clustering/znode.py +++ b/plugins/modules/clustering/znode.py @@ -49,6 +49,22 @@ options: - Recursively delete node and all its children. type: bool default: false + auth_scheme: + description: + - 'Authentication scheme.' + choices: [ digest, sasl ] + type: str + default: "digest" + required: false + version_added: 5.8.0 + auth_credential: + description: + - The authentication credential value. Depends on I(auth_scheme). + - The format for I(auth_scheme=digest) is C(user:password), + and the format for I(auth_scheme=sasl) is C(user:password). + type: str + required: false + version_added: 5.8.0 requirements: - kazoo >= 2.1 - python >= 2.6 @@ -69,6 +85,13 @@ EXAMPLES = """ 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' @@ -122,7 +145,9 @@ def main(): op=dict(choices=['get', 'wait', 'list']), state=dict(choices=['present', 'absent']), timeout=dict(default=300, type='int'), - recursive=dict(default=False, type='bool') + recursive=dict(default=False, type='bool'), + auth_scheme=dict(default='digest', choices=['digest', 'sasl']), + auth_credential=dict(type='str', no_log=True), ), supports_check_mode=False ) @@ -201,6 +226,8 @@ class KazooCommandProxy(): def start(self): self.zk.start() + if self.module.params['auth_credential']: + self.zk.add_auth(self.module.params['auth_scheme'], self.module.params['auth_credential']) def wait(self): return self._wait(self.module.params['name'], self.module.params['timeout'])