Add: support for jinja2_native

This commit is contained in:
Robin Pierre Cordier 2022-03-08 16:28:48 -05:00
parent cb70574fed
commit f0dc98ac74
2 changed files with 4 additions and 1 deletions

View File

@ -86,6 +86,7 @@ class InventoryModule(BaseInventoryPlugin, Cacheable, Constructable):
#self._consume_options(config_data) #self._consume_options(config_data)
# Get options from inventory # Get options from inventory
self.jinja2_native = self.get_option('jinja2_native')
self.strict = self.get_option('strict') self.strict = self.get_option('strict')
self.compose = self.get_option('compose') self.compose = self.get_option('compose')
self.groups = self.get_option('groups') self.groups = self.get_option('groups')
@ -111,6 +112,7 @@ class InventoryModule(BaseInventoryPlugin, Cacheable, Constructable):
scope=None, scope=None,
_templar=self.templar, _templar=self.templar,
_variables=host.get_vars(), _variables=host.get_vars(),
jinja2_native=self.jinja2_native,
#trace=True, #trace=True,
#explain=True, #explain=True,
) )

View File

@ -462,6 +462,7 @@ class AnsibleKheops():
_variables=None, _variables=None,
_process_scope=None, _process_scope=None,
_process_results=None, _process_results=None,
jinja2_native=False
): ):
_process_scope = _process_scope or self.config['process_scope'] _process_scope = _process_scope or self.config['process_scope']
@ -471,7 +472,7 @@ class AnsibleKheops():
scope = self.get_scope_from_host_inventory(_variables, scope=scope) scope = self.get_scope_from_host_inventory(_variables, scope=scope)
elif _process_scope == 'jinja': elif _process_scope == 'jinja':
assert _templar, f"BUG: We expected a templar object here, got: {_templar}" assert _templar, f"BUG: We expected a templar object here, got: {_templar}"
scope = self.get_scope_from_jinja(_variables, _templar, scope=scope) scope = self.get_scope_from_jinja(_variables, _templar, scope=scope, jinja2_native=jinja2_native)
ret = self.lookup(keys, namespace=namespace, scope=scope) ret = self.lookup(keys, namespace=namespace, scope=scope)