Name Last Update
bin Loading commit data...
provisioning Loading commit data...
shared Loading commit data...
.gitignore Loading commit data... Loading commit data... Loading commit data...
Vagrantfile Loading commit data...
inventory.soe Loading commit data...


  • MIT, see


Vagrant Kitchen is a way to simplify the quick provisioning of an environment for testing ansible playbooks.

The key points are:

  • The Vagrant file is adapted to use an Ansible inventory file

This is done by:

  • The key file in this construct is ./inventory, which normally is a symlink to the file/environment you are currently working on.
  • The Vagrant file calls bin/inventory.rb, which translates the "inventory" file into a JSON structure.
  • The JSON structure is used in the Vagrant file to set up the necessary VMs with the wanted resources (cpus, RAM, IP address, vagrant box image).
Vagrant Kitchen:

+-------------+     +------------------+
| Vagrantfile |---->| bin/inventory.rb |
+-------------+     +------------------+
                      +-------------+            +---------------+
                      |  inventory  | -symlink-> | inventory.soe |
                      +-------------+            +---------------+
Your Ansible              symlink    
repo:                        |
                   | inventory.vagrant |

To make this work, you will need to do the following:

  • Create an inventory file called "inventory" by copying the sample file, or create a soft link to an already existing inventory file
ln -s inventory.soe inventory
  • The inventory file is using ansible inventory "ini" style format. See the content of the template "inventory.soe"
  • The inventory file will need at least the IP address as a host variable for each host.
  • Optional host variables are:

    • vagrant_ram (defaulting to 256)
    • vagrant_image (defaulting to ubuntu/trusty64 if not set)
  • Test that you have a proper inventory file by running:

bin/ --list

inventory files

Ansible variables to control the Vagrant box

These variables can be used, for example to set the ip to, the box image to soe-linux-kmg, RAM to 512 MB, and the cpu count to 2. The Vagrant box will be fetched from the Hashicorp Atlas repository.

  • ansible_ssh_host=
  • vagrant_image=kmggroup/soe-linux-kmg
  • vagrant_ram=512
  • vagrant_cpu=2

Example (simplified) config:

soe ansible_ssh_host= vagrant_image=kmggroup/soe-linux-kmg vagrant_ram=512 ansible_user=ops





Please note 3 points:

  • The group "ubuntu" is the default group, in which all servers you want to install should be put as well as in the group "vagrant-kitchen".
  • If you want to test ansible scripts that require a server to be member of a group, add the group as seen in the "soe" example above
  • The ansible_ssh_host host variable will set the ip addresses of your servers

If you run ansible scripts from here or from a different place does not matter, as long as you make a symlink to the vagrant-kitchen inventory in your base directory for Ansible (where your group_vars directory is placed).

Example - symlink

malu@kmg-mcp001.local:/Users/malu/dev/vagrant-kitchen $ls -la inventory*
lrwxr-xr-x  1 malu  staff   13 Mar 20 11:53 inventory -> inventory.soe
-rw-r--r--  1 malu  staff  668 Mar 20 11:59 inventory.soe

Example - tie an Ansible repo to a Vagrant Kitchen

cd ~/path/to/my/ansible/repo
ln -s ~/path/to/vagrant-kitchen/inventory inventories/inventory.vagrant

Example - (from a different repo):

cd ~/path/to/my/ansible/repo
ansible-playbook -i ./inventories/inventory.vagrant playbooks/soe-linux.yml