variable expansion in dict

Hi,

On my dictionary I need to use a variable to assign the same value on multiple keys so that I only need to update it in one place, but unfortunately results in variable is undefined. I’ve already read that this is not possible (forgot the source) is there a way to tell Ansible to do variable expansion inside dict?

Regards

Jeff

  • hosts: localhost
    vars:
    containers:
    container1:
    version: “1.1.1”
    image: “myimage1:{{version}}”
    container2:
    version: “2.2.2”
    image: “myimage2:{{version}}”
    tasks:
  • debug:
    msg: “{{containers}}”

result is ‘version’ is undefined

This could help you:

https://docs.ansible.com/ansible/latest/user_guide/playbooks_advanced_syntax.html#id2

Thanks the anchors did help