fix discovery on loop with delegation (#70013)
* fix discovery on loop with delegation fixes #69963
This commit is contained in:
parent
8ffaed00f8
commit
4c9d9dbb56
4 changed files with 16 additions and 0 deletions
2
changelogs/fragments/ensure_discovery_delegate.yml
Normal file
2
changelogs/fragments/ensure_discovery_delegate.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- ensure we pass on interpreter discovery values to delegated host.
|
|
@ -252,6 +252,11 @@ class ActionBase(with_metaclass(ABCMeta, object)):
|
||||||
task_vars['ansible_facts'][discovered_key] = self._discovered_interpreter
|
task_vars['ansible_facts'][discovered_key] = self._discovered_interpreter
|
||||||
# preserve this so _execute_module can propagate back to controller as a fact
|
# preserve this so _execute_module can propagate back to controller as a fact
|
||||||
self._discovered_interpreter_key = discovered_key
|
self._discovered_interpreter_key = discovered_key
|
||||||
|
else:
|
||||||
|
task_vars['ansible_delegated_vars'][self._task.delegate_to]
|
||||||
|
if task_vars['ansible_delegated_vars'][self._task.delegate_to].get('ansible_facts') is None:
|
||||||
|
task_vars['ansible_delegated_vars'][self._task.delegate_to]['ansible_facts'] = {}
|
||||||
|
task_vars['ansible_delegated_vars'][self._task.delegate_to]['ansible_facts'][discovered_key] = self._discovered_interpreter
|
||||||
|
|
||||||
return (module_style, module_shebang, module_data, module_path)
|
return (module_style, module_shebang, module_data, module_path)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
- hosts: testhost
|
||||||
|
gather_facts: no
|
||||||
|
tasks:
|
||||||
|
- command: ls
|
||||||
|
delegate_to: "{{ item }}"
|
||||||
|
with_items:
|
||||||
|
- localhost
|
||||||
|
- "{{ inventory_hostname }}"
|
|
@ -69,3 +69,4 @@ ln -s python firstpython
|
||||||
ln -s python secondpython
|
ln -s python secondpython
|
||||||
)
|
)
|
||||||
ansible-playbook verify_interpreter.yml -i inventory_interpreters -v "$@"
|
ansible-playbook verify_interpreter.yml -i inventory_interpreters -v "$@"
|
||||||
|
ansible-playbook discovery_applied.yml -i inventory -v "$@"
|
||||||
|
|
Loading…
Reference in a new issue