Playbook fails using "dict2items"

Hi :wave:
I have issues with dict2items. It fails on my proxmox ubuntu VMs.
The test playbook I use is following:

- name: Test loop with lists
  hosts: localhost
  gather_facts: no
  vars:
    test:
      test_key_1:
        - list_item_1
        - list_item_2
        - list_item_3
      test_key_2:
        - list_item_1
        - list_item_2
        - list_item_3

  tasks:
    - name: Show test_items
      ansible.builtin.debug:
        msg: "{{ test | dict2items }}"

Ansible only gives following output:

ansible-playbook test2.yml

PLAY [Test loop with lists] ***************************************************************************************************************************************************

TASK [Show test_items] ********************************************************************************************************************************************************
usage: ansible-playbook [-h] NEW OLD OLD_VER OUTPUT
ansible-playbook: error: the following arguments are required: OLD, OLD_VER, OUTPUT
ERROR! A worker was found in a dead state

I also tested it on a VPS which also has ubuntu installed and there it’s working fine.
Output of ansible on VPS:

ansible-playbook test.yml

PLAY [Test loop with lists] ***************************************************************************************************************************************************

TASK [Show test_items] ********************************************************************************************************************************************************
ok: [localhost] => {
    "msg": [
        {
            "key": "test_key_1",
            "value": [
                "list_item_1",
                "list_item_2",
                "list_item_3"
            ]
        },
        {
            "key": "test_key_2",
            "value": [
                "list_item_1",
                "list_item_2",
                "list_item_3"
            ]
        }
    ]
}

PLAY RECAP ********************************************************************************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

The python interpreter and ansible is everywhere the same:

ansible --version
ansible [core 2.18.1]
  config file = /opt/test/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /opt/test/venv/lib/python3.12/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /opt/test/venv/bin/ansible
  python version = 3.12.3 (main, Jan 17 2025, 18:03:48) [GCC 13.3.0] (/opt/test/venv/bin/python3)
  jinja version = 3.1.4
  libyaml = True

DMESG and journalctl is also showing no related errors.

Has someone an idea what’s going on or can help me debug the issue further?

Hi @DarkPhily this seems to be highly dependant on the environment. It’s gonna be hard for anyone here to say why one of your environments has a problem and the other has not.

I would suggest comparing the envs but you have already checked the versions are the same. Maybe something useful comes out running that with -vvvv ?

Hi @russoz,

Unfortunately this is not providing any useful information either. I know it is specific to the environment.

I have access to two different VMs on that Proxmox cluster. One with non-root privileges and one with root privileges. The issue exists on both of them. I also doubt that Proxmox itself is causing the issue.

I created a quick test Proxmox cluster and spun up a ubuntu VM there. There the test playbook also works fine.

For me it would be interesting why the forked process is dying immediately. Since the fork process is inheriting basically everything from the parent process and the parent process ansible-playbook test.yml is running fine I don’t get why the fork is dying.

You have an idea how to get the traceback of the fork? I believe this could help finding the root cause.

I have not delved that deep into the internals of it, but it does sound like something for Ansible Core devs to take a look at. @mattclay would you be able to point @DarkPhily here to the right direction? TIA

1 Like

I finally figured out the issue…
It’s embarassingly stupid.

On the failing VMs I had an ansible.cfg file with following line:

filter_plugins = ~/.ansible/plugins/filter:/usr/share/ansible/plugins/filter:

Since these directories didn’t exist the task failed while looking up the dict2items filter.

Maybe ansible-core could provide a better error message regarding that :sweat_smile:

1 Like

Missing filter directories are ignored by ansible-core. I think the issue is the trailing :, which adds the current working directory to the filter search path.

filter_plugins = ~/.ansible/plugins/filter:/usr/share/ansible/plugins/filter
2 Likes