diff --git a/plugins/provisioners/puppet/config/puppet_server.rb b/plugins/provisioners/puppet/config/puppet_server.rb index 9c53672d5..5cab589b6 100644 --- a/plugins/provisioners/puppet/config/puppet_server.rb +++ b/plugins/provisioners/puppet/config/puppet_server.rb @@ -2,6 +2,10 @@ module VagrantPlugins module Puppet module Config class PuppetServer < Vagrant.plugin("2", :config) + # The path to Puppet's bin/ directory. + # @return [String] + attr_accessor :binary_path + attr_accessor :client_cert_path attr_accessor :client_private_key_path attr_accessor :facter @@ -12,6 +16,7 @@ module VagrantPlugins def initialize super + @binary_path = UNSET_VALUE @client_cert_path = UNSET_VALUE @client_private_key_path = UNSET_VALUE @facter = {} @@ -29,6 +34,7 @@ module VagrantPlugins def finalize! super + @binary_path = nil if @binary_path == UNSET_VALUE @client_cert_path = nil if @client_cert_path == UNSET_VALUE @client_private_key_path = nil if @client_private_key_path == UNSET_VALUE @puppet_node = nil if @puppet_node == UNSET_VALUE diff --git a/plugins/provisioners/puppet/provisioner/puppet_server.rb b/plugins/provisioners/puppet/provisioner/puppet_server.rb index 9c9e9e6b7..29c1c23dc 100644 --- a/plugins/provisioners/puppet/provisioner/puppet_server.rb +++ b/plugins/provisioners/puppet/provisioner/puppet_server.rb @@ -17,8 +17,14 @@ module VagrantPlugins end def verify_binary(binary) + if @config.binary_path + test_cmd = "test -x #{@config.binary_path}/#{binary}" + else + test_cmd = "which #{binary}" + end + @machine.communicate.sudo( - "which #{binary}", + test_cmd, error_class: PuppetServerError, error_key: :not_detected, binary: binary) @@ -83,8 +89,13 @@ module VagrantPlugins facter = "#{facts.join(" ")} " end + + puppet_bin = "puppet" + if @config.binary_path + puppet_bin = File.join(@config.binary_path, puppet_bin) + end options = options.join(" ") - command = "#{facter}puppet agent --onetime --no-daemonize #{options} " + + command = "#{facter} #{puppet_bin} agent --onetime --no-daemonize #{options} " + "--server #{config.puppet_server} --detailed-exitcodes || [ $? -eq 2 ]" @machine.ui.info I18n.t("vagrant.provisioners.puppet_server.running_puppetd") diff --git a/website/docs/source/v2/provisioning/puppet_agent.html.md b/website/docs/source/v2/provisioning/puppet_agent.html.md index 14d2b8a7c..26f43cf2a 100644 --- a/website/docs/source/v2/provisioning/puppet_agent.html.md +++ b/website/docs/source/v2/provisioning/puppet_agent.html.md @@ -26,6 +26,8 @@ the set of modules and manifests from there. The `puppet_server` provisioner takes various options. None are strictly required. They are listed below: +* `binary_path` (string) - Path on the guest to Puppet's `bin/` directory. + * `client_cert_path` (string) - Path to the client certificate for the node on your disk. This defaults to nothing, in which case a client cert won't be uploaded.