# ansible with elastic search with Jinja2 Template

**URL:** <https://forum.ansible.com/t/ansible-with-elastic-search-with-jinja2-template/27274>\
**Category:** Ansible Project\
**Created:** [April 13, 2018, 2:51pm UTC](https://forum.ansible.com/t/ansible-with-elastic-search-with-jinja2-template/27274 "2018-04-13T14:51:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bishwajit\_Samanta](https://avatars.discourse-cdn.com/v4/letter/b/8e7dd6/32.png) [@Bishwajit\_Samanta](https://forum.ansible.com/u/Bishwajit_Samanta)\
**Post date:** [April 13, 2018, 2:51pm UTC](https://forum.ansible.com/t/ansible-with-elastic-search-with-jinja2-template/27274/1 "2018-04-13T14:51:31Z")

</div>

Hi, my question is ::--------------------------------

My ansible script will be running for multiple systems. But in elasticsearch.jinja2 how can i change the value of node.name for different systems.

Jinja 2 Code::-

---

<div class="post-metadata">

**Author:** ![Bishwajit\_Samanta](https://avatars.discourse-cdn.com/v4/letter/b/8e7dd6/32.png) [@Bishwajit\_Samanta](https://forum.ansible.com/u/Bishwajit_Samanta)\
**Post date:** [April 13, 2018, 5:56pm UTC](https://forum.ansible.com/t/ansible-with-elastic-search-with-jinja2-template/27274/2 "2018-04-13T17:56:56Z")

</div>

Can anyone help me in my problem please ?

---

<div class="post-metadata">

**Author:** ![Larry\_Smith1](https://avatars.discourse-cdn.com/v4/letter/l/d26b3c/32.png) [@Larry\_Smith1](https://forum.ansible.com/u/Larry_Smith1)\
**Post date:** [April 14, 2018, 4:55am UTC](https://forum.ansible.com/t/ansible-with-elastic-search-with-jinja2-template/27274/3 "2018-04-14T04:55:49Z")

</div>

You can use:  
`node.name: {{ansible_hostname}}`

Which will use the hostname defined on the remote host.

Or you can use:

`node.name:{{inventory_hostname}}`

Which will use the inventory hostname defined in your Ansible inventory.

For reference:  
[https://github.com/mrlesmithjr/ansible-elasticsearch/blob/master/defaults/main.yml#L74](https://github.com/mrlesmithjr/ansible-elasticsearch/blob/master/defaults/main.yml#L74)

Hope this helps.

---

<div class="post-metadata">

**Author:** ![Bishwajit\_Samanta](https://avatars.discourse-cdn.com/v4/letter/b/8e7dd6/32.png) [@Bishwajit\_Samanta](https://forum.ansible.com/u/Bishwajit_Samanta)\
**Post date:** [April 14, 2018, 5:10am UTC](https://forum.ansible.com/t/ansible-with-elastic-search-with-jinja2-template/27274/4 "2018-04-14T05:10:21Z")

</div>

Thanks Larry for such great help… i hope this solves my problem. !! 🙂
