Skip to content

Commit e63930e

Browse files
committed
Added Vagrant support
1 parent f5fb49a commit e63930e

File tree

3 files changed

+62
-4
lines changed

3 files changed

+62
-4
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
*~
2+
3+
#Vagrant Files
4+
.vagrant/*

README.rst

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,16 +205,24 @@ If you'd like to help with the project itself, here are some other ways you can
205205

206206
Testing
207207
~~~~~~~
208+
This role includes a Vagrantfile used with a Docker-based test harness for integration testing. Using Vagrant allows all contributors to test on the same platform and avoid false test failures due to untested or incompatible docker versions.
208209

209-
This role includes a Docker-based test harness for integration testing.
210+
1. Install `Vagrant <https://www.vagrantup.com/>`__ and `VirtualBox <https://www.virtualbox.org/>`__.
210211

211-
1. Install `Docker <https://docs.docker.com/engine/installation/>`__ and `Docker Compose <https://docs.docker.com/compose/>`__.
212+
2. Run ``vagrant up`` from the same directory as the Vagrantfile in this repository.
212213

213-
2. Run tests with ``make``.
214+
3. SSH into the VM with: ``vagrant ssh`` or ``ssh 127.0.0.1:2222`` or ``ssh 10.1.15.10``
214215

215-
::
216+
4. Change directories into **/vagrant** with the command: ``cd /vagrant``
217+
218+
5. Test the role against each Dockerfile with ``make``:
219+
220+
::
216221

217222
make jessie64 test
223+
make centos7 test
224+
make xenial64 test
225+
218226

219227
Integration tests use **systemd** by default. Set ``PROCESS_CONTROL`` to change this:
220228

Vagrantfile

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Defines our Vagrant environment
2+
#
3+
# -*- mode: ruby -*-
4+
# vi: set ft=ruby :
5+
6+
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
7+
VAGRANTFILE_API_VERSION = "2"
8+
9+
my_machines={
10+
# 'hostname' => ['IPAddress','Memory in MB','Number of CPUs'],
11+
'node1' => ['10.1.15.10','1024','1']
12+
}
13+
14+
$setupScript = <<SCRIPT
15+
echo provisioning docker...
16+
sudo apt-get update
17+
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
18+
sudo apt-add-repository 'deb https://apt.dockerproject.org/repo ubuntu-trusty main'
19+
sudo apt-get update
20+
sudo apt-get -o Dpkg::Options::="--force-confnew" install --force-yes -y docker-engine=1.10.2-0~trusty
21+
sudo usermod -a -G docker vagrant
22+
curl -L "https://github.com/docker/compose/releases/download/1.6.2/docker-compose-$(uname -s)-$(uname -m)" > /usr/local/bin/docker-compose
23+
chmod +x /usr/local/bin/docker-compose
24+
docker version
25+
26+
docker-compose version
27+
SCRIPT
28+
29+
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
30+
config.vm.box = "bento/ubuntu-14.04"
31+
32+
my_machines.each do |short_name, array|
33+
34+
config.vm.define short_name do |host|
35+
host.vm.network 'private_network', ip: array[0]
36+
host.vm.hostname = "#{short_name}"
37+
host.vm.provider "virtualbox" do |vb|
38+
vb.memory = "#{array[1]}"
39+
vb.cpus = "#{array[2]}"
40+
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
41+
vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
42+
vb.customize ["modifyvm", :id, "--nictype1", "virtio"]
43+
end
44+
host.vm.provision :shell, :inline => $setupScript
45+
end
46+
end
47+
end

0 commit comments

Comments
 (0)