diff --git a/CHANGELOG.md b/CHANGELOG.md index a157b2d75..b626a89bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,8 @@ - `VM#run_action` is now public so plugin-devs can hook into it. - Fix crashing bug when attempting to run commands on the "primary" VM in a multi-VM environment. [GH-761] + - With puppet you can now specify `:facter` as a dictionary of facts to + override what is generated by Puppet. [GH-753] ## 0.9.7 (February 9, 2012) diff --git a/lib/vagrant/provisioners/puppet.rb b/lib/vagrant/provisioners/puppet.rb index e18404b05..44f49b0e3 100644 --- a/lib/vagrant/provisioners/puppet.rb +++ b/lib/vagrant/provisioners/puppet.rb @@ -13,11 +13,13 @@ module Vagrant attr_accessor :module_path attr_accessor :pp_path attr_accessor :options + attr_accessor :facter def manifest_file; @manifest_file || "default.pp"; end def manifests_path; @manifests_path || "manifests"; end def pp_path; @pp_path || "/tmp/vagrant-puppet"; end def options; @options ||= []; end + def facter; @facter ||= {}; end # Returns the manifests path expanded relative to the root path of the # environment. @@ -138,7 +140,18 @@ module Vagrant options << @manifest_file options = options.join(" ") - command = "cd #{manifests_guest_path} && puppet apply #{options}" + # Build up the custom facts if we have any + facter = "" + if !config.facter.empty? + facts = [] + config.facter.each do |key, value| + facts << "FACTER_#{key}='#{value}'" + end + + facter = "#{facts.join(" ")} " + end + + command = "cd #{manifests_guest_path} && #{facter}puppet apply #{options}" env[:ui].info I18n.t("vagrant.provisioners.puppet.running_puppet", :manifest => @manifest_file)