Configuring Ansible to run on localhost

Since ansible-pull relies on Git to locally clone the repository and execute it, we don't need the execution to happen over SSH. Go to the root directory of your Ansible repository to create a new file. The file should be called localhost and it should contain the following:

[localhost] 
localhost ansible_connection=local 

Essentially, what we are doing is creating a static inventory and asking ansible to run commands in local mode (as opposed to using SSH) when the target host is localhost. We can save the changes and commit the new file to GitHub as follows:

$ git add localhost
$ git commit -m "Adding localhost inventory"
$ git push 

Get Effective DevOps with AWS - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.