# Playbook fails using "dict2items"

**URL:** <https://forum.ansible.com/t/playbook-fails-using-dict2items/39812>\
**Category:** Get Help\
**Tags:** proxmox, playbook, ubuntu\
**Created:** [January 24, 2025, 2:28pm UTC](https://forum.ansible.com/t/playbook-fails-using-dict2items/39812 "2025-01-24T14:28:42Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![DarkPhily](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/darkphily/32/7284_2.png) [@DarkPhily](https://forum.ansible.com/u/DarkPhily)\
**Post date:** [January 24, 2025, 2:28pm UTC](https://forum.ansible.com/t/playbook-fails-using-dict2items/39812/1 "2025-01-24T14:28:42Z")

</div>

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

```auto
- 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:

```auto
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:

```auto
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:

```auto
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?

---

<div class="post-metadata">

**Author:** ![russoz](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/russoz/32/127_2.png) [@russoz](https://forum.ansible.com/u/russoz)\
**Post date:** [January 26, 2025, 8:51pm UTC](https://forum.ansible.com/t/playbook-fails-using-dict2items/39812/2 "2025-01-26T20:51:33Z")

</div>

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` ?

---

<div class="post-metadata">

**Author:** ![DarkPhily](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/darkphily/32/7284_2.png) [@DarkPhily](https://forum.ansible.com/u/DarkPhily)\
**Post date:** [January 26, 2025, 9:08pm UTC](https://forum.ansible.com/t/playbook-fails-using-dict2items/39812/3 "2025-01-26T21:08:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![russoz](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/russoz/32/127_2.png) [@russoz](https://forum.ansible.com/u/russoz)\
**Post date:** [January 26, 2025, 9:12pm UTC](https://forum.ansible.com/t/playbook-fails-using-dict2items/39812/4 "2025-01-26T21:12:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![DarkPhily](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/darkphily/32/7284_2.png) [@DarkPhily](https://forum.ansible.com/u/DarkPhily)\
**Post date:** [January 27, 2025, 10:12am UTC](https://forum.ansible.com/t/playbook-fails-using-dict2items/39812/5 "2025-01-27T10:12:57Z")

</div>

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

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

```auto
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 😅

---

<div class="post-metadata">

**Author:** ![shertel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/shertel/32/1241_2.png) [@shertel](https://forum.ansible.com/u/shertel)\
**Post date:** [January 27, 2025, 4:15pm UTC](https://forum.ansible.com/t/playbook-fails-using-dict2items/39812/6 "2025-01-27T16:15:01Z")

</div>

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.

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

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [February 26, 2025, 4:15pm UTC](https://forum.ansible.com/t/playbook-fails-using-dict2items/39812/7 "2025-02-26T16:15:32Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
