|
up vote
down votefavorite
|
I have this inventory file
inventory/hosts_elk<br>[elk-client-0]<br>10.11.22.22<br><br>
Now I have a template, and I want to do this
elk_server.yml.j2<br>elk_server = {{ elk-client-0 }}<br><br>
But that doesn’t work, that is the value for {{ elk-client-0 }} does NOT get substituted.
What is the correct syntax so when the template gets laid out on the server, the resulting file looks like<br>elk_server = 10.11.22.22<br><br>
|
Those aren’t variables.
You defined a group called ‘elk-client-0’ with a nameless server in it.
This template will produce the output you want:
elk_server = {{ groups['elk-client-0'][0] }}
Though I’m a bit confused why you have an elk server in a group called ‘elk-client-0’.
Thanks, that worked! It makes sense now.