# Variable interpolation syntax

**URL:** <https://forum.ansible.com/t/variable-interpolation-syntax/38831>\
**Category:** Ansible Project\
**Tags:** vmware\
**Created:** [July 24, 2024, 1:59pm UTC](https://forum.ansible.com/t/variable-interpolation-syntax/38831 "2024-07-24T13:59:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chris\_Bachmeyer](https://avatars.discourse-cdn.com/v4/letter/c/3e96dc/32.png) [@Chris\_Bachmeyer](https://forum.ansible.com/u/Chris_Bachmeyer)\
**Post date:** [July 24, 2024, 1:59pm UTC](https://forum.ansible.com/t/variable-interpolation-syntax/38831/1 "2024-07-24T13:59:29Z")

</div>

Hi, community,

I’m setting a fact there to grab the JSON dict of the template from the content library.

- name: vm-create | Use the name to identify library item  
set\_fact:  
rhel8\_9template: “{{ lib\_items.value | selectattr(‘name’, ‘equalto’, ‘rhel8-9template’)|first }}”

Next, I am using the variable “{{ rhel8\_9template.id }}” to feed in the template id to the template\_library\_item: parameter, part of the overall task.

- name: vm-create | Create virtual machine from Content Library  
vmware.vmware\_rest.vcenter\_vmtemplate\_libraryitems:  
vcenter\_hostname: “{{ hostname }}”  
vcenter\_password: “{{ survey\_password }}”  
vcenter\_validate\_certs: false  
name: “{{ survey\_vm\_name }}”  
library: “{{ library\_id }}”  
template\_library\_item: “{{ rhel8\_9template.id }}”

This does work but I want to set a few more facts based on the available operating systems such as rhel9. I want to set a survey variable to allow admins to choose the OS to deploy.

I tried two variable syntax structure, neither seem to work. I need to pull the id from the respective OS.

template\_library\_item: “{{ vars[‘survey\_os’].id }}”  
template\_library\_item: “{{ survey\_os[.id] }}”

What am I missing here? Thanks!
