From 6614d8a84bee661f75948cce3c4b458b146154e0 Mon Sep 17 00:00:00 2001 From: Andrew Butcher Date: Tue, 26 Apr 2016 16:27:22 -0400 Subject: Port lookup plugins to ansible v2. --- lookup_plugins/oo_option.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'lookup_plugins/oo_option.py') diff --git a/lookup_plugins/oo_option.py b/lookup_plugins/oo_option.py index 35dce48f9..3fc46ab9b 100644 --- a/lookup_plugins/oo_option.py +++ b/lookup_plugins/oo_option.py @@ -17,14 +17,36 @@ This returns, by order of priority: * if none of the above conditions are met, empty string is returned ''' -from ansible.utils import template + import os +# pylint: disable=no-name-in-module,import-error,unused-argument,unused-variable,super-init-not-called,too-few-public-methods,missing-docstring +try: + # ansible-2.0 + from ansible.plugins.lookup import LookupBase +except ImportError: + # ansible-1.9.x + class LookupBase(object): + def __init__(self, basedir=None, runner=None, **kwargs): + self.runner = runner + self.basedir = self.runner.basedir + def get_basedir(self, variables): + return self.basedir + +# pylint: disable=no-name-in-module,import-error +try: + # ansible-2.0 + from ansible import template +except ImportError: + # ansible 1.9.x + from ansible.utils import template + + # Reason: disable too-few-public-methods because the `run` method is the only # one required by the Ansible API # Status: permanently disabled # pylint: disable=too-few-public-methods -class LookupModule(object): +class LookupModule(LookupBase): ''' oo_option lookup plugin main class ''' # Reason: disable unused-argument because Ansible is calling us with many -- cgit v1.2.3