community.general icon indicating copy to clipboard operation
community.general copied to clipboard

'IncludedFile' object has no attribute '_task_fields' when using community.general.elastic callback

Open kees-closed opened this issue 6 months ago • 5 comments

Summary

'IncludedFile' object has no attribute '_task_fields' when looping ansible.builtin.include_tasks and using the community.general.elastic callback.

When using this in a task main:

- name: Setup system foundation
  ansible.builtin.include_tasks: "{{ included_task }}"
  loop:
    - hostname.yml
    - time.yml
    - selinux.yml
    - accounts.yml
    - firewalld.yml
    - authentication.yml
    - networks.yml
  loop_control:
    loop_var: included_task
  tags: always

I get the error below, when using community.general.elastic as a callback plugin.

[WARNING]: Failure using method (v2_playbook_on_include) in callback plugin (<ansible_collections.community.general.plugins.callback.elastic.CallbackModule object at 0x7f01cc044250>): 'IncludedFile' object has no attribute
'_task_fields'

When I remove the looped include task, the warning/failure is gone. My loop_var is maybe the issue? Is this a bug, or am I using ansible.builtin.include_tasks wrong?

Issue Type

Bug Report

Component Name

elastic

Ansible Version

ansible [core 2.18.3]
  config file = /var/home/user/git/ansible/ansible.cfg
  configured module search path = ['/var/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.13/site-packages/ansible
  ansible collection location = /var/home/user/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.13.3 (main, Apr 22 2025, 00:00:00) [GCC 15.0.1 20250418 (Red Hat 15.0.1-0)] (/usr/bin/python3)
  jinja version = 3.1.6
  libyaml = True

Community.general Version

$ ansible-galaxy collection list community.general
# /usr/share/ansible/collections/ansible_collections
Collection        Version
----------------- -------
community.general 10.5.0 

Configuration

CALLBACKS_ENABLED(/var/home/user/git/ansible/ansible.cfg) = ['profile_roles']
CONFIG_FILE() = /var/home/user/git/ansible/ansible.cfg
DEFAULT_BECOME(/var/home/user/git/ansible/ansible.cfg) = True
DEFAULT_BECOME_ASK_PASS(/var/home/user/git/ansible/ansible.cfg) = True
DEFAULT_BECOME_METHOD(/var/home/user/git/ansible/ansible.cfg) = sudo
DEFAULT_FORCE_HANDLERS(/var/home/user/git/ansible/ansible.cfg) = True
DEFAULT_FORKS(/var/home/user/git/ansible/ansible.cfg) = 8
DEFAULT_HOST_LIST(/var/home/user/git/ansible/ansible.cfg) = ['/var/home/user/git/ansible/hosts.cfg']
DEFAULT_JINJA2_EXTENSIONS(/var/home/user/git/ansible/ansible.cfg) = jinja2.ext.loopcontrols
DEFAULT_LOAD_CALLBACK_PLUGINS(/var/home/user/git/ansible/ansible.cfg) = True
DEFAULT_MANAGED_STR(/var/home/user/git/ansible/ansible.cfg) = Ansible managed: {file} modified on %Y-%m-%d %H:%M:%S %z (%Z) by {uid} on {host}
DEFAULT_REMOTE_PORT(/var/home/user/git/ansible/ansible.cfg) = 
DEFAULT_VAULT_PASSWORD_FILE(/var/home/user/git/ansible/ansible.cfg) = /var/home/user/git/ansible/.vault-pass
DIFF_ALWAYS(/var/home/user/git/ansible/ansible.cfg) = True
DIFF_CONTEXT(/var/home/user/git/ansible/ansible.cfg) = 3
EDITOR(env: EDITOR) = /usr/bin/vim
RETRY_FILES_ENABLED(/var/home/user/git/ansible/ansible.cfg) = False

GALAXY_SERVERS:


OS / Environment

Fedora Silverblue 42, running in Toolbox with the same distro.

Steps to Reproduce

- name: Setup system foundation
  ansible.builtin.include_tasks: "{{ included_task }}"
  loop:
    - hostname.yml
    - time.yml
    - selinux.yml
    - accounts.yml
    - firewalld.yml
    - authentication.yml
    - networks.yml
  loop_control:
    loop_var: included_task
  tags: always

Of course those yaml files should exist in the root dir of the task, together with the main which includes this loop.

Expected Results

That it loops, includes tasks and the Elastic callback plugin doesn't run into an error.

Actual Results

[WARNING]: Failure using method (v2_playbook_on_include) in callback plugin (<ansible_collections.community.general.plugins.callback.elastic.CallbackModule object at 0x7f01cc044250>): 'IncludedFile' object has no attribute
'_task_fields'

Code of Conduct

  • [x] I agree to follow the Ansible Code of Conduct

kees-closed avatar May 26 '25 18:05 kees-closed

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

ansibullbot avatar May 26 '25 18:05 ansibullbot

cc @v1v click here for bot help

ansibullbot avatar May 26 '25 18:05 ansibullbot

I guess the problem is in line 404 (https://github.com/ansible-collections/community.general/blob/main/plugins/callback/elastic.py#L404), where included_file is passed in to finish_task()'s result parameter.

felixfontein avatar May 28 '25 18:05 felixfontein

I guess the problem is in line 404 (https://github.com/ansible-collections/community.general/blob/main/plugins/callback/elastic.py#L404), where included_file is passed in to finish_task()'s result parameter.

Is it easily fixable? I'm not familiar with how this is supposed to work.

kees-closed avatar Jun 04 '25 09:06 kees-closed

No idea, sorry. Maybe @v1v can help here?

felixfontein avatar Jun 04 '25 19:06 felixfontein