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?
This pops up in a significant share of my scripts:
Is there any way to shortcut this to something shorter like
or somesuch?
In inventory
[local]
localhost ansible_connection=local
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