Update Vagrantfile since we use only hashes in conf files now.
[project/drush-vagrant.git] / lib / Vagrantfile
1 Vagrant::Config.run do |config|
2   require "./.config/config"
3
4   Vm.descendants.each_with_index do |vm,count_vms|
5     (1..vm::Count).each do |index|
6       # Initialize & set counters
7       count = ""
8       formatted_count = ""
9       if vm::Count > 1
10         count = "#{index}"
11         formatted_count = "(#{index}of#{vm::Count})"
12       end
13
14       config.vm.define "#{vm::Shortname}#{index}" do |vm_config|
15
16         vm_config.vm.box = vm::Basebox
17         vm_config.vm.box_url = vm::Box_url
18         vm_config.vm.auto_port_range = Conf::SSH_range
19         vm_config.vm.network :hostonly, "#{Conf::Network}.#{Conf::Subnet}.#{Conf::Host_IP + ((count_vms) * 10) + index - 1}"
20         hostname = "#{vm::Shortname}#{count}.#{Conf::Project}.#{vm::Domain}"
21         vm_config.vm.host_name = hostname
22         vm_config.vm.customize ["modifyvm", :id, "--name", "#{vm::Longname}#{formatted_count}(#{hostname})"]
23         vm_config.vm.customize ["modifyvm", :id, "--memory", "#{vm::Memory}"]
24         if defined?(vm::NFS_shares)
25           vm::NFS_shares.each do |name, path|
26             vm_config.vm.share_folder(name, path, "./#{name}", { :nfs => true, :create => true, :remount => true })
27           end
28         end
29         if vm::Gui == true
30           vm_config.vm.boot_mode = :gui
31         end
32
33         if File::exists?("#{vm::Manifests}/#{vm::Site}.pp")
34           vm_config.vm.provision :puppet do |puppet|
35             puppet.manifest_file = "#{vm::Site}.pp"
36             # Initialize an empty array so we can push onto it
37             puppet.module_path = []
38             # Merge in project-specific Puppet modules
39             vm::Modules.update(Conf::Modules)
40             vm::Modules.each do |name,path|
41               # Expand relative paths (such as '~')
42               full_path = File.expand_path("#{path}")
43               # Cull directories that don't exist
44               if File::directory?("#{full_path}")
45                 puppet.module_path.push("#{full_path}")
46               end
47             end
48             puppet.facter = Conf::Facts.update(vm::Facts)
49             puppet.options = vm::Options
50             if vm::Debug == true
51               puppet.options = puppet.options + " --debug"
52             end
53             if vm::Verbose == true
54               puppet.options = puppet.options + " --verbose"
55             end
56           end
57         end
58
59       end
60
61     end
62   end
63
64 end