|
45 | 45 | import ansible_mitogen.process |
46 | 46 |
|
47 | 47 | import ansible.executor.process.worker |
| 48 | +import ansible.template |
48 | 49 | import ansible.utils.sentinel |
49 | 50 |
|
50 | 51 |
|
@@ -326,3 +327,24 @@ def run(self, iterator, play_context, result=0): |
326 | 327 | self._worker_model.on_strategy_complete() |
327 | 328 | finally: |
328 | 329 | ansible_mitogen.process.set_worker_model(None) |
| 330 | + |
| 331 | + def _smuggle_to_connction_reset(self, task, play_context, iterator, target_host): |
| 332 | + # Workaround for https://github.com/ansible/ansible/issues/84238 |
| 333 | + variables = self._variable_manager.get_vars( |
| 334 | + play=iterator._play, host=target_host, task=task, |
| 335 | + _hosts=self._hosts_cache, _hosts_all=self._hosts_cache_all, |
| 336 | + ) |
| 337 | + templar = ansible.template.Templar( |
| 338 | + loader=self._loader, variables=variables, |
| 339 | + ) |
| 340 | + play_context.vars.update({ |
| 341 | + '_mitogen.smuggled.reset_connection': (task, templar), |
| 342 | + }) |
| 343 | + |
| 344 | + def _execute_meta(self, task, play_context, iterator, target_host): |
| 345 | + if task.args['_raw_params'] == 'reset_connection': |
| 346 | + self._smuggle_to_connction_reset(task, play_context, iterator, target_host) |
| 347 | + |
| 348 | + return super(StrategyMixin, self)._execute_meta( |
| 349 | + task, play_context, iterator, target_host, |
| 350 | + ) |
0 commit comments