if you enable gathering fatcs is true, you can call the hostname like below.
- hosts: all
gather_facts: yes
tasks:
- debug: msg='{{ inventory_hostname }}'
Note; Inventory_hostname will give you the hostname of the remote server
where your task is exeucting, it will work for localhost also
On Friday, 10 June 2016 18:11:59 UTC+5:30, pall wrote:
>
> Hi,
>
> I have a file in which i need to replace <hostname> worrd with hostname of
> my machine.
> I am trying below code and getting error.
> Pls let me know ho can i do this .. i am new to ansible
>
> - name: hostame
> shell: hostname
> register: hostnameoutput
> - debug: mesg='{{ hostnameoutput }}'
>
> - name: replace hostname
> replace: dest=/root/test1 regexp=hostname replace={{ hostnameoutput }}
>
>
--
You received this message because you are subscribed to the Google Groups
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.