# overwrite dictionary variables in playbooks

**URL:** <https://forum.ansible.com/t/overwrite-dictionary-variables-in-playbooks/19417>\
**Category:** Ansible Project\
**Created:** [October 2, 2015, 1:36pm UTC](https://forum.ansible.com/t/overwrite-dictionary-variables-in-playbooks/19417 "2015-10-02T13:36:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cosbug](https://avatars.discourse-cdn.com/v4/letter/c/13edae/32.png) [@cosbug](https://forum.ansible.com/u/cosbug)\
**Post date:** [October 2, 2015, 1:36pm UTC](https://forum.ansible.com/t/overwrite-dictionary-variables-in-playbooks/19417/1 "2015-10-02T13:36:51Z")

</div>

Hi All,

I have something like this defined in vars which is being passed as ‘instance.volumes’ variable later in tasks like this volumes: “{{ instance.volumes }}”.

`

instance:  
volumes:

- device\_name: /dev/sda1  
`

And I need in playbook during execution time to replace ‘/dev/sda1’ value with dynamically generated value. The below approach doesn’t work.

`set_fact: instance.volumes[0].device_name="{{ new_root_dev }}"`

Is the any way to overwrite a key in dictionary ?

Regards,  
Constantin
