Is there a way to shortcut local host?

86 views
Skip to first unread message

ghe...@gmail.com

unread,
Apr 28, 2014, 12:15:16 PM4/28/14
to ansible...@googlegroups.com
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?

Michael DeHaan

unread,
Apr 28, 2014, 12:47:14 PM4/28/14
to ansible...@googlegroups.com
In inventory

[local]
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/5f272bfb-2ec2-4631-8224-41a861316ddf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jesse Keating

unread,
Apr 28, 2014, 3:07:01 PM4/28/14
to ansible...@googlegroups.com
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
Reply all
Reply to author
Forward
0 new messages