summaryrefslogtreecommitdiffstats
path: root/qtip
diff options
context:
space:
mode:
authorYujun Zhang <zhang.yujunz@zte.com.cn>2017-04-24 21:14:40 +0800
committerYujun Zhang <zhang.yujunz@zte.com.cn>2017-04-24 22:47:18 +0800
commit7aaa7b0bf4ae4f29134b0298351c1aa1c189c253 (patch)
tree3cde7a25f4dc1500bd2c35cb54efc53d66070b0a /qtip
parentd550122312110e9db8759a4dc52ace8b230373db (diff)
Support running collect stage only
- add `always` tag to tasks required for all stages - apply `setup`, `collect` and `run` tag to each stage Change-Id: I806ec1add08bb18cb5b2848c78a039ed8a38c8ff Signed-off-by: Yujun Zhang <zhang.yujunz@zte.com.cn>
Diffstat (limited to 'qtip')
-rw-r--r--qtip/ansible_library/plugins/action/collect.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/qtip/ansible_library/plugins/action/collect.py b/qtip/ansible_library/plugins/action/collect.py
index 88ad0e35..e51b8072 100644
--- a/qtip/ansible_library/plugins/action/collect.py
+++ b/qtip/ansible_library/plugins/action/collect.py
@@ -10,6 +10,7 @@
##############################################################################
from collections import defaultdict
+import json
import re
from ansible.plugins.action import ActionBase
@@ -25,11 +26,12 @@ class ActionModule(ActionBase):
string = self._task.args.get('string')
patterns = self._task.args.get('patterns')
+ export_to = self._task.args.get('export_to')
- return collect(patterns, string)
+ return collect(patterns, string, export_to)
-def collect(patterns, string):
+def collect(patterns, string, export_to=None):
"""collect all named subgroups of the match into a list keyed by subgroup name
"""
captured = defaultdict(list)
@@ -42,4 +44,7 @@ def collect(patterns, string):
for (key, value) in match_obj.groupdict().items():
captured[key].append(value)
+ if export_to is not None:
+ with open(export_to, 'w+') as f:
+ f.write(json.dumps(captured, indent=2))
return captured