Run Ansible Playbooks On Your Localhost Machine

In this post, I will show you how to run Ansible playbooks on your localhost machine only which will help test Ansible with a very basic setup.

Localhost

When you don’t have access to a managed machine, you can use your Ansible host to run playbooks against itself. This is also good for learning purposes.

The process is not complicated and works very well. To get it done, all we need to do is create an inventory file or use an existing one and add our localhost, as shown below.

Inventory File

Below is my inventory file, which has a host group called mylocalhost. I also have my localhost listed as a managed host, and the most important part I tell Ansible is a local connection.

[mylocalhost]
localhost ansible_connection=local

Once the inventory file and configuration are in place I can run any playbook or a single command using the following command.

ansible mylocalhost -m ping -i servers

If you need to install Ansible on Ubuntu 20.04check this post.

Processing…
Success! You're on the list.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.