Setting up a basic Debian configuration with Ansible

Starting up a new Ruby Sinatra project, I wanted to find a way to experiment with different configurations but also keep a map of what I have already tried so I can wipe it all and try again with no more drama. I chose Vagrant and Ansible for this, two tools I’ve successfully used in the past.

The image I am using is that of Debian 10 which is basic and sophisticated at the same time and will also allow me to deploy to my Raspberry Pi’s.

Both tools can easily be installed in macOS with homebrew and pip.


Installation notes
brew install vagrant 

Homebrew takes care of the dependency installation also like Virtualbox and takes a while to complete.


The Vagrantfile is pretty basic for now:

Vagrant.configure("2") do |config|
  HOST_DIR = "/Users/chrisveleris/projects/paqetz"
  GUEST_DIR= "/home/vagrant/paqetz" = "generic/debian10" "public_network" "private_network", ip: ""

  config.vm.synced_folder HOST_DIR, GUEST_DIR, type: "nfs"

Vagrant will try to find the vagrant box and If it’s not previously downloaded, it will try to download and spin up a new image - then ssh to it.


Installation notes

First install pip for python3. Then ansible:

sudo python3 -m pip install ansible

Create a configuration file in ~/.ansible.cfg:

inventory = .ansible/hosts

Create ~/.ansible/hosts:

[vagrant-box] ansible_user=vagrant

Check out If everything is fine:

ansible vagrant-box -m ping
# or
ansible-playbook provision.yml -m ping

Start provisioning:

ansible-playbook -l vagrant-box provision.yml

What’s next? Setting up an ansible playbook for a new project.