mitchellh/vagrant — pull request #753 by ergonlogic (2012-02-21 06:32:46+00:00)
Title: Add pre-apply option so we can set Puppet facts

Hi,

There's this great, little known ability in Puppet (well, Facter actually) whereby you can set facts prior to running 'puppet apply' in a fashion similar to altering environment variables using ENV:

```shell
# override $operatingsystem for testing purposes
$ FACTER_operatingsystem=Debian puppet -e 'notify { "We are running on $operatingsystem": }'
notice: We are running on Debian
```
(ref.: [Puppet Cookbook](http://www.puppetcookbook.com/posts/override-a-facter-fact.html))

I modeled 'pre_apply' directly on the 'option' setting for puppet, so that single facts, such as:

```ruby
config.vm.provision :puppet, :pre_apply = "FACTER_fqdn='www.ergonlogic.com'"
```
or an array of facts work equally well:

```ruby
config.vm.provision :puppet, :pre_apply = [ "FACTER_domain='ergonlogic.com'", "FACTER_hostname='www'" ]
```

Let me know if you like the idea and I'll write up some tests to go along with it.

By the way, my hope is to use this for a Vagrant-based project I started called [Aegir-up](http://drupal.org/project/aegir-up). The itch that led to this little patch is that there's a [bug in Puppet](http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=637894) that results in incorrect FQDNs on Debian systems when using an internal DNS server.