From f85f575a58e9dde66cb176ed3fccd1bbea0dac9e 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 --- lib/ansible/modules/extras/clustering/znode.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/extras/clustering/znode.py b/lib/ansible/modules/extras/clustering/znode.py index d5913c772b3..aff1cd1d224 100644 --- a/lib/ansible/modules/extras/clustering/znode.py +++ b/lib/ansible/modules/extras/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.'}