overwrite dictionary variables in playbooks

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