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"*


On Friday, June 25, 2021 at 3:34:08 PM UTC+5:30 [email protected] 
wrote:

> 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:
> ---
> all:
>   vars:
>     ansible_connection: ssh
>     ansible_user: pibco
>   children:
>     tibco:
>       vars:
>         tibco_user: pibco
>         tibco_group: pibgrp
>         ansible_ssh_pass: Maddy1600
>       hosts:
>         tomlap01195.:
>     tibco_tea:
>       vars:
>         tibco_user: pibco
>         tibco_group: pibgrp
>         ansible_ssh_pass: Maddy1600
>       hosts:
>         tomlap04090.corp:
>     local:
>       hosts:
>         localhost:
>           ansible_connection: local
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/f799e66d-0c18-447b-846a-b8760f94da52n%40googlegroups.com.

Reply via email to