# Adding dict key + value

**URL:** <https://forum.ansible.com/t/adding-dict-key-value/19476>\
**Category:** Ansible Project\
**Created:** [October 9, 2015, 9:41pm UTC](https://forum.ansible.com/t/adding-dict-key-value/19476 "2015-10-09T21:41:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guy\_Knights](https://avatars.discourse-cdn.com/v4/letter/g/db5fbb/32.png) [@Guy\_Knights](https://forum.ansible.com/u/Guy_Knights)\
**Post date:** [October 9, 2015, 9:41pm UTC](https://forum.ansible.com/t/adding-dict-key-value/19476/1 "2015-10-09T21:41:10Z")

</div>

I’m trying to add a new key to an existing dictionary but I’m having some trouble. I have this set\_fact task:

`

- set\_fact:  
ha.listeners.backends[item.key].servers=“{{ groups[item.key] }}”  
with\_dict: ha.listeners.backends  
`

It runs through without complaining, but when I debug the car there’s new data isn’t in the dict. Is it even possible to do what I’m trying to do?

Thanks,  
Guy

---

<div class="post-metadata">

**Author:** ![Guy\_Knights](https://avatars.discourse-cdn.com/v4/letter/g/db5fbb/32.png) [@Guy\_Knights](https://forum.ansible.com/u/Guy_Knights)\
**Post date:** [October 13, 2015, 5:32pm UTC](https://forum.ansible.com/t/adding-dict-key-value/19476/2 "2015-10-13T17:32:39Z")

</div>

Apologies, ‘the car’ should be ‘the var’, in case it’s not obvious.
