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
This commit is contained in:
Emmanuel BENOîT 2022-09-04 23:00:15 +02:00
parent a5b1ac5c4c
commit 7e5eb8e414

View file

@ -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))