From 99b57140373dd8d7a1e565611c8a2e2dab24eca8 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Thu, 21 May 2020 21:01:06 +0200 Subject: improved intel stability fix --- filter_plugins/config-parser.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 filter_plugins/config-parser.py (limited to 'filter_plugins/config-parser.py') diff --git a/filter_plugins/config-parser.py b/filter_plugins/config-parser.py new file mode 100644 index 00000000..8654a104 --- /dev/null +++ b/filter_plugins/config-parser.py @@ -0,0 +1,28 @@ +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +from functools import partial + +from ansible import errors + + +def from_ini(data): + try: + import configparser + config = configparser.ConfigParser() + config.optionxform = lambda option: option + config.read_string(data) + return config._sections + except Exception as e: + raise errors.AnsibleFilterError("from_ini(): %s" % str(e)) + + +class FilterModule(object): + + ''' config parser filters ''' + filter_map = { + 'from_ini': from_ini, + } + + def filters(self): + return self.filter_map -- cgit v1.2.3 From b3accaa242e9ae74e387e0ead60da24e35a2f1f2 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Thu, 21 May 2020 21:37:47 +0200 Subject: fix last commit for python2 --- filter_plugins/config-parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'filter_plugins/config-parser.py') diff --git a/filter_plugins/config-parser.py b/filter_plugins/config-parser.py index 8654a104..c052a7ec 100644 --- a/filter_plugins/config-parser.py +++ b/filter_plugins/config-parser.py @@ -12,7 +12,7 @@ def from_ini(data): config = configparser.ConfigParser() config.optionxform = lambda option: option config.read_string(data) - return config._sections + return {s: dict(config.items(s)) for s in config.sections()} except Exception as e: raise errors.AnsibleFilterError("from_ini(): %s" % str(e)) -- cgit v1.2.3