Debian Codegraph @

tests/vagrant/vagrant-template-centos6/Vagrantfile

raw
1 # -*- mode: ruby -*-
2 # vi: set ft=ruby :
3
4 Vagrant.configure("2") do |config|
5 config.vm.define "vagrant-testVM" do |testvm|
6 testvm.vm.box = "raghavendra-talur/gluster-dev-centos6"
7 testvm.vm.hostname = "vagrant-testVM"
8 #testvm.ssh.insert_key = false
9 testvm.vm.synced_folder ".", "/vagrant", disabled: true
10
11 host = RbConfig::CONFIG['host_os']
12 # Give VM 1/4 system memory & access to all cpu cores on the host
13 if host =~ /darwin/
14 cpus = `sysctl -n hw.ncpu`.to_i
15 # sysctl returns Bytes and we need to convert to MB
16 mem = `sysctl -n hw.memsize`.to_i / 1024 / 1024 / 4
17 elsif host =~ /linux/
18 cpus = `nproc`.to_i
19 # meminfo shows KB and we need to convert to MB
20 mem = `grep 'MemTotal' /proc/meminfo | sed -e 's/MemTotal://' -e 's/ kB//'`.to_i / 1024 / 4
21 else # sorry Windows folks, I can't help you
22 cpus = 2
23 mem = 1024
24 end
25
26 # Define basic config for VM, memory, cpu, storage pool
27 testvm.vm.provider "libvirt" do |lv|
28 lv.storage_pool_name = "default"
29 lv.memory = mem
30 lv.cpus = cpus
31
32
33 # We need a brick partition, lets have a 5G disk for that.
34 # If you need more bricks, just add more letters to the
35 # string below.
36 "b".split("").each do |i|
37 lv.storage :file,
38 #:path => "",
39 #:allow_existing => "",
40 :device => "vd#{i}",
41 :size => "5G",
42 :type => "qcow2",
43 :bus => "virtio",
44 :cache => "default"
45 end
46 end
47
48 # Let's provision
49 testvm.vm.provision "ansible", run: "always" do |setup|
50 setup.verbose = "v"
51 setup.playbook = "setup.yml"
52 end
53
54 end
55 end