Get host name from inventory on remote host?

729 views
Skip to first unread message

seanosh

unread,
May 1, 2012, 11:01:31 PM5/1/12
to Ansible Project
Was wondering if there's a way to get the hostname I've specified in
my inventory available as a var for use in a template on the remote
host? Would be useful for setting the hostname properly of a new
server that may have a different hostname defined in the setup
ansible_fqdn or ansible_hostname data... similar to the way
group_names are exposed in the setup data - maybe an
inventory_hostname?

Michael DeHaan

unread,
May 1, 2012, 11:40:25 PM5/1/12
to ansible...@googlegroups.com
We were discussing this on IRC today in fact, not presently, but it's going to be added.

I like inventory_hostname as a suggested name pretty well. I think we were thinking in terms of ansible_connectedname
though inventory_hostname makes better sense.

--Michael

seth vidal

unread,
May 1, 2012, 11:46:25 PM5/1/12
to ansible...@googlegroups.com, michael...@gmail.com
On Tue, 1 May 2012 23:40:25 -0400
Michael DeHaan <michael...@gmail.com> wrote:

> We were discussing this on IRC today in fact, not presently, but it's
> going to be added.
>
> I like inventory_hostname as a suggested name pretty well. I think
> we were thinking in terms of ansible_connectedname though
> inventory_hostname makes better sense.
>

+1 inventory_hostname


-sv

seanosh

unread,
May 2, 2012, 12:23:58 AM5/2/12
to Ansible Project
(realized I replied to author instead of reply)...

That's great news - will keep an eye out for it. Would consider
providing a patch but could use some brushing up on my Python
first...

Loving Ansible so far - coming from Puppet, this is much simpler and
just what I need... keep it up!

On May 1, 11:46 pm, seth vidal <skvi...@fedoraproject.org> wrote:
> On Tue, 1 May 2012 23:40:25 -0400
>

Jeroen Hoekx

unread,
May 2, 2012, 3:56:18 AM5/2/12
to ansible...@googlegroups.com
Good idea. I was using a hostname variable in my playbooks.

I'll take this one (it's a 3 line patch or so)!

Jeroen
Reply all
Reply to author
Forward
0 new messages