Puppet accepts :facter option to override default facts [GH-753]

This commit is contained in:
Mitchell Hashimoto 2012-02-25 10:18:17 -08:00
parent 2c823e98bd
commit 6490710d43
2 changed files with 16 additions and 1 deletions

View File

@ -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)

View File

@ -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)