Using Ansible for local environment configuration

As well as configuring servers, you can use Ansible to configure your own local machine and development environment.

The change that you need to make is within the hosts.ini file:

127.0.0.1 ansible_connection=local

Instead of the server's IP address or hostname, use the localhost IP address and set ansible_connection to local to tell Ansible to run locally instead of using an SSH connection.

Another way to do this is to set hosts: 127.0.0.1 and connection: true in your playbook.

Once this is done, you can run tasks, roles, and collections to automate tasks such as installing software, adding your SSH keys, configuring your project directories, and anything else that you need to do.

For an example of this, you can see my dotfiles repository on GitHub.


Want to learn more about how I use Ansible? Register for my upcoming free email course.

- Oliver

P.S. Are you still using Drupal 7 and don’t know what’s involved to upgrade to Drupal 10? Book a Drupal 7 upgrade consultation call or an upgrade roadmap.

Was this useful?

Sign up here and get more like this delivered straight to your inbox every day.

About me

Picture of Oliver

I'm an Acquia-certified Drupal Triple Expert with 17 years of experience, an open-source software maintainer and Drupal core contributor, public speaker, live streamer, and host of the Beyond Blocks podcast.