From a3c1ea886ffd2115ea2475d5342fc8d015790643 Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Wed, 24 Jun 2020 15:36:51 -0400 Subject: [PATCH] Revert commits related to delegated facts changes (#70272) * Revert "Fix storing delegate_to facts (#70231)" This reverts commit 88bb76f248833ea0761fc474ba77ef697c62baac. * Revert "Fix storing local task_vars facts for the retry (#70171)" This reverts commit eaf6086eeab3ffc0389694a037c776cd3d6ac0b5. --- ...168-fix-delegate_facts-without-interpreter-set.yml | 2 -- lib/ansible/plugins/action/__init__.py | 10 +++------- test/integration/targets/delegate_to/aliases | 1 - test/integration/targets/delegate_to/runme.sh | 5 ----- .../verify_interpreter_auto_delegate_to.yml | 7 ------- .../delegate_to/verify_interpreter_delegate_facts.yml | 11 ----------- 6 files changed, 3 insertions(+), 33 deletions(-) delete mode 100644 changelogs/fragments/70168-fix-delegate_facts-without-interpreter-set.yml delete mode 100644 test/integration/targets/delegate_to/verify_interpreter_auto_delegate_to.yml delete mode 100644 test/integration/targets/delegate_to/verify_interpreter_delegate_facts.yml diff --git a/changelogs/fragments/70168-fix-delegate_facts-without-interpreter-set.yml b/changelogs/fragments/70168-fix-delegate_facts-without-interpreter-set.yml deleted file mode 100644 index 371778eabb2..00000000000 --- a/changelogs/fragments/70168-fix-delegate_facts-without-interpreter-set.yml +++ /dev/null @@ -1,2 +0,0 @@ -bugfixes: - - "Fix ``delegate_facts: true`` when ``ansible_python_interpreter`` is not set. (https://github.com/ansible/ansible/issues/70168)" diff --git a/lib/ansible/plugins/action/__init__.py b/lib/ansible/plugins/action/__init__.py index f1e0a14bca6..83c7715d3ee 100644 --- a/lib/ansible/plugins/action/__init__.py +++ b/lib/ansible/plugins/action/__init__.py @@ -160,7 +160,7 @@ class ActionBase(with_metaclass(ABCMeta, object)): ''' if task_vars is None: - task_vars = {} + use_vars = dict() if self._task.delegate_to: use_vars = task_vars.get('ansible_delegated_vars')[self._task.delegate_to] @@ -242,22 +242,18 @@ class ActionBase(with_metaclass(ABCMeta, object)): # we'll propagate back to the controller in the task result discovered_key = 'discovered_interpreter_%s' % idre.interpreter_name - # update the local vars copy for the retry - if use_vars.get('ansible_facts') is None: - use_vars['ansible_facts'] = {} - use_vars['ansible_facts'][discovered_key] = self._discovered_interpreter - # TODO: this condition prevents 'wrong host' from being updated # but in future we would want to be able to update 'delegated host facts' # irrespective of task settings if not self._task.delegate_to or self._task.delegate_facts: # store in local task_vars facts collection for the retry and any other usages in this worker - if task_vars.get('ansible_facts') is None: + if use_vars.get('ansible_facts') is None: task_vars['ansible_facts'] = {} task_vars['ansible_facts'][discovered_key] = self._discovered_interpreter # preserve this so _execute_module can propagate back to controller as a fact 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 diff --git a/test/integration/targets/delegate_to/aliases b/test/integration/targets/delegate_to/aliases index 5ba9106d8ad..b8e973dacea 100644 --- a/test/integration/targets/delegate_to/aliases +++ b/test/integration/targets/delegate_to/aliases @@ -2,4 +2,3 @@ shippable/posix/group3 needs/ssh needs/root # only on macOS and FreeBSD to configure network interfaces skip/aix -non_local # workaround to allow override of ansible_python_interpreter; disables coverage on this integration target diff --git a/test/integration/targets/delegate_to/runme.sh b/test/integration/targets/delegate_to/runme.sh index b5e0836ae06..8095c921d23 100755 --- a/test/integration/targets/delegate_to/runme.sh +++ b/test/integration/targets/delegate_to/runme.sh @@ -70,8 +70,3 @@ ln -s python secondpython ) ansible-playbook verify_interpreter.yml -i inventory_interpreters -v "$@" ansible-playbook discovery_applied.yml -i inventory -v "$@" - -# https://github.com/ansible/ansible/issues/70168 -ansible-playbook verify_interpreter_delegate_facts.yml -i inventory -v "$@" - -ansible-playbook verify_interpreter_auto_delegate_to.yml -i inventory -v "$@" diff --git a/test/integration/targets/delegate_to/verify_interpreter_auto_delegate_to.yml b/test/integration/targets/delegate_to/verify_interpreter_auto_delegate_to.yml deleted file mode 100644 index 81905413b91..00000000000 --- a/test/integration/targets/delegate_to/verify_interpreter_auto_delegate_to.yml +++ /dev/null @@ -1,7 +0,0 @@ -- hosts: testhost - gather_facts: no - tasks: - - detect_interpreter: - delegate_to: testhost3 - vars: - ansible_python_interpreter: auto diff --git a/test/integration/targets/delegate_to/verify_interpreter_delegate_facts.yml b/test/integration/targets/delegate_to/verify_interpreter_delegate_facts.yml deleted file mode 100644 index 27e90ed49c8..00000000000 --- a/test/integration/targets/delegate_to/verify_interpreter_delegate_facts.yml +++ /dev/null @@ -1,11 +0,0 @@ -- hosts: testhost - gather_facts: yes - tasks: - - detect_interpreter: - delegate_to: "{{ item }}" - delegate_facts: yes - vars: - ansible_python_interpreter: auto - loop: - - testhost3 - - testhost4