From 8c1ff5ee26f132b024c842bcd568fa5f33cd0168 Mon Sep 17 00:00:00 2001 From: Ben Hines Date: Tue, 14 Jul 2015 23:21:46 -0700 Subject: [PATCH 1/3] Fix custom puppet.binary_path to work properly on windows. Fix automatic puppet path detection on windows --- .../provisioners/puppet/provisioner/puppet.rb | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/plugins/provisioners/puppet/provisioner/puppet.rb b/plugins/provisioners/puppet/provisioner/puppet.rb index 67954ca77..033b38830 100644 --- a/plugins/provisioners/puppet/provisioner/puppet.rb +++ b/plugins/provisioners/puppet/provisioner/puppet.rb @@ -109,7 +109,8 @@ module VagrantPlugins verify_shared_folders(check) # Verify Puppet is installed and run it - verify_binary(puppet_binary_path("puppet")) + puppet_bin = "puppet" + verify_binary(puppet_bin) # Upload Hiera configuration if we have it @hiera_config_path = nil @@ -144,15 +145,16 @@ module VagrantPlugins end end - # Returns the path to the Puppet binary, taking into account the - # `binary_path` configuration option. - def puppet_binary_path(binary) - return binary if !@config.binary_path - return File.join(@config.binary_path, binary) - end - def verify_binary(binary) - if !machine.communicate.test("sh -c 'command -v #{binary}'") + test_cmd = "sh -c 'command -v #{binary}'" + if windows? + if @config.binary_path + test_cmd = "where \"#{@config.binary_path}:#{binary}\"" + else + test_cmd = "where #{binary}" + end + end + if !machine.communicate.test(test_cmd) @config.binary_path = "/opt/puppetlabs/bin/" @machine.communicate.sudo( "test -x /opt/puppetlabs/bin/#{binary}", @@ -214,7 +216,8 @@ module VagrantPlugins facter = "#{facts.join(" ")} " end - command = "#{facter} #{config.binary_path}puppet apply #{options}" + puppet_bin = File.join(@config.binary_path, "puppet") + command = "#{facter} #{puppet_bin} apply #{options}" if config.working_directory if windows? command = "cd #{config.working_directory}; if (`$?) \{ #{command} \}" From 8c2ddac2cdf81d9ab62fdce89a59143093812816 Mon Sep 17 00:00:00 2001 From: Ben Hines Date: Tue, 14 Jul 2015 23:26:55 -0700 Subject: [PATCH 2/3] Check for nil config_path. --- plugins/provisioners/puppet/provisioner/puppet.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/provisioners/puppet/provisioner/puppet.rb b/plugins/provisioners/puppet/provisioner/puppet.rb index 033b38830..e53b4d8ff 100644 --- a/plugins/provisioners/puppet/provisioner/puppet.rb +++ b/plugins/provisioners/puppet/provisioner/puppet.rb @@ -216,7 +216,10 @@ module VagrantPlugins facter = "#{facts.join(" ")} " end - puppet_bin = File.join(@config.binary_path, "puppet") + puppet_bin = "puppet" + if(@config.binary_path) + puppet_bin = File.join(@config.binary_path, puppet_bin) + end command = "#{facter} #{puppet_bin} apply #{options}" if config.working_directory if windows? From 46eedb64911e2cb45e9f5cf73ad6f672ab3f2554 Mon Sep 17 00:00:00 2001 From: Ben Hines Date: Tue, 14 Jul 2015 23:55:09 -0700 Subject: [PATCH 3/3] Back to using 'which' when no path is defined since the winrm communicator overrides it anyway. --- plugins/provisioners/puppet/provisioner/puppet.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/provisioners/puppet/provisioner/puppet.rb b/plugins/provisioners/puppet/provisioner/puppet.rb index e53b4d8ff..e7c598140 100644 --- a/plugins/provisioners/puppet/provisioner/puppet.rb +++ b/plugins/provisioners/puppet/provisioner/puppet.rb @@ -151,7 +151,7 @@ module VagrantPlugins if @config.binary_path test_cmd = "where \"#{@config.binary_path}:#{binary}\"" else - test_cmd = "where #{binary}" + test_cmd = "which #{binary}" end end if !machine.communicate.test(test_cmd)