diff --git a/plugins/provisioners/puppet/provisioner/puppet.rb b/plugins/provisioners/puppet/provisioner/puppet.rb index f1987dbd5..d1e124e85 100644 --- a/plugins/provisioners/puppet/provisioner/puppet.rb +++ b/plugins/provisioners/puppet/provisioner/puppet.rb @@ -62,12 +62,16 @@ module VagrantPlugins # Parse out the environment manifest path since puppet apply doesnt do that for us. environment_conf = File.join(environments_guest_path, @config.environment, "environment.conf") if @machine.communicate.test("test -e #{environment_conf}", sudo: true) - conf = @machine.communicate.sudo("cat #{environment_conf}") do | type, data| + @machine.communicate.sudo("cat #{environment_conf}") do | type, data| if type == :stdout data.each_line do |line| if line =~ /^\s*manifest\s+=\s+([^\s]+)/ @manifest_file = $1 - @manifest_file.gsub! '$basemodulepath:', "#{environments_guest_path}/#{@config.environment}/" + @manifest_file.gsub! "$codedir", File.dirname(environments_guest_path) + @manifest_file.gsub! "$environment", @config.environment + if !@manifest_file.start_with? "/" + @manifest_file = File.join(environments_guest_path, @config.environment, @manifest_file) + end @logger.debug("Using manifest from environment.conf: #{@manifest_file}") end end @@ -85,7 +89,7 @@ module VagrantPlugins # In environment mode we still need to specify a manifest file, if its not, use the one from env config if specified. if !@manifest_file - @manifest_file = "#{environments_guest_path}/#{@config.environment}/manifests/site.pp" + @manifest_file = "#{environments_guest_path}/#{@config.environment}/manifests" parse_environment_metadata end # Check that the shared folders are properly shared diff --git a/website/docs/source/v2/provisioning/puppet_apply.html.md b/website/docs/source/v2/provisioning/puppet_apply.html.md index 89fe90195..b8f0a5f02 100644 --- a/website/docs/source/v2/provisioning/puppet_apply.html.md +++ b/website/docs/source/v2/provisioning/puppet_apply.html.md @@ -140,8 +140,9 @@ that the path is located in the "vm" at "/path/to/manifests". ## Environments -If you are using Puppet 4 or higher, you can also specify the name of the -Puppet environment and the path on the local disk to the environment files: +If you are using Puppet 4 or higher, you can proivision using +[Puppet Environments](https://docs.puppetlabs.com/puppet/latest/reference/environments.html) by specifying the name of the environment and the path on the +local disk to the environment files: ```ruby Vagrant.configure("2") do |config| @@ -152,6 +153,13 @@ Vagrant.configure("2") do |config| end ``` +The default manifest is the environment's `manifests` directory. +If the environment has an `environment.conf` the manifest path is parsed +from there. Relative paths are assumed to be relative to the directory of +the environment. If the manifest setting in `environment.conf` use +the Puppet variables `$codedir` or `$environment` they are resoled to +the parent directory of `environment_path` and `environment` respectively. + ## Modules Vagrant also supports provisioning with [Puppet modules](http://docs.puppetlabs.com/guides/modules.html).