fix discovery on loop with delegation (#70013)

* fix discovery on loop with delegation

fixes #69963
This commit is contained in:
Brian Coca 2020-06-11 18:04:17 -04:00 committed by GitHub
parent 8ffaed00f8
commit 4c9d9dbb56
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 0 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- ensure we pass on interpreter discovery values to delegated host.

View file

@ -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)

View file

@ -0,0 +1,8 @@
- hosts: testhost
gather_facts: no
tasks:
- command: ls
delegate_to: "{{ item }}"
with_items:
- localhost
- "{{ inventory_hostname }}"

View file

@ -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 "$@"