From 7e5eb8e414d078e07fc153050592f8c1a15c78c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Sun, 4 Sep 2022 23:00:15 +0200 Subject: [PATCH] Fixed caching problem in set_fact * Since facts have a lower priority than local variables, set_fact should only update the cache if no local variable uses the same name --- inventory_plugins/reconstructed.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/inventory_plugins/reconstructed.py b/inventory_plugins/reconstructed.py index 395a243..db4c815 100644 --- a/inventory_plugins/reconstructed.py +++ b/inventory_plugins/reconstructed.py @@ -480,12 +480,14 @@ class RciSetVarOrFact(RcInstruction): else: name = self._var_name value = self._templar.template(self._var_value) - merged_vars[name] = value if self._is_fact: self._inventory.set_variable(host_name, name, value) host_vars[name] = value + if name not in script_vars: + merged_vars[name] = value else: script_vars[name] = value + merged_vars[name] = value self._display.vvv( "- set %s %s to %s" % ("fact" if self._is_fact else "var", name, repr(value))