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: else:
name = self._var_name name = self._var_name
value = self._templar.template(self._var_value) value = self._templar.template(self._var_value)
merged_vars[name] = value
if self._is_fact: if self._is_fact:
self._inventory.set_variable(host_name, name, value) self._inventory.set_variable(host_name, name, value)
host_vars[name] = value host_vars[name] = value
if name not in script_vars:
merged_vars[name] = value
else: else:
script_vars[name] = value script_vars[name] = value
merged_vars[name] = value
self._display.vvv( self._display.vvv(
"- set %s %s to %s" "- set %s %s to %s"
% ("fact" if self._is_fact else "var", name, repr(value)) % ("fact" if self._is_fact else "var", name, repr(value))