# Is there a way to shortcut local host?

**URL:** <https://forum.ansible.com/t/is-there-a-way-to-shortcut-local-host/15102>\
**Category:** Ansible Project\
**Created:** [April 28, 2014, 4:15pm UTC](https://forum.ansible.com/t/is-there-a-way-to-shortcut-local-host/15102 "2014-04-28T16:15:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ghexsel](https://avatars.discourse-cdn.com/v4/letter/g/dbc845/32.png) [@ghexsel](https://forum.ansible.com/u/ghexsel)\
**Post date:** [April 28, 2014, 4:15pm UTC](https://forum.ansible.com/t/is-there-a-way-to-shortcut-local-host/15102/1 "2014-04-28T16:15:16Z")

</div>

This pops up in a significant share of my scripts:

- hosts: 127.0.0.1  
connection: local  
gather\_facts: false

Is there any way to shortcut this to something shorter like

- local\_script

or somesuch?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [April 28, 2014, 4:47pm UTC](https://forum.ansible.com/t/is-there-a-way-to-shortcut-local-host/15102/2 "2014-04-28T16:47:14Z")

</div>

In inventory

[local]  
localhost ansible\_connection=local

---

<div class="post-metadata">

**Author:** ![Jesse\_Keating](https://avatars.discourse-cdn.com/v4/letter/j/3bc359/32.png) [@Jesse\_Keating](https://forum.ansible.com/u/Jesse_Keating)\
**Post date:** [April 28, 2014, 7:07pm UTC](https://forum.ansible.com/t/is-there-a-way-to-shortcut-local-host/15102/3 "2014-04-28T19:07:01Z")

</div>

On an individual task level you can do either:

\<modulename\>: \<moduleargs\>  
delegate\_to: localhost

or

local\_action: \<modulename\> \<moduleargs\>

which will do a local action. However it would do this X times, where X == the number of hosts in your hosts: definition for that play.

The most clean way to do a single local action is to do like you've been, create a play with hosts: localhost and the tasks you wish to execute there. Because it really is a separate play, outside the host loop of other plays, you do need the play headers.

As of 1.5, localhost is an implicit member of your inventory, with a default connection of local, so you shouldn't have to specify that bit.

-jlk
