Thanks, that worked! It makes sense now.
On Friday, April 21, 2017 at 1:43:12 PM UTC-4, Dick Davies wrote:
>
> 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'.
>
> On 21 April 2017 at 18:13, ZillaYT <[email protected] <javascript:>> wrote:
>
>> up vote
>> down votefavorite
>> <http://stackoverflow.com/questions/43547313/in-ansible-how-do-i-use-a-variable-in-an-inventory-file-in-a-template#>
>>
>> I have this inventory file
>>
>> inventory/hosts_elk
>>
>> [elk-client-0]
>> 10.11.22.22
>>
>> Now I have a template, and I want to do this
>>
>> elk_server.yml.j2
>>
>> elk_server = {{ elk-client-0 }}
>>
>> 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
>>
>> elk_server = 10.11.22.22
>>
>>
>> --
>> 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 [email protected] <javascript:>.
>> To post to this group, send email to [email protected]
>> <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/06b4ebff-9b5a-42c7-8618-214fb70f78b5%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/ansible-project/06b4ebff-9b5a-42c7-8618-214fb70f78b5%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/3f65a2e2-e704-4aac-b818-1cd99bfc0e7c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.