Skip to content

Commit

Permalink
vagrants: multiple targets work now. customization makes a bit more s…
Browse files Browse the repository at this point in the history
…ense.
  • Loading branch information
Philip (flip) Kromer committed Feb 20, 2012
1 parent bf9b401 commit 750c5b2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
4 changes: 3 additions & 1 deletion lib/chef/knife/cluster_vagrant.rb
Expand Up @@ -127,7 +127,9 @@ def run
#
section("issuing command 'vagrant #{vagrant_command}'", :green)

env.cli(vagrant_command, * target.servers.map(&:fullname))
target.servers.each do |server|
env.cli(vagrant_command, server.fullname)
end
end

def display(target)
Expand Down
20 changes: 11 additions & 9 deletions lib/chef/knife/vagrant/skeleton_vagrantfile.rb
Expand Up @@ -38,6 +38,8 @@ def ip_for(svr)

# FIXME: things like this should be imputed by the `cloud` statement
ram_mb = 640
video_ram_mb = 10
cores = 2

# ===========================================================================
#
Expand All @@ -53,7 +55,7 @@ def ip_for(svr)
#
# Define a VM for all the targeted servers in the cluster.
#
# * vm name - server's fullname ('el_ridiculoso-grande-2')
# * vm name - server's fullname ('el_ridiculoso-gordo-2')
# * vm box - cloud.image_name
# * creates host network on the subnet defined in Chef::Config[:host_network_blk]
# * populates chef provisioner from the server's run_list
Expand All @@ -68,15 +70,15 @@ def ip_for(svr)
# See http://www.virtualbox.org/manual/ch08.html#idp12418752
# for the craziness
#
vm_customizations = {
"modifyvm" => :id,
"--name" => svr.fullname.to_s,
# Use the host resolver for DNS so that VPN continues to work within the VM
"--natdnshostresolver1" => "on",
}
# vm_customizations["--memory"] = svr.cloud.ram_mb.to_s if svr.cloud.ram_mb
vm_customizations = {}
vm_customizations[:name] = svr.fullname.to_s
vm_customizations[:memory] = ram_mb.to_s if ram_mb
vm_customizations[:vram] = video_ram_mb.to_s if video_ram_mb
vm_customizations[:cpus] = cores.to_s if cores
# Use the host resolver for DNS so that VPN continues to work within the VM
vm_customizations[:natdnshostresolver1] = "on"
#
cfg.vm.customize vm_customizations
cfg.vm.customize ["modifyvm", :id, vm_customizations.map{|k,v| ["--#{k}", v]} ].flatten

# Assign this VM to a bridged network, allowing you to connect directly to a
# network using the host's network device. This makes the VM appear as another
Expand Down
2 changes: 1 addition & 1 deletion notes
Submodule notes updated from 7838fa to 753814

0 comments on commit 750c5b2

Please sign in to comment.