|
@@ -0,0 +1,48 @@
|
|
1
|
+# The following patch needs to be applied for ansible to run cleanly on vagrant up:
|
|
2
|
+# https://github.com/mitchellh/vagrant/pull/1723.diff on /opt/vagrant/embedded/gems/gems/vagrant-1.2.x
|
|
3
|
+
|
|
4
|
+curdir=File.dirname(__FILE__)
|
|
5
|
+
|
|
6
|
+$boxes = [
|
|
7
|
+ {
|
|
8
|
+ :name => "ansible.local",
|
|
9
|
+ :forwards => { 22 => 22222, 80 => 80, 25 => 25, 143 => 143, 465 => 465, 993 => 993 }
|
|
10
|
+ }
|
|
11
|
+]
|
|
12
|
+
|
|
13
|
+Vagrant.configure("2") do |config|
|
|
14
|
+
|
|
15
|
+ # only use if have downloaded https://github.com/fgrehm/vagrant-cachier
|
|
16
|
+ #config.cache.auto_detect = true
|
|
17
|
+
|
|
18
|
+ # define some standard configuration for memory
|
|
19
|
+ #config.vm.provider :lxc do |lxc|
|
|
20
|
+ # lxc.customize 'cgroup.memory.limit_in_bytes', '400M'
|
|
21
|
+ # lxc.customize 'cgroup.memory.memsw.limit_in_bytes', '500M'
|
|
22
|
+ #end
|
|
23
|
+
|
|
24
|
+ config.vm.provider :lxc do |lxc, override|
|
|
25
|
+ override.vm.box = "precise64"
|
|
26
|
+ override.vm.box_url = "http://bit.ly/vagrant-lxc-precise64-2013-05-08"
|
|
27
|
+ end
|
|
28
|
+ config.vm.provider :virtualbox do |vbox, override|
|
|
29
|
+ override.vm.box = "precise64"
|
|
30
|
+ override.vm.box_url = "http://files.vagrantup.com/precise64.box"
|
|
31
|
+ end
|
|
32
|
+ $boxes.each do | opts |
|
|
33
|
+ config.vm.define(opts[:name]) do |config|
|
|
34
|
+ config.vm.hostname = "%s" % [ opts[:name].to_s ]
|
|
35
|
+ opts[:forwards].each do |guest_port,host_port|
|
|
36
|
+ config.vm.network :forwarded_port, guest: guest_port, host: host_port
|
|
37
|
+ end if opts[:forwards]
|
|
38
|
+
|
|
39
|
+ config.vm.provision :shell, :inline => 'if [ ! -e /root/apt.updated ]; then apt-get update && touch /root/apt.updated ; fi; apt-get install -y python-apt'
|
|
40
|
+ config.vm.provision :ansible do |ansible|
|
|
41
|
+ ansible.playbook = "site.yml"
|
|
42
|
+ #ansible.inventory_file = "hosts"
|
|
43
|
+ end
|
|
44
|
+ config.vm.provision :shell, :inline => "echo [test] > /vagrant/hosts.autogen && ifconfig eth0 | grep 'inet addr'|awk '{print $2}' |cut -d: -f2 >> /vagrant/hosts.autogen"
|
|
45
|
+ config.vm.provision :shell, :inline => "echo 'VM is setup'"
|
|
46
|
+ end if ! opts[:disabled]
|
|
47
|
+ end
|
|
48
|
+end
|