More cache/loop fixes

* When the loop variable state is restored, the cache must also be
    modified.
  * What needs to be done depends on whether a host fact by the same
    name also exist.
  * Fuck that cache thing. It's going away next time I can hack on this.
This commit is contained in:
Emmanuel BENOîT 2022-09-04 23:20:26 +02:00
parent 57bf02e79d
commit 91ff8296d6

View file

@ -238,8 +238,13 @@ class RcInstruction(abc.ABC):
# Restore loop variable state
if had_loop_var:
script_vars[self._loop_var] = old_loop_var
merged_vars[self._loop_var] = old_loop_var
else:
del script_vars[self._loop_var]
if self._loop_var in host_vars:
merged_vars[self._loop_var] = host_vars[self._loop_var]
else:
del merged_vars[self._loop_var]
def run_once(self, host_name, merged_vars, host_vars, script_vars):
if self.evaluate_condition(host_name, merged_vars):