Allow passing options to the Puppet provisioner

This allows for instance to pass the --modulepath options like this:

config.vm.puppet.options = ["--modulepath","modules"]

Which would call puppet with "--modulepath modules".

Signed-off-by: Brice Figureau <brice@daysofwonder.com>
This commit is contained in:
Brice Figureau 2010-12-12 18:20:48 +01:00 committed by Mitchell Hashimoto
parent d0add468ac
commit 6b46949550
2 changed files with 10 additions and 2 deletions

View File

@ -11,11 +11,13 @@ module Vagrant
attr_accessor :manifest_file
attr_accessor :manifests_path
attr_accessor :pp_path
attr_accessor :options
def initialize
@manifest_file = ""
@manifests_path = "manifests"
@pp_path = "/tmp/vagrant-puppet"
@options = []
end
end
@ -66,7 +68,7 @@ module Vagrant
end
def run_puppet_client
command = "cd #{env.config.puppet.pp_path} && sudo -E puppet #{@manifest}"
command = "cd #{env.config.puppet.pp_path} && sudo -E puppet #{env.config.puppet.options.join(" ")} #{@manifest}"
env.ui.info I18n.t("vagrant.provisioners.puppet.running_puppet")

View File

@ -114,6 +114,12 @@ class PuppetProvisionerTest < Test::Unit::TestCase
@action.run_puppet_client
end
should "cd into the pp_path directory and run puppet with given options" do
@env.config.puppet.options = ["--modulepath", "modules", "--verbose"]
@ssh.expects(:exec!).with("cd #{@env.config.puppet.pp_path} && sudo -E puppet --modulepath modules --verbose #{@manifest}").once
@action.run_puppet_client
end
should "check the exit status if that is given" do
@ssh.stubs(:exec!).yields(nil, :exit_status, :foo)
@ssh.expects(:check_exit_status).with(:foo, anything).once