How to get the hostname into jinja file

Hi Folks,

Thank you for reading this.

My expectation is to get the hostname from the inventory file, please help how to get this.

Jinjafile :

teaserverurl: “http://{{tibcoteahost}}:8777/tea”

vars file :

tibco_tea_group: “{{ groups[‘tibco_tea’] | default(ansible_play_hosts) | sort }}”
tibcoteahost: >
“{% for server in tibco_tea_group -%}
{{ hostvars.get(server).ansible_all_ipv4_addresses }}
{% endfor %}”

inventory file:

Hi,

Are you looking to set the url on each server during playbook execution ? You can use magic variable inventory_hostname to dynamically get hostname during play execution.

teaserverurl: “http://{{ inventory_hostname }}:8777/tea”