mitchellh/packer — pull request #1575 by denmat (2014-10-13 01:21:04+00:00)
Title: Adding hieradata directory to puppet-masterless provisioner 

We were having issues with the way the puppet apply was working with our hiera data directory (it wasn't syncing it up to our target hosts).

This PR is to add that ability and also add the ability to access the StagingDir variable so we can use a hieradata directory that is does not have a fully defined path (this means that we can use the same hiera file regardless of if we are using vagrant or packer to build hosts).

In this PR we create a hieradata_dir and that syncs the defined directory up to our target build as:
```
/hieradata
```

We can then use a hiera.yaml file like this:
```
---
:backends:
- yaml
:yaml:
:datadir: ./hieradata
:hierarchy:
- common
```

And run our puppet apply like this:
```
{
"type": "puppet-masterless",
"manifest_file": "providers/puppet/manifests/site.pp",
"module_paths": [ "providers/puppet/modules" ],
"hiera_config_path": "providers/puppet/hiera.yaml",
"hieradata_dir": "providers/puppet/hieradata",
"manifest_dir": "providers/puppet/manifests",
"facter": {
"app": "none"
},
"execute_command": "pushd {{.StagingDir}} ; {{.FacterVars}} sudo -E puppet apply \
--verbose --modulepath={{.ModulePath}} --hiera_config={{.HieraConfigPath}} \
--manifestdir={{.ManifestDir}} --detailed-exitcodes {{.ManifestFile}}"
}
```

Tested on ec2 only.