'Get deeply nested values from task_vars.
Ansible task_vars structures are Python dicts, often mapping strings to
other dicts. This helper makes it easier to get a nested value, raising
OpenShiftCheckException when a key is not found.
Keyword args:
default:
On missing key, return this as default value instead of raising exception.
convert:
Supply a function to apply to normalize the value before returning it.
None is the default (return as-is).
This function should raise ValueError if the user has provided a value
that cannot be converted, or OpenShiftCheckException if some other
problem needs to be described to the user.'

def get_var(self, *keys, **kwargs):

    if (len(keys) == 1):
        keys = keys[0].split('.')
    try:
        value = reduce(operator.getitem, keys, self.task_vars)
    except (KeyError, TypeError):
        if ('default' not in kwargs):
            raise OpenShiftCheckException("This    check    expects    the    '{}'    inventory    variable    to    be    defined\nin    order    to    proceed,    but    it    is    undefined.    There    may    be    a    bug\nin    Ansible,    the    checks,    or    their    dependencies.".format('.'.join(map(str, keys))))
        value = kwargs['default']
    convert = kwargs.get('convert', None)
    try:
        if (convert is None):
            return value
        elif (convert is bool):
            return ansible_to_bool(value)
        else:
            return convert(value)
    except ValueError as error:
        raise OpenShiftCheckException('Cannot    convert    inventory    variable    to    expected    type:\n        "{var}={value}"\n{error}'.format(var='.'.join(keys), value=value, error=error))
    except OpenShiftCheckException:
        raise
    except Exception as error:
        raise OpenShiftCheckException('There    is    a    bug    in    this    check.    While    trying    to    convert    variable    \n        "{var}={value}"\nthe    given    converter    cannot    be    used    or    failed    unexpectedly:\n{error}'.format(var='.'.join(keys), value=value, error=error))
