diff options
author | Yannig Perré <yannig.perre@gmail.com> | 2015-08-07 09:40:24 +0200 |
---|---|---|
committer | Yannig Perré <yannig.perre@gmail.com> | 2015-08-07 09:40:24 +0200 |
commit | 07fcb50b9bfd26a28e8666ac1751a3122f65564d (patch) | |
tree | 6876df992ed8f8f71cfb1e3e2e637046d3268808 /lib/ansible/plugins/lookup/ini.py | |
parent | 09d257e63769854828953fc1e1059622d76665da (diff) | |
download | ansible-07fcb50b9bfd26a28e8666ac1751a3122f65564d.tar.gz |
Porting ini lookup plugin against ansible v2.
Diffstat (limited to 'lib/ansible/plugins/lookup/ini.py')
-rw-r--r-- | lib/ansible/plugins/lookup/ini.py | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/ansible/plugins/lookup/ini.py b/lib/ansible/plugins/lookup/ini.py index ebfed750c2..0c04f06909 100644 --- a/lib/ansible/plugins/lookup/ini.py +++ b/lib/ansible/plugins/lookup/ini.py @@ -14,19 +14,19 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type -from ansible import utils, errors import StringIO import os import codecs import ConfigParser import re -class LookupModule(object): +from ansible.errors import * +from ansible.plugins.lookup import LookupBase - def __init__(self, basedir=None, **kwargs): - self.basedir = basedir - self.cp = ConfigParser.ConfigParser() +class LookupModule(LookupBase): def read_properties(self, filename, key, dflt, is_regexp): config = StringIO.StringIO() @@ -51,13 +51,15 @@ class LookupModule(object): return dflt return value - def run(self, terms, inject=None, **kwargs): - - terms = utils.listify_lookup_plugin_terms(terms, self.basedir, inject) + def run(self, terms, variables=None, **kwargs): if isinstance(terms, basestring): terms = [ terms ] + basedir = self.get_basedir(variables) + self.basedir = basedir + self.cp = ConfigParser.ConfigParser() + ret = [] for term in terms: params = term.split() @@ -80,7 +82,7 @@ class LookupModule(object): except (ValueError, AssertionError), e: raise errors.AnsibleError(e) - path = utils.path_dwim(self.basedir, paramvals['file']) + path = self._loader.path_dwim_relative(basedir, 'files', paramvals['file']) if paramvals['type'] == "properties": var = self.read_properties(path, key, paramvals['default'], paramvals['re']) else: |