Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
How to run an Ansible playbook locally
  • using Ansible command line:
ansible-playbook --connection=local playbook.yml
  • using inventory: ansible_connection=local
  • using Ansible configuration file:
transport = local
  • using playbook header:
- hosts:
  connection: local
Copy link

k-popov commented Oct 15, 2018

The first option only works as ansible-playbook --connection=local --inventory, playbook.yml
Comma is essential, otherwise it's treated like file name.

Copy link

Thanks! Bookmarked :-)

Copy link

wazcov commented Nov 28, 2019

which is recommended or best practice?

Copy link

alces commented Nov 29, 2019

I don't know anything about official best practices, but by myself most often use the last variant (i.e., playbook header).

Copy link

q2dg commented Jan 12, 2020

But if I have'nt understood this badly (, it isn't necessary to indicate explicitely the connection type: just writing "localhost" as target will make Ansible to infer it has to make a "local" connection, isn't?

Copy link

alces commented Jan 13, 2020

I'm not sure it worked this way in all versions of Ansible I'd previously coded for, so I used to always add connection: local just to make sure that the connection will not go through SSL.

Copy link

ansible-playbook -c local -i localhost, ini.yaml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment