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 not properly shown in task #74071

Closed
nomadcz opened this issue Mar 30, 2021 · 5 comments · Fixed by #74370
Closed

Delegation not properly shown in task #74071

nomadcz opened this issue Mar 30, 2021 · 5 comments · Fixed by #74370
Labels
affects_2.9 This issue/PR affects Ansible v2.9 bug This issue/PR relates to a bug. P3 Priority 3 - Approved, No Time Limitation python3 support:core This issue/PR relates to code supported by the Ansible Engineering Team.

Comments

@nomadcz
Copy link

nomadcz commented Mar 30, 2021

Summary

When I run a task with the delegation it is not shown properly in the output.
Ansible 2.9.4 actually works ok. Ansible 2.9.17 and 2.9.18 seems broken.

Issue Type

Bug Report

Component Name

delegate_to

Ansible Version

  ansible 2.9.18
  config file = /srv/data/prod/ansible/core/remote/cm/csas/linux-cm-dev/ansible.cfg
  configured module search path = ['/home/spider/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /srv/app/prod/ansible/core/ansible-2.9.18/lib64/python3.6/site-packages/ansible
  executable location = /srv/app/prod/ansible/core/ansible-2.9.18/bin/ansible
  python version = 3.6.8 (default, Aug 18 2020, 08:33:21) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]

Configuration

strategy = host_pinned

OS / Environment

RHEL8

Steps to Reproduce

---
- name: Debug
  hosts: "{{ servers }}"
  gather_facts: no
  become: no

  tasks:
  - name: Run command
    command: id
    delegate_to: localhost

Expected Results

When delegated task is being run ansible should properly show to which host is task delegated:

PLAY [Debug] ********************************************************************************************************************************************************************************

TASK [Run command] **************************************************************************************************************************************************************************
Tuesday 30 March 2021  17:18:37 +0200 (0:00:00.411)       0:00:00.411 *********
 [started TASK: Run command on tpinsas03.vs.csin.cz]
changed: [tpinsas03.vs.csin.cz -> localhost]

Actual Results

PLAY [Debug] *******************************************************************

TASK [Run command] *************************************************************
Tuesday 30 March 2021  17:12:08 +0200 (0:00:00.153)       0:00:00.153 *********
 [started TASK: Run command on tpinsas03.vs.csin.cz]
changed: [tpinsas03.vs.csin.cz]
@ansibot
Copy link
Contributor

ansibot commented Mar 30, 2021

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibot ansibot added affects_2.9 This issue/PR affects Ansible v2.9 bug This issue/PR relates to a bug. needs_triage Needs a first human triage before being processed. python3 support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Mar 30, 2021
@samdoran samdoran added needs_verified This issue needs to be verified/reproduced by maintainer P3 Priority 3 - Approved, No Time Limitation and removed needs_triage Needs a first human triage before being processed. labels Mar 30, 2021
@samdoran
Copy link
Contributor

There seems to be another callback or have some other options enabled based on the output. Can you provide further details about any configuration changes you may have in place?

@nomadcz
Copy link
Author

nomadcz commented Mar 30, 2021

Of course.

spider@ppansss01:linux-cm-dev$ ansible-config dump --only-changed
ANSIBLE_PIPELINING(/srv/data/prod/ansible/core/remote/cm/csas/linux-cm-dev/ansible.cfg) = True
ANSIBLE_SSH_ARGS(/srv/data/prod/ansible/core/remote/cm/csas/linux-cm-dev/ansible.cfg) = -4 -o ControlMaster=auto -o ControlPersist=3600s -o GSSAPIAuthentication=no -o PreferredAuthenticatio
ANSIBLE_SSH_CONTROL_PATH(/srv/data/prod/ansible/core/remote/cm/csas/linux-cm-dev/ansible.cfg) = /tmp/ansible-ssh-%%h-%%p-%%r
ANSIBLE_SSH_RETRIES(/srv/data/prod/ansible/core/remote/cm/csas/linux-cm-dev/ansible.cfg) = 3
CACHE_PLUGIN(/srv/data/prod/ansible/core/remote/cm/csas/linux-cm-dev/ansible.cfg) = jsonfile
CACHE_PLUGIN_CONNECTION(/srv/data/prod/ansible/core/remote/cm/csas/linux-cm-dev/ansible.cfg) = ./temp/cache/
CACHE_PLUGIN_PREFIX(/srv/data/prod/ansible/core/remote/cm/csas/linux-cm-dev/ansible.cfg) = json
CACHE_PLUGIN_TIMEOUT(/srv/data/prod/ansible/core/remote/cm/csas/linux-cm-dev/ansible.cfg) = 3600
COLLECTIONS_PATHS(/srv/data/prod/ansible/core/remote/cm/csas/linux-cm-dev/ansible.cfg) = ['/srv/data/prod/ansible/core/remote/cm/csas/linux-cm-dev/collections']
DEFAULT_BECOME(/srv/data/prod/ansible/core/remote/cm/csas/linux-cm-dev/ansible.cfg) = True
DEFAULT_BECOME_ASK_PASS(/srv/data/prod/ansible/core/remote/cm/csas/linux-cm-dev/ansible.cfg) = False
DEFAULT_BECOME_METHOD(/srv/data/prod/ansible/core/remote/cm/csas/linux-cm-dev/ansible.cfg) = sudo
DEFAULT_BECOME_USER(/srv/data/prod/ansible/core/remote/cm/csas/linux-cm-dev/ansible.cfg) = root
DEFAULT_CALLBACK_WHITELIST(/srv/data/prod/ansible/core/remote/cm/csas/linux-cm-dev/ansible.cfg) = ['timer', 'log_plays', 'foreman', 'profile_tasks']
DEFAULT_FORKS(/srv/data/prod/ansible/core/remote/cm/csas/linux-cm-dev/ansible.cfg) = 50
DEFAULT_GATHERING(/srv/data/prod/ansible/core/remote/cm/csas/linux-cm-dev/ansible.cfg) = smart
DEFAULT_HOST_LIST(/srv/data/prod/ansible/core/remote/cm/csas/linux-cm-dev/ansible.cfg) = ['/srv/data/prod/ansible/core/remote/cm/csas/linux-cm-dev/inventory']
DEFAULT_JINJA2_EXTENSIONS(/srv/data/prod/ansible/core/remote/cm/csas/linux-cm-dev/ansible.cfg) = jinja2.ext.do
DEFAULT_LOAD_CALLBACK_PLUGINS(/srv/data/prod/ansible/core/remote/cm/csas/linux-cm-dev/ansible.cfg) = True
DEFAULT_LOG_PATH(/srv/data/prod/ansible/core/remote/cm/csas/linux-cm-dev/ansible.cfg) = /srv/data/prod/ansible/core/remote/cm/csas/linux-cm-dev/log/ansible.log
DEFAULT_MANAGED_STR(/srv/data/prod/ansible/core/remote/cm/csas/linux-cm-dev/ansible.cfg) = Ansible managed: {file}
DEFAULT_NO_TARGET_SYSLOG(/srv/data/prod/ansible/core/remote/cm/csas/linux-cm-dev/ansible.cfg) = False
DEFAULT_PRIVATE_KEY_FILE(/srv/data/prod/ansible/core/remote/cm/csas/linux-cm-dev/ansible.cfg) = /srv/data/prod/ansible/core/remote/cm/csas/linux-cm-dev/secrets/id_rsa
DEFAULT_REMOTE_USER(/srv/data/prod/ansible/core/remote/cm/csas/linux-cm-dev/ansible.cfg) = spider
DEFAULT_SCP_IF_SSH(/srv/data/prod/ansible/core/remote/cm/csas/linux-cm-dev/ansible.cfg) = True
DEFAULT_STRATEGY(/srv/data/prod/ansible/core/remote/cm/csas/linux-cm-dev/ansible.cfg) = host_pinned
DEFAULT_SYSLOG_FACILITY(/srv/data/prod/ansible/core/remote/cm/csas/linux-cm-dev/ansible.cfg) = user.notice
DEFAULT_TIMEOUT(/srv/data/prod/ansible/core/remote/cm/csas/linux-cm-dev/ansible.cfg) = 10
DEFAULT_TRANSPORT(/srv/data/prod/ansible/core/remote/cm/csas/linux-cm-dev/ansible.cfg) = ssh
DEFAULT_VAULT_PASSWORD_FILE(/srv/data/prod/ansible/core/remote/cm/csas/linux-cm-dev/ansible.cfg) = /srv/data/prod/ansible/core/remote/cm/csas/linux-cm-dev/secrets/vault.passwd
DIFF_ALWAYS(/srv/data/prod/ansible/core/remote/cm/csas/linux-cm-dev/ansible.cfg) = True
HOST_KEY_CHECKING(/srv/data/prod/ansible/core/remote/cm/csas/linux-cm-dev/ansible.cfg) = False
RETRY_FILES_ENABLED(/srv/data/prod/ansible/core/remote/cm/csas/linux-cm-dev/ansible.cfg) = True
RETRY_FILES_SAVE_PATH(/srv/data/prod/ansible/core/remote/cm/csas/linux-cm-dev/ansible.cfg) = /srv/data/prod/ansible/core/remote/cm/csas/linux-cm-dev/retry

As I said output works for ansible 2.9.4 - we have folder on NFS share so ansible.cfg and plays/roles are the same in all cases. Just ansible istallations (binaries/modules) are local.

Thank you.

@samdoran
Copy link
Contributor

Thank you. That should be enough for further investigation.

@bcoca
Copy link
Member

bcoca commented Apr 21, 2021

for some reason delegated vars are not being passed, but in any case we should not need em.

index 229728aa22..63e94b8b98 100644
--- a/lib/ansible/plugins/callback/__init__.py
+++ b/lib/ansible/plugins/callback/__init__.py
@@ -105,9 +105,8 @@ class CallbackBase(AnsiblePlugin):
         result.
         """
         hostname = result._host.get_name()
-        delegated_vars = result._result.get('_ansible_delegated_vars', None)
-        if delegated_vars:
-            return "%s -> %s" % (hostname, delegated_vars['ansible_host'])
+        if result._task.delegate_to:
+            return "%s -> %s" % (hostname, result._task.delegate_to)
         return "%s" % (hostname,)

     def _run_is_verbose(self, result, verbosity=0):```

@ansible ansible locked and limited conversation to collaborators May 26, 2021
@sivel sivel removed the needs_verified This issue needs to be verified/reproduced by maintainer label Feb 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.9 This issue/PR affects Ansible v2.9 bug This issue/PR relates to a bug. P3 Priority 3 - Approved, No Time Limitation python3 support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants