From 91ff8296d64c3571a73b29dfae2bf645266417c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Sun, 4 Sep 2022 23:20:26 +0200 Subject: [PATCH] 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. --- inventory_plugins/reconstructed.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/inventory_plugins/reconstructed.py b/inventory_plugins/reconstructed.py index 4754091..cfbd367 100644 --- a/inventory_plugins/reconstructed.py +++ b/inventory_plugins/reconstructed.py @@ -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):