From 66bf56a073e6700115a96a42d2126646435dcd75 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 14 Jan 2011 00:21:20 -0800 Subject: [PATCH] Fix issue with puppet mounting shared folder as subfolder of another, causing spurious folder creation on the host --- lib/vagrant/provisioners/puppet.rb | 16 ++++++---------- test/vagrant/provisioners/puppet_test.rb | 23 ++--------------------- 2 files changed, 8 insertions(+), 31 deletions(-) diff --git a/lib/vagrant/provisioners/puppet.rb b/lib/vagrant/provisioners/puppet.rb index 2fa7e14ce..bed551fc8 100644 --- a/lib/vagrant/provisioners/puppet.rb +++ b/lib/vagrant/provisioners/puppet.rb @@ -77,12 +77,11 @@ module Vagrant def provision! verify_binary("puppet") - create_pp_path run_puppet_client end def share_manifests - env.config.vm.share_folder("manifests", config.pp_path, config.manifests_path) + env.config.vm.share_folder("manifests", manifests_guest_path, config.expanded_manifests_path) end def share_module_paths @@ -102,26 +101,23 @@ module Vagrant end end + def manifests_guest_path + File.join(config.pp_path, "manifests") + end + def verify_binary(binary) vm.ssh.execute do |ssh| ssh.exec!("sudo -i which #{binary}", :error_class => PuppetError, :_key => :puppet_not_detected, :binary => binary) end end - def create_pp_path - vm.ssh.execute do |ssh| - ssh.exec!("sudo mkdir -p #{config.pp_path}") - ssh.exec!("sudo chown #{env.config.ssh.username} #{config.pp_path}") - end - end - def run_puppet_client options = [config.options].flatten options << "--modulepath '#{@module_paths.values.join(':')}'" if !@module_paths.empty? options << config.computed_manifest_file options = options.join(" ") - command = "sudo -i 'cd #{config.pp_path}; puppet #{options}'" + command = "sudo -i 'cd #{manifests_guest_path}; puppet #{options}'" env.ui.info I18n.t("vagrant.provisioners.puppet.running_puppet", :manifest => config.computed_manifest_file) diff --git a/test/vagrant/provisioners/puppet_test.rb b/test/vagrant/provisioners/puppet_test.rb index 68e2556cf..81eab3045 100644 --- a/test/vagrant/provisioners/puppet_test.rb +++ b/test/vagrant/provisioners/puppet_test.rb @@ -106,22 +106,14 @@ class PuppetProvisionerTest < Test::Unit::TestCase should "run the proper sequence of methods in order" do prov_seq = sequence("prov_seq") @action.expects(:verify_binary).with("puppet").once.in_sequence(prov_seq) - @action.expects(:create_pp_path).once.in_sequence(prov_seq) @action.expects(:run_puppet_client).once.in_sequence(prov_seq) @action.provision! end end context "share manifests folder" do - setup do - @manifests_path = "manifests" - @pp_path = "/tmp/vagrant-puppet" - @action.stubs(:manifests_path).returns(@manifests_path) - @action.stubs(:pp_path).returns(@pp_path) - end - should "share manifest folder" do - @env.config.vm.expects(:share_folder).with("manifests", @pp_path, @manifests_path) + @env.config.vm.expects(:share_folder).with("manifests", @action.manifests_guest_path, @config.expanded_manifests_path) @action.share_manifests end end @@ -151,17 +143,6 @@ class PuppetProvisionerTest < Test::Unit::TestCase end end - context "create pp path" do - should "create and chown the folder to the ssh user" do - ssh_seq = sequence("ssh_seq") - ssh = mock("ssh") - ssh.expects(:exec!).with("sudo mkdir -p #{@config.pp_path}").once.in_sequence(ssh_seq) - ssh.expects(:exec!).with("sudo chown #{@env.config.ssh.username} #{@config.pp_path}").once.in_sequence(ssh_seq) - @vm.ssh.expects(:execute).yields(ssh) - @action.create_pp_path - end - end - context "running puppet client" do setup do @ssh = mock("ssh") @@ -170,7 +151,7 @@ class PuppetProvisionerTest < Test::Unit::TestCase end def expect_puppet_command(command) - @ssh.expects(:exec!).with("sudo -i 'cd #{@config.pp_path}; #{command}'") + @ssh.expects(:exec!).with("sudo -i 'cd #{@action.manifests_guest_path}; #{command}'") end should "cd into the pp_path directory and run puppet" do