Hi,
I’m trying to access hostvar in replace module but I could not access the same.
hosts:
Hi,
I’m trying to access hostvar in replace module but I could not access the same.
hosts:
Hi,
the variable syntax seems to be wrong.
Could you please try to replace:
replace: ‘private_ip: {{ hostvars.[serverFqdn][‘host_ip’] }}’
by :
replace: “private_ip: {{ hostvars[serverFqdn][‘host_ip’] }}”
Thanks,
Hi Petetin,
Thanks for your response.
The proposed code fails to get the actual value from hostvar; instead, the code itself placed in the ‘path’.
Result:
cat /tmp/test_params.yaml
private_ip: hostvars[‘server1.com’].host_ip
Looks like we need some other way to eval ‘hostvars[‘server1.com’].host_ip’.
I did try replace: “{{ “private_ip: {{ hostvars[serverFqdn][‘host_ip’] }}”}}” but no luck.
Regards,
Dinesh
Thanks a lot, Petetin.
My bad; the variable format suggested by you works fine. Please ignore my previous email.
Regards,
Dinesh