Trying to understand the details of scripting vagrant within a Rakefile. I'm trying to loop over my chef roles and package out a set of boxes, but I'm not understanding how to access the configuration for provisioning as my Ruby skills are only a few weeks old. Any help appreciated, this is what I have so far:
task :build do
env = Vagrant::Environment.new
env.ui = Vagrant::UI::Shell.new(env, Thor::Base.shell.new)
puts "Building boxes"
puts "Init environment"
env.cli('init','base')
roles.keys.each do |role|
puts "Spinning up vagrant box"
env.cli('up', '--no-provision')
puts "Provisioning role #{role}"
env.config.vm.provisioners.each do |chef|
chef.config.chef_server_url = CHEF_SERVER
chef.config.validation_key_path = "/home/mark/.chef/validation.pem"
chef.config.run_list = "role[#{role}]"
end
env.cli('provision')
puts "Packaging role #{role}"
env.cli('package', '--output', "#{role}.box", '--vagrantfile', 'Vagrantfile')
puts "Destroying VM"
env.cli('destroy')
end
end
This is okay, except its not provisioning anything which I guess is because I'm not setting the per package provision config up properly.
-Mark
--
Mark Cheverton
mark.ch...@ecafe.org
@ennui2342