# hostname supplied on the cmd line

**URL:** <https://forum.ansible.com/t/hostname-supplied-on-the-cmd-line/13386>\
**Category:** Ansible Project\
**Created:** [August 30, 2013, 12:21am UTC](https://forum.ansible.com/t/hostname-supplied-on-the-cmd-line/13386 "2013-08-30T00:21:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Birdsong](https://avatars.discourse-cdn.com/v4/letter/d/bb73d2/32.png) [@David\_Birdsong](https://forum.ansible.com/u/David_Birdsong)\
**Post date:** [August 30, 2013, 12:21am UTC](https://forum.ansible.com/t/hostname-supplied-on-the-cmd-line/13386/1 "2013-08-30T00:21:38Z")

</div>

I have a situation I’m positive is not very unique where I’d like to leverage Ansible to set the hostname of a node upon intial setup post it’s installation. The node where I call the ansible playbook from is using the proper hostname as the names are pre-generated, pre-known, already resolvable via DNS.

Could the calling script inject the names into the standard gathered facts? I know I could use reverse DNS to get going, but it sure seems like there’s some shortcut that everybody else uses that I’m not aware of.

---

<div class="post-metadata">

**Author:** ![David\_Birdsong](https://avatars.discourse-cdn.com/v4/letter/d/bb73d2/32.png) [@David\_Birdsong](https://forum.ansible.com/u/David_Birdsong)\
**Post date:** [August 30, 2013, 12:24am UTC](https://forum.ansible.com/t/hostname-supplied-on-the-cmd-line/13386/2 "2013-08-30T00:24:07Z")

</div>

I just tried more searches and I think I found it: $inventory\_hostname

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [August 30, 2013, 12:54am UTC](https://forum.ansible.com/t/hostname-supplied-on-the-cmd-line/13386/3 "2013-08-30T00:54:23Z")

</div>

Yep, you should do {{ inventory\_hostname }} though, to use the newstyle variable system.

It becomes easier if you want to use more complex data later.
