Fix scoping for env and config.vm variables in the puppet provisioner.

This commit is contained in:
Colin Moller 2012-01-04 12:28:18 -08:00
parent 33551eca47
commit 0f5f607767
1 changed files with 12 additions and 8 deletions

View File

@ -13,6 +13,7 @@ module Vagrant
attr_accessor :options attr_accessor :options
def initialize def initialize
@manifest_file = nil @manifest_file = nil
@manifests_path = "manifests" @manifests_path = "manifests"
@module_path = nil @module_path = nil
@ -23,7 +24,7 @@ module Vagrant
# Returns the manifests path expanded relative to the root path of the # Returns the manifests path expanded relative to the root path of the
# environment. # environment.
def expanded_manifests_path def expanded_manifests_path
Pathname.new(manifests_path).expand_path(env.root_path) Pathname.new(manifests_path).expand_path(@env.root_path)
end end
# Returns the manifest file if set otherwise returns the box name pp file # Returns the manifest file if set otherwise returns the box name pp file
@ -42,12 +43,14 @@ module Vagrant
paths = module_path paths = module_path
paths = [paths] if !paths.is_a?(Array) paths = [paths] if !paths.is_a?(Array)
paths.map do |path| paths.map do |path|
Pathname.new(path).expand_path(env.root_path) Pathname.new(path).expand_path(@env.root_path)
end end
end end
def validate(env, errors) def validate(env, errors)
super super env, errors
@env = env
# Manifests path/file validation # Manifests path/file validation
if !expanded_manifests_path.directory? if !expanded_manifests_path.directory?
@ -83,7 +86,7 @@ module Vagrant
end end
def share_manifests def share_manifests
env.config.vm.share_folder("manifests", manifests_guest_path, config.expanded_manifests_path) env[:vm].config.vm.share_folder("manifests", manifests_guest_path, config.expanded_manifests_path)
end end
def share_module_paths def share_module_paths
@ -91,7 +94,7 @@ module Vagrant
@module_paths.each do |from, to| @module_paths.each do |from, to|
# Sorry for the cryptic key here, but VirtualBox has a strange limit on # Sorry for the cryptic key here, but VirtualBox has a strange limit on
# maximum size for it and its something small (around 10) # maximum size for it and its something small (around 10)
env.config.vm.share_folder("v-pp-m#{count}", to, from) env[:vm].config.vm.share_folder("v-pp-m#{count}", to, from)
count += 1 count += 1
end end
end end
@ -108,7 +111,7 @@ module Vagrant
end end
def verify_binary(binary) def verify_binary(binary)
vm.ssh.execute do |ssh| env[:vm].ssh.execute do |ssh|
ssh.sudo!("which #{binary}", :error_class => PuppetError, :_key => :puppet_not_detected, :binary => binary) ssh.sudo!("which #{binary}", :error_class => PuppetError, :_key => :puppet_not_detected, :binary => binary)
end end
end end
@ -122,9 +125,9 @@ module Vagrant
commands = ["cd #{manifests_guest_path}", commands = ["cd #{manifests_guest_path}",
"puppet apply #{options}"] "puppet apply #{options}"]
env.ui.info I18n.t("vagrant.provisioners.puppet.running_puppet", :manifest => config.computed_manifest_file) env[:ui].info I18n.t("vagrant.provisioners.puppet.running_puppet", :manifest => config.computed_manifest_file)
vm.ssh.execute do |ssh| env[:vm].ssh.execute do |ssh|
ssh.sudo! commands do |ch, type, data| ssh.sudo! commands do |ch, type, data|
if type == :exit_status if type == :exit_status
ssh.check_exit_status(data, commands) ssh.check_exit_status(data, commands)
@ -142,3 +145,4 @@ module Vagrant
end end
end end
end end