variable expansion in dict

31 views
Skip to first unread message

Jff Frm

unread,
Feb 6, 2021, 2:28:48 PM2/6/21
to Ansible Project
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

Dick Visser

unread,
Feb 6, 2021, 6:51:52 PM2/6/21
to ansible...@googlegroups.com
This could help you:


--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/118349c9-ddd1-45d7-82e8-b1c9ae711d7an%40googlegroups.com.
--
Sent from a mobile device - please excuse the brevity, spelling and punctuation.

Jff Frm

unread,
Feb 8, 2021, 10:38:24 AM2/8/21
to Ansible Project
Thanks the anchors did help
Reply all
Reply to author
Forward
0 new messages