Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi vm #143

Merged
merged 7 commits into from Sep 28, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/berkshelf/vagrant.rb
Expand Up @@ -18,12 +18,12 @@ module Action

class << self
# @param [Vagrant::Action::Environment] env
#
# @return [String, nil]
def shelf_for(env)
unless env[:global_config].vm.host_name
return nil
end
return nil if env[:vm].uuid.nil?

File.join(Berkshelf.berkshelf_path, "vagrant", env[:global_config].vm.host_name)
File.join(Berkshelf.berkshelf_path, "vagrant", env[:vm].uuid)
end

# @param [Symbol] shortcut
Expand Down Expand Up @@ -64,7 +64,7 @@ def init!
::Vagrant.actions[action].insert(::Vagrant::Action::VM::Provision, Berkshelf::Vagrant::Middleware.upload)
end

::Vagrant.actions[:destroy].insert(::Vagrant::Action::VM::CleanMachineFolder, Berkshelf::Vagrant::Middleware.clean)
::Vagrant.actions[:destroy].insert(::Vagrant::Action::VM::ProvisionerCleanup, Berkshelf::Vagrant::Middleware.clean)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/berkshelf/vagrant/action/clean.rb
Expand Up @@ -11,7 +11,7 @@ def initialize(app, env)
end

def call(env)
if Berkshelf::Vagrant.chef_solo?(env[:global_config]) && self.shelf
if Berkshelf::Vagrant.chef_solo?(env[:vm].config) && self.shelf
Berkshelf.formatter.msg "cleaning Vagrant's shelf"
FileUtils.remove_dir(self.shelf, fore: true)
end
Expand Down
6 changes: 3 additions & 3 deletions lib/berkshelf/vagrant/action/install.rb
Expand Up @@ -11,14 +11,14 @@ class Install
def initialize(app, env)
@app = app
@shelf = Berkshelf::Vagrant.shelf_for(env)
@config = env[:global_config].berkshelf
@config = env[:vm].config.berkshelf
Berkshelf.config_path = @config.config_path
Berkshelf.load_config
@berksfile = Berksfile.from_file(@config.berksfile_path)
end

def call(env)
if Berkshelf::Vagrant.chef_solo?(env[:global_config])
if Berkshelf::Vagrant.chef_solo?(env[:vm].config)
configure_cookbooks_path(env)
install(env)
end
Expand All @@ -37,7 +37,7 @@ def install(env)
end

def configure_cookbooks_path(env)
Berkshelf::Vagrant.provisioners(:chef_solo, env[:global_config]).each do |provisioner|
Berkshelf::Vagrant.provisioners(:chef_solo, env[:vm].config).each do |provisioner|
provisioner.config.cookbooks_path.unshift(self.shelf)
end
end
Expand Down
12 changes: 6 additions & 6 deletions lib/berkshelf/vagrant/action/upload.rb
Expand Up @@ -10,14 +10,14 @@ class Upload

def initialize(app, env)
@app = app
@node_name = env[:global_config].berkshelf.node_name
@client_key = env[:global_config].berkshelf.client_key
@ssl_verify = env[:global_config].berkshelf.ssl_verify
@berksfile = Berksfile.from_file(env[:global_config].berkshelf.berksfile_path)
@node_name = env[:vm].config.berkshelf.node_name
@client_key = env[:vm].config.berkshelf.client_key
@ssl_verify = env[:vm].config.berkshelf.ssl_verify
@berksfile = Berksfile.from_file(env[:vm].config.berkshelf.berksfile_path)
end

def call(env)
if Berkshelf::Vagrant.chef_client?(env[:global_config])
if Berkshelf::Vagrant.chef_client?(env[:vm].config)
upload(env)
end

Expand All @@ -27,7 +27,7 @@ def call(env)
private

def upload(env)
Berkshelf::Vagrant.provisioners(:chef_client, env[:global_config]).each do |provisioner|
Berkshelf::Vagrant.provisioners(:chef_client, env[:vm].config).each do |provisioner|
Berkshelf.formatter.msg "uploading cookbooks to '#{provisioner.config.chef_server_url}'"
berksfile.upload(
server_url: provisioner.config.chef_server_url,
Expand Down