# Dict converted to string in 2.19

**URL:** <https://forum.ansible.com/t/dict-converted-to-string-in-2-19/45119>\
**Category:** Get Help\
**Created:** [January 16, 2026, 7:59pm UTC](https://forum.ansible.com/t/dict-converted-to-string-in-2-19/45119 "2026-01-16T19:59:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mikemorency](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mikemorency/32/2672_2.png) [@mikemorency](https://forum.ansible.com/u/mikemorency)\
**Post date:** [January 16, 2026, 7:59pm UTC](https://forum.ansible.com/t/dict-converted-to-string-in-2-19/45119/1 "2026-01-16T19:59:51Z")

</div>

I just ran a playbook I have not run in awhile, and 2.19 bit me 🙂 I cant figure out how to re-write this and make it work again. Any help would be appreciated.

I have a group\_vars file that has data like this:

```auto
__ds_defaults:
  clob: false
  connectionLimit: -1
  validate: false

my_config:
  ds_sources: >
    {
      {% for ds_name, ds_values in __env_ds.items() %}
        '{{ ds_name }}': {{
          __ds_defaults |
          combine(ds_values)|
          combine({
            'some_url': 'https://' + ds_values.host + ':' + ds_values.port 
          })
        }},
      {% endfor %}
    }

```

And then my playbook will define some `__env_ds` like

```auto
__env_ds:
  one:
    a: 1
    host: example.com
    port: 443
    clob: true

```

When I ran my playbook, I would use `copy` to dump `my_config | to_nice_json` to a file. `ds_sources` would be rendered as a dict/object in the json as expected.

With 2.19, its being rendered as a string in the config file. What can I do to fix this?

---

<div class="post-metadata">

**Author:** ![felixfontein](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/felixfontein/32/7530_2.png) [@felixfontein](https://forum.ansible.com/u/felixfontein)\
**Post date:** [January 16, 2026, 8:53pm UTC](https://forum.ansible.com/t/dict-converted-to-string-in-2-19/45119/2 "2026-01-16T20:53:54Z")

</div>

```yaml
- hosts: localhost
  tasks:
    - debug:
        msg: "{{ my_config }}"
  vars:
    __ds_defaults:
      clob: false
      connectionLimit: -1
      validate: false
    __env_ds:
      one:
        a: 1
        host: example.com
        port: 443
        clob: true
    my_config: |-
      {% set my_var_tmp = {} %}
      {% for ds_name, ds_values in __env_ds.items() %}
      {% set _ = my_var_tmp.update(
          {ds_name:
             __ds_defaults |
             combine(ds_values)|
             combine({
              'some_url': 'https://' ~ ds_values.host ~ ':' ~ ds_values.port 
             })
          }
      ) %}
      {% endfor %}
      {{ my_var_tmp }}

```

(Based on something similar @bvitnik posted on Matrix a day ago or so 🙂 )

---

<div class="post-metadata">

**Author:** ![mikemorency](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mikemorency/32/2672_2.png) [@mikemorency](https://forum.ansible.com/u/mikemorency)\
**Post date:** [January 16, 2026, 9:00pm UTC](https://forum.ansible.com/t/dict-converted-to-string-in-2-19/45119/3 "2026-01-16T21:00:53Z")

</div>

It works 🥹. thanks @felixfontein and @bvitnik!

I found an open issue on the ansible repo that had something similar but for lists. I couldnt get it to work and was about to try something completely different. Amazing stuff

---

<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 15, 2026, 9:01pm UTC](https://forum.ansible.com/t/dict-converted-to-string-in-2-19/45119/4 "2026-02-15T21:01:14Z")

</div>

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