Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delegation fix #74685

Merged
merged 4 commits into from May 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 3 additions & 4 deletions lib/ansible/executor/task_executor.py
Expand Up @@ -5,7 +5,6 @@
__metaclass__ = type

import os
import re
import pty
import time
import json
Expand All @@ -20,7 +19,7 @@
from ansible.executor.task_result import TaskResult
from ansible.executor.module_common import get_action_args_with_defaults
from ansible.module_utils.parsing.convert_bool import boolean
from ansible.module_utils.six import iteritems, string_types, binary_type
from ansible.module_utils.six import iteritems, binary_type
from ansible.module_utils.six.moves import xrange
from ansible.module_utils._text import to_text, to_native
from ansible.module_utils.connection import write_to_file_descriptor
Expand Down Expand Up @@ -480,8 +479,8 @@ def _execute(self, variables=None):
if self._loop_eval_error is not None:
raise self._loop_eval_error # pylint: disable=raising-bad-type

# if we ran into an error while setting up the PlayContext, raise it now
if context_validation_error is not None:
# if we ran into an error while setting up the PlayContext, raise it now, unless is known issue with delegation
if context_validation_error is not None and not (self._task.delegate_to and isinstance(context_validation_error, AnsibleUndefinedVariable)):
raise context_validation_error # pylint: disable=raising-bad-type

# if this task is a TaskInclude, we just return now with a success code so the
Expand Down
@@ -0,0 +1,18 @@
- name: ensure we can use fact on delegated host for connection info
hosts: localhost
gather_facts: no
tasks:
- add_host: name=f31 bogus_user=notme ansible_connection=ssh ansible_host=4.2.2.2

- name: if not overriding with delegated host info, will not be unreachable
ping:
timeout: 5
delegate_to: f31
ignore_errors: true
ignore_unreachable: true
register: delping

- name: ensure that the expected happened
assert:
that:
- delping is failed
1 change: 1 addition & 0 deletions test/integration/targets/delegate_to/runme.sh
Expand Up @@ -74,3 +74,4 @@ ansible-playbook discovery_applied.yml -i inventory -v "$@"
ansible-playbook resolve_vars.yml -i inventory -v "$@"
ansible-playbook test_delegate_to_lookup_context.yml -i inventory -v "$@"
ansible-playbook delegate_local_from_root.yml -i inventory -v "$@" -e 'ansible_user=root'
ansible-playbook delegate_with_fact_from_delegate_host.yml "$@"