From b8bc7ed9fff82e5f5ddd8c67c5c94bf0d64f8aac Mon Sep 17 00:00:00 2001 From: Justin Good Date: Tue, 9 Feb 2016 12:41:30 +0000 Subject: [PATCH] Add support for recursive znode deletion --- clustering/znode.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/clustering/znode.py b/clustering/znode.py index d5913c772b3..aff1cd1d224 100644 --- a/clustering/znode.py +++ b/clustering/znode.py @@ -50,6 +50,12 @@ options: - The amount of time to wait for a node to appear. default: 300 required: false + recursive: + description: + - Recursively delete node and all its children. + default: False + required: false + version_added: "2.1" requirements: - kazoo >= 2.1 - python >= 2.6 @@ -90,7 +96,8 @@ def main(): value=dict(required=False, default=None, type='str'), op=dict(required=False, default=None, choices=['get', 'wait', 'list']), state=dict(choices=['present', 'absent']), - timeout=dict(required=False, default=300, type='int') + timeout=dict(required=False, default=300, type='int'), + recursive=dict(required=False, default=False, type='bool') ), supports_check_mode=False ) @@ -175,7 +182,7 @@ class KazooCommandProxy(): def _absent(self, znode): if self.exists(znode): - self.zk.delete(znode) + self.zk.delete(znode, recursive=self.module.params['recursive']) return True, {'changed': True, 'msg': 'The znode was deleted.'} else: return True, {'changed': False, 'msg': 'The znode does not exist.'}