From 1a6805d469528c80b94f9844c1498d45e0084121 Mon Sep 17 00:00:00 2001 From: Ben Hines Date: Mon, 15 Sep 2014 21:49:37 -0700 Subject: [PATCH 01/15] Use the more canonical require_relative to include files --- plugins/provisioners/puppet/plugin.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/provisioners/puppet/plugin.rb b/plugins/provisioners/puppet/plugin.rb index 362a1c421..4d2b74bbe 100644 --- a/plugins/provisioners/puppet/plugin.rb +++ b/plugins/provisioners/puppet/plugin.rb @@ -10,22 +10,22 @@ module VagrantPlugins DESC config(:puppet, :provisioner) do - require File.expand_path("../config/puppet", __FILE__) + require_relative "config/puppet" Config::Puppet end config(:puppet_server, :provisioner) do - require File.expand_path("../config/puppet_server", __FILE__) + require_relative "config/puppet_server" Config::PuppetServer end provisioner(:puppet) do - require File.expand_path("../provisioner/puppet", __FILE__) + require_relative "provisioner/puppet" Provisioner::Puppet end provisioner(:puppet_server) do - require File.expand_path("../provisioner/puppet_server", __FILE__) + require_relative "provisioner/puppet_server" Provisioner::PuppetServer end end From 16870d72d1102ef3623a4269af2b87e37628f3bf Mon Sep 17 00:00:00 2001 From: Ben Hines Date: Sun, 19 Oct 2014 21:28:38 -0700 Subject: [PATCH 02/15] Some work in progress environment support --- Vagrantfile | 79 +++++++----------- plugins/provisioners/puppet/config/puppet.rb | 69 +++++++++++++--- .../provisioners/puppet/provisioner/puppet.rb | 80 ++++++++++++++++--- templates/locales/en.yml | 11 +++ vagrant.gemspec | 3 +- 5 files changed, 171 insertions(+), 71 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 075157ed9..2dea5e123 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,54 +1,35 @@ -# This Vagrantfile can be used to develop Vagrant. Note that VirtualBox -# doesn't run in VirtualBox so you can't actually _run_ Vagrant within -# the VM created by this Vagrantfile, but you can use it to develop the -# Ruby, run unit tests, etc. -Vagrant.configure("2") do |config| - config.vm.box = "hashicorp/precise64" +# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! +VAGRANTFILE_API_VERSION = "2" - ["virtualbox", "vmware_fusion", "vmware_workstation"].each do |provider| - config.vm.provider provider do |v, override| - v.memory = "1024" +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + config.vm.box = "centos7" + + config.vm.define :centos7 do |centos7| + config.vm.network "private_network", ip: "192.168.11.3" + config.vm.hostname = "centos7" + # config.vm.network "public_network" + # config.ssh.forward_agent = true + config.vm.synced_folder "../puppet", "/puppet" + + config.vm.provider "virtualbox" do |vb| + vb.gui = false + # Use VBoxManage to customize the VM. For example to change memory: + vb.customize ["modifyvm", :id, "--memory", "2048"] end + + config.vm.provision "puppet" do |puppet| + puppet.environmentpath = "../puppet/environments" + puppet.environment = "testenv" + # puppet.manifests_path = "../puppet/manifests" + # puppet.manifest_file = "site.pp" + puppet.module_path = [ "../puppet/modules/public", "../puppet/modules/private" ] + # puppet.options = "--debug --verbose" + end + + # Deprecated method: + #puppet apply --debug --verbose --modulepath '/puppet/modules/private:/puppet/modules/public:/etc/puppet/modules' + #--manifestdir /tmp/vagrant-puppet-1/manifests --detailed-exitcodes /tmp/vagrant-puppet-1/manifests/site.pp + end - - config.vm.provision "shell", inline: $shell end - -$shell = <<-CONTENTS -MARKER_FILE="/usr/local/etc/vagrant_provision_marker" - -# Only provision once -if [ -f "${MARKER_FILE}" ]; then - exit 0 -fi - -# Update apt -apt-get update - -# Install basic dependencies -apt-get install -y build-essential bsdtar curl - -# Install RVM -su -l -c 'curl -L https://get.rvm.io | bash -s stable' vagrant - -# Add the vagrant user to the RVM group -#usermod -a -G rvm vagrant - -# Install some Rubies -su -l -c 'rvm install 2.1.1' vagrant -su -l -c 'rvm --default use 2.1.1' vagrant - -# Output the Ruby version (for sanity) -su -l -c 'ruby --version' vagrant - -# Install Git -apt-get install -y git - -# Automatically move into the shared folder, but only add the command -# if it's not already there. -grep -q 'cd /vagrant' /home/vagrant/.bash_profile || echo 'cd /vagrant' >> /home/vagrant/.bash_profile - -# Touch the marker file so we don't do this again -touch ${MARKER_FILE} -CONTENTS diff --git a/plugins/provisioners/puppet/config/puppet.rb b/plugins/provisioners/puppet/config/puppet.rb index 3117f9f6f..cc028b8db 100644 --- a/plugins/provisioners/puppet/config/puppet.rb +++ b/plugins/provisioners/puppet/config/puppet.rb @@ -10,6 +10,8 @@ module VagrantPlugins attr_accessor :hiera_config_path attr_accessor :manifest_file attr_accessor :manifests_path + attr_accessor :environment + attr_accessor :environmentpath attr_accessor :module_path attr_accessor :options attr_accessor :synced_folder_type @@ -22,6 +24,8 @@ module VagrantPlugins @hiera_config_path = UNSET_VALUE @manifest_file = UNSET_VALUE @manifests_path = UNSET_VALUE + @environment = UNSET_VALUE + @environmentpath = UNSET_VALUE @module_path = UNSET_VALUE @options = [] @facter = {} @@ -45,24 +49,45 @@ module VagrantPlugins def merge(other) super.tap do |result| result.facter = @facter.merge(other.facter) + result.environmentpath = @facter.merge(other.environmentpath) + result.environment = @facter.merge(other.environment) end end def finalize! super - if @manifests_path == UNSET_VALUE - @manifests_path = [:host, "manifests"] - end + if @environmentpath == UNSET_VALUE + if @manifests_path == UNSET_VALUE + if 1 #If puppet 3.4+ + puts "Puppet 3.4+, manifests_path is unset and environmentpath is unset, presuming an environment" + @environmentpath = [:host, "environments"] + else + @manifests_path = [:host, "manifests"] + end + end - if @manifests_path && !@manifests_path.is_a?(Array) - @manifests_path = [:host, @manifests_path] + if @manifests_path && !@manifests_path.is_a?(Array) + @manifests_path = [:host, @manifests_path] + end + else + if @environmentpath && !@environmentpath.is_a?(Array) + @environmentpath = [:host, @environmentpath] + end end - @manifests_path[0] = @manifests_path[0].to_sym - @hiera_config_path = nil if @hiera_config_path == UNSET_VALUE - @manifest_file = "default.pp" if @manifest_file == UNSET_VALUE + + if @environmentpath == UNSET_VALUE + @manifests_path[0] = @manifests_path[0].to_sym + @environmentpath = nil + @manifest_file = "default.pp" if @manifest_file == UNSET_VALUE + else + @environmentpath[0] = @environmentpath[0].to_sym + @environment = "production" if @environment == UNSET_VALUE + @manifest_file = nil + end + @module_path = nil if @module_path == UNSET_VALUE @synced_folder_type = nil if @synced_folder_type == UNSET_VALUE @temp_dir = nil if @temp_dir == UNSET_VALUE @@ -96,8 +121,13 @@ module VagrantPlugins # Calculate the manifests and module paths based on env this_expanded_module_paths = expanded_module_paths(machine.env.root_path) + if environmentpath != UNSET_VALUE && manifests_path != UNSET_VALUE + errors << "You may not specify both environmentpath and manifests_path. Please specify environment and environmentpath only" + end + # Manifests path/file validation - if manifests_path[0].to_sym == :host + puts "manifests_path is #{manifests_path}" + if manifests_path != UNSET_VALUE && manifests_path[0].to_sym == :host expanded_path = Pathname.new(manifests_path[1]). expand_path(machine.env.root_path) if !expanded_path.directory? @@ -110,8 +140,29 @@ module VagrantPlugins manifest: expanded_manifest_file.to_s) end end + end + + # Environments path/file validation + if environmentpath != UNSET_VALUE && environmentpath[0].to_sym == :host + expanded_path = Pathname.new(environmentpath[1]). + expand_path(machine.env.root_path) + if !expanded_path.directory? + errors << I18n.t("vagrant.provisioners.puppet.environmentpath_missing", + path: expanded_path.to_s) + else + expanded_environment_file = expanded_path.join(environment) + if !expanded_environment_file.file? && !expanded_environment_file.directory? + errors << I18n.t("vagrant.provisioners.puppet.environment_missing", + environment: environment.to_s, + environmentpath: expanded_path.to_s) + end + end end + if environmentpath == UNSET_VALUE && manifests_path == UNSET_VALUE + errors << "Please specify either a Puppet environmentpath + environment (preferred) or manifests_path (deprecated)." + end + # Module paths validation this_expanded_module_paths.each do |path| if !path.directory? diff --git a/plugins/provisioners/puppet/provisioner/puppet.rb b/plugins/provisioners/puppet/provisioner/puppet.rb index f49316bf7..14b64087e 100644 --- a/plugins/provisioners/puppet/provisioner/puppet.rb +++ b/plugins/provisioners/puppet/provisioner/puppet.rb @@ -18,7 +18,6 @@ module VagrantPlugins # Calculate the paths we're going to use based on the environment root_path = @machine.env.root_path @expanded_module_paths = @config.expanded_module_paths(root_path) - @manifest_file = File.join(manifests_guest_path, @config.manifest_file) # Setup the module paths @module_paths = [] @@ -30,11 +29,23 @@ module VagrantPlugins folder_opts[:type] = @config.synced_folder_type if @config.synced_folder_type folder_opts[:owner] = "root" if !@config.synced_folder_type - # Share the manifests directory with the guest - if @config.manifests_path[0].to_sym == :host - root_config.vm.synced_folder( - File.expand_path(@config.manifests_path[1], root_path), - manifests_guest_path, folder_opts) + if @config.environmentpath.is_a?(Array) + # Share the environments directory with the guest + if @config.environmentpath[0].to_sym == :host + root_config.vm.synced_folder( + File.expand_path(@config.environmentpath[1], root_path), + environments_guest_path, folder_opts) + end + parse_environment_metadata() + else + # Non-Environment mode + @manifest_file = File.join(manifests_guest_path, @config.manifest_file) + # Share the manifests directory with the guest + if @config.manifests_path[0].to_sym == :host + root_config.vm.synced_folder( + File.expand_path(@config.manifests_path[1], root_path), + manifests_guest_path, folder_opts) + end end # Share the module paths @@ -43,6 +54,24 @@ module VagrantPlugins end end + # For convenience, add in any module_paths from the Puppet environment.cfg to the vagrant module_paths + # This is needed because puppet apply does not read environment metadata (as of v3.6) + def parse_environment_metadata + 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| + if type == :stdout + #modulepath = $basemodulepath:modules/private:modules/public + puts "got line #{data}" + end + end + puts "Found an environment cfg at: #{environment_conf} - #{conf}" + else + puts "env cfg not found, looked for #{environment_conf}" + end + end + + def provision # If the machine has a wait for reboot functionality, then # do that (primarily Windows) @@ -52,9 +81,12 @@ module VagrantPlugins # Check that the shared folders are properly shared check = [] - if @config.manifests_path[0] == :host + if @config.manifests_path.is_a?(Array) && @config.manifests_path[0] == :host check << manifests_guest_path end + if @config.environmentpath.is_a?(Array) && @config.environmentpath[0] == :host + check << environments_guest_path + end @module_paths.each do |host_path, guest_path| check << guest_path end @@ -92,6 +124,16 @@ module VagrantPlugins end end + def environments_guest_path + if config.environmentpath[0] == :host + # The path is on the host, so point to where it is shared + File.join(config.temp_dir, "environments") + else + # The path is on the VM, so just point directly to it + config.environmentpath[1] + end + end + def verify_binary(binary) @machine.communicate.sudo( "which #{binary}", @@ -125,10 +167,18 @@ module VagrantPlugins options << "--color=false" end - options << "--manifestdir #{manifests_guest_path}" options << "--detailed-exitcodes" - options << @manifest_file + + if !config.environmentpath.empty? + options << "#{environments_guest_path}/#{@config.environment}/manifests" + options << "--environment #{@config.environment}" + else + options << "--manifestdir #{manifests_guest_path}" + options << @manifest_file + end options = options.join(" ") + + @machine.ui.info("Running ye puppet apply with options #{options}") # Build up the custom facts if we have any facter = "" @@ -155,9 +205,15 @@ module VagrantPlugins end end - @machine.ui.info(I18n.t( - "vagrant.provisioners.puppet.running_puppet", - manifest: config.manifest_file)) + if !config.environmentpath.empty? + @machine.ui.info(I18n.t( + "vagrant.provisioners.puppet.running_puppet_env", + environment: config.environment)) + else + @machine.ui.info(I18n.t( + "vagrant.provisioners.puppet.running_puppet", + manifest: config.manifest_file)) + end opts = { elevated: true, diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 4be7a92e7..2ec1d5c54 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -1733,12 +1733,23 @@ en: installed on this guest. Puppet provisioning can not continue without Puppet properly installed. running_puppet: "Running Puppet with %{manifest}..." + running_puppet_env: "Running Puppet with environment %{environment}..." manifest_missing: |- The configured Puppet manifest is missing. Please specify a path to an existing manifest: %{manifest} + environment_missing: |- + The configured Puppet environment folder '%{environment}' was not found in the + specified environmentpath %{environmentpath}. + Please specify a path to an existing Puppet directory environment. manifests_path_missing: "The manifests path specified for Puppet does not exist: %{path}" + manifest_missing: |- + The configured Puppet envrionment is missing. Please specify a path to an + existing envrionment file: + + %{environment} + manifests_path_missing: "The environment path specified for Puppet does not exist: %{path}" missing_shared_folders: |- Shared folders that Puppet requires are missing on the virtual machine. This is usually due to configuration changing after already booting the diff --git a/vagrant.gemspec b/vagrant.gemspec index c4131b270..4a53983dc 100644 --- a/vagrant.gemspec +++ b/vagrant.gemspec @@ -15,7 +15,8 @@ Gem::Specification.new do |s| s.required_rubygems_version = ">= 1.3.6" s.rubyforge_project = "vagrant" - s.add_dependency "bundler", ">= 1.5.2", "< 1.7.0" + s.add_dependency "bundler", ">= 1.5.2" +#, "< 1.7.0" s.add_dependency "childprocess", "~> 0.5.0" s.add_dependency "erubis", "~> 2.7.0" s.add_dependency "i18n", "~> 0.6.0" From 3321a6da117b050713a6f250aa18b91a3e985352 Mon Sep 17 00:00:00 2001 From: Ben Hines Date: Sun, 19 Oct 2014 21:34:54 -0700 Subject: [PATCH 03/15] Make environment path param more canonical with an underscore --- Vagrantfile | 2 +- plugins/provisioners/puppet/config/puppet.rb | 56 ++++++++++---------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 2dea5e123..0f5f34c66 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -19,7 +19,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| end config.vm.provision "puppet" do |puppet| - puppet.environmentpath = "../puppet/environments" + puppet.environment_path = "../puppet/environments" puppet.environment = "testenv" # puppet.manifests_path = "../puppet/manifests" # puppet.manifest_file = "site.pp" diff --git a/plugins/provisioners/puppet/config/puppet.rb b/plugins/provisioners/puppet/config/puppet.rb index cc028b8db..a6140b037 100644 --- a/plugins/provisioners/puppet/config/puppet.rb +++ b/plugins/provisioners/puppet/config/puppet.rb @@ -11,7 +11,7 @@ module VagrantPlugins attr_accessor :manifest_file attr_accessor :manifests_path attr_accessor :environment - attr_accessor :environmentpath + attr_accessor :environment_path attr_accessor :module_path attr_accessor :options attr_accessor :synced_folder_type @@ -21,17 +21,17 @@ module VagrantPlugins def initialize super - @hiera_config_path = UNSET_VALUE - @manifest_file = UNSET_VALUE - @manifests_path = UNSET_VALUE - @environment = UNSET_VALUE - @environmentpath = UNSET_VALUE - @module_path = UNSET_VALUE - @options = [] - @facter = {} + @hiera_config_path = UNSET_VALUE + @manifest_file = UNSET_VALUE + @manifests_path = UNSET_VALUE + @environment = UNSET_VALUE + @environment_path = UNSET_VALUE + @module_path = UNSET_VALUE + @options = [] + @facter = {} @synced_folder_type = UNSET_VALUE - @temp_dir = UNSET_VALUE - @working_directory = UNSET_VALUE + @temp_dir = UNSET_VALUE + @working_directory = UNSET_VALUE end def nfs=(value) @@ -49,7 +49,7 @@ module VagrantPlugins def merge(other) super.tap do |result| result.facter = @facter.merge(other.facter) - result.environmentpath = @facter.merge(other.environmentpath) + result.environment_path = @facter.merge(other.environment_path) result.environment = @facter.merge(other.environment) end end @@ -57,11 +57,11 @@ module VagrantPlugins def finalize! super - if @environmentpath == UNSET_VALUE + if @environment_path == UNSET_VALUE if @manifests_path == UNSET_VALUE if 1 #If puppet 3.4+ - puts "Puppet 3.4+, manifests_path is unset and environmentpath is unset, presuming an environment" - @environmentpath = [:host, "environments"] + puts "Puppet 3.4+, manifests_path is unset and environment_path is unset, presuming an environment" + @environment_path = [:host, "environments"] else @manifests_path = [:host, "manifests"] end @@ -71,19 +71,19 @@ module VagrantPlugins @manifests_path = [:host, @manifests_path] end else - if @environmentpath && !@environmentpath.is_a?(Array) - @environmentpath = [:host, @environmentpath] + if @environment_path && !@environment_path.is_a?(Array) + @environment_path = [:host, @environment_path] end end @hiera_config_path = nil if @hiera_config_path == UNSET_VALUE - if @environmentpath == UNSET_VALUE + if @environment_path == UNSET_VALUE @manifests_path[0] = @manifests_path[0].to_sym - @environmentpath = nil + @environment_path = nil @manifest_file = "default.pp" if @manifest_file == UNSET_VALUE else - @environmentpath[0] = @environmentpath[0].to_sym + @environment_path[0] = @environment_path[0].to_sym @environment = "production" if @environment == UNSET_VALUE @manifest_file = nil end @@ -121,8 +121,8 @@ module VagrantPlugins # Calculate the manifests and module paths based on env this_expanded_module_paths = expanded_module_paths(machine.env.root_path) - if environmentpath != UNSET_VALUE && manifests_path != UNSET_VALUE - errors << "You may not specify both environmentpath and manifests_path. Please specify environment and environmentpath only" + if environment_path != UNSET_VALUE && manifests_path != UNSET_VALUE + errors << "You may not specify both environment_path and manifests_path. Please specify environment and environment_path only" end # Manifests path/file validation @@ -143,24 +143,24 @@ module VagrantPlugins end # Environments path/file validation - if environmentpath != UNSET_VALUE && environmentpath[0].to_sym == :host - expanded_path = Pathname.new(environmentpath[1]). + if environment_path != UNSET_VALUE && environment_path[0].to_sym == :host + expanded_path = Pathname.new(environment_path[1]). expand_path(machine.env.root_path) if !expanded_path.directory? - errors << I18n.t("vagrant.provisioners.puppet.environmentpath_missing", + errors << I18n.t("vagrant.provisioners.puppet.environment_path_missing", path: expanded_path.to_s) else expanded_environment_file = expanded_path.join(environment) if !expanded_environment_file.file? && !expanded_environment_file.directory? errors << I18n.t("vagrant.provisioners.puppet.environment_missing", environment: environment.to_s, - environmentpath: expanded_path.to_s) + environment_path: expanded_path.to_s) end end end - if environmentpath == UNSET_VALUE && manifests_path == UNSET_VALUE - errors << "Please specify either a Puppet environmentpath + environment (preferred) or manifests_path (deprecated)." + if environment_path == UNSET_VALUE && manifests_path == UNSET_VALUE + errors << "Please specify either a Puppet environment_path + environment (preferred) or manifests_path (deprecated)." end # Module paths validation From 3a2a9a3b948f1dc7f8dc7a49494e4c48eaf5a5e6 Mon Sep 17 00:00:00 2001 From: Ben Hines Date: Sat, 11 Apr 2015 23:35:25 -0700 Subject: [PATCH 04/15] Add a binary_path option to the puppet provisioner to match the chef provisioner, and support new puppet 4 install location. --- plugins/provisioners/puppet/config/puppet.rb | 9 ++++++- .../provisioners/puppet/provisioner/puppet.rb | 25 +++++++++++++------ 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/plugins/provisioners/puppet/config/puppet.rb b/plugins/provisioners/puppet/config/puppet.rb index eccd5f780..0e4fabaeb 100644 --- a/plugins/provisioners/puppet/config/puppet.rb +++ b/plugins/provisioners/puppet/config/puppet.rb @@ -1,7 +1,12 @@ module VagrantPlugins module Puppet module Config - class Puppet < Vagrant.plugin("2", :config) + class Puppet < Vagrant.plugin("2", :config) + + # The path to Puppet's bin/ directory. + # @return [String] + attr_accessor :binary_path + attr_accessor :facter attr_accessor :hiera_config_path attr_accessor :manifest_file @@ -17,6 +22,7 @@ module VagrantPlugins def initialize super + @binary_path = UNSET_VALUE @hiera_config_path = UNSET_VALUE @manifest_file = UNSET_VALUE @manifests_path = UNSET_VALUE @@ -88,6 +94,7 @@ module VagrantPlugins @synced_folder_type = nil if @synced_folder_type == UNSET_VALUE @temp_dir = "/tmp/vagrant-puppet" if @temp_dir == UNSET_VALUE @working_directory = nil if @working_directory == UNSET_VALUE + @binary_path = nil if @binary_path == UNSET_VALUE end # Returns the module paths as an array of paths expanded relative to the diff --git a/plugins/provisioners/puppet/provisioner/puppet.rb b/plugins/provisioners/puppet/provisioner/puppet.rb index 66461af5e..0cd5e8033 100644 --- a/plugins/provisioners/puppet/provisioner/puppet.rb +++ b/plugins/provisioners/puppet/provisioner/puppet.rb @@ -103,7 +103,7 @@ module VagrantPlugins verify_shared_folders(check) # Verify Puppet is installed and run it - verify_binary("puppet") + verify_binary(puppet_binary_path("puppet")) # Upload Hiera configuration if we have it @hiera_config_path = nil @@ -138,12 +138,23 @@ module VagrantPlugins end end + # Returns the path to the Puppet binary, taking into account the + # `binary_path` configuration option. + def puppet_binary_path(binary) + return binary if !@config.binary_path + return File.join(@config.binary_path, binary) + end + def verify_binary(binary) - @machine.communicate.sudo( - "which #{binary}", - error_class: PuppetError, - error_key: :not_detected, - binary: binary) + puts "verify_binary: #{binary}" + if !machine.communicate.test("sh -c 'command -v #{binary}'") + @config.binary_path = "/opt/puppetlabs/bin" + @machine.communicate.sudo( + "test -x /opt/puppetlabs/bin/#{binary}", + error_class: PuppetError, + error_key: :not_detected, + binary: binary) + end end def run_puppet_apply @@ -200,7 +211,7 @@ module VagrantPlugins facter = "#{facts.join(" ")} " end - command = "#{facter}puppet apply #{options}" + command = "#{facter} #{config.binary_path}/puppet apply #{options}" if config.working_directory if windows? command = "cd #{config.working_directory}; if (`$?) \{ #{command} \}" From e2c68fc12d2373e755abc3685de7e19d94ced88d Mon Sep 17 00:00:00 2001 From: Ben Hines Date: Sat, 11 Apr 2015 23:48:18 -0700 Subject: [PATCH 05/15] Correct environment path config name. --- .../provisioners/puppet/provisioner/puppet.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/plugins/provisioners/puppet/provisioner/puppet.rb b/plugins/provisioners/puppet/provisioner/puppet.rb index 0cd5e8033..700cc6580 100644 --- a/plugins/provisioners/puppet/provisioner/puppet.rb +++ b/plugins/provisioners/puppet/provisioner/puppet.rb @@ -32,11 +32,11 @@ module VagrantPlugins folder_opts[:type] = @config.synced_folder_type if @config.synced_folder_type folder_opts[:owner] = "root" if !@config.synced_folder_type - if @config.environmentpath.is_a?(Array) + if @config.environment_path.is_a?(Array) # Share the environments directory with the guest - if @config.environmentpath[0].to_sym == :host + if @config.environment_path[0].to_sym == :host root_config.vm.synced_folder( - File.expand_path(@config.environmentpath[1], root_path), + File.expand_path(@config.environment_path[1], root_path), environments_guest_path, folder_opts) end parse_environment_metadata() @@ -87,7 +87,7 @@ module VagrantPlugins if @config.manifests_path.is_a?(Array) && @config.manifests_path[0] == :host check << manifests_guest_path end - if @config.environmentpath.is_a?(Array) && @config.environmentpath[0] == :host + if @config.environment_path.is_a?(Array) && @config.environment_path[0] == :host check << environments_guest_path end @module_paths.each do |host_path, guest_path| @@ -129,12 +129,12 @@ module VagrantPlugins end def environments_guest_path - if config.environmentpath[0] == :host + if config.environment_path[0] == :host # The path is on the host, so point to where it is shared File.join(config.temp_dir, "environments") else # The path is on the VM, so just point directly to it - config.environmentpath[1] + config.environment_path[1] end end @@ -184,7 +184,7 @@ module VagrantPlugins options << "--detailed-exitcodes" - if !config.environmentpath.empty? + if !config.environment_path.empty? options << "#{environments_guest_path}/#{@config.environment}/manifests" options << "--environment #{@config.environment}" else @@ -220,7 +220,7 @@ module VagrantPlugins end end - if !config.environmentpath.empty? + if !config.environment_path.empty? @machine.ui.info(I18n.t( "vagrant.provisioners.puppet.running_puppet_env", environment: config.environment)) From 3ee47acb42e73fff5e83771b19e5b9e77d09c04c Mon Sep 17 00:00:00 2001 From: Ben Hines Date: Sun, 12 Apr 2015 01:18:12 -0700 Subject: [PATCH 06/15] Remove debug output --- plugins/provisioners/puppet/provisioner/puppet.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/provisioners/puppet/provisioner/puppet.rb b/plugins/provisioners/puppet/provisioner/puppet.rb index 700cc6580..df66f5222 100644 --- a/plugins/provisioners/puppet/provisioner/puppet.rb +++ b/plugins/provisioners/puppet/provisioner/puppet.rb @@ -146,7 +146,6 @@ module VagrantPlugins end def verify_binary(binary) - puts "verify_binary: #{binary}" if !machine.communicate.test("sh -c 'command -v #{binary}'") @config.binary_path = "/opt/puppetlabs/bin" @machine.communicate.sudo( From 7a4e7929f84b8b69b10492fac6059c4db22d4716 Mon Sep 17 00:00:00 2001 From: Ben Hines Date: Sun, 12 Apr 2015 01:18:49 -0700 Subject: [PATCH 07/15] Don't parse env metadata until provisioning time. TBD: make it functional --- plugins/provisioners/puppet/provisioner/puppet.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/provisioners/puppet/provisioner/puppet.rb b/plugins/provisioners/puppet/provisioner/puppet.rb index df66f5222..0187d9d68 100644 --- a/plugins/provisioners/puppet/provisioner/puppet.rb +++ b/plugins/provisioners/puppet/provisioner/puppet.rb @@ -39,7 +39,6 @@ module VagrantPlugins File.expand_path(@config.environment_path[1], root_path), environments_guest_path, folder_opts) end - parse_environment_metadata() else # Non-Environment mode @manifest_file = File.join(manifests_guest_path, @config.manifest_file) @@ -114,6 +113,7 @@ module VagrantPlugins @machine.communicate.upload(local_hiera_path, @hiera_config_path) end + parse_environment_metadata run_puppet_apply end From cff7c52716bc2f4ce7c5c2de12dee05b3ca7fd19 Mon Sep 17 00:00:00 2001 From: Ben Hines Date: Sun, 12 Apr 2015 01:25:40 -0700 Subject: [PATCH 08/15] Use localized error message. Update strings for puppet provisioner errors. --- plugins/provisioners/puppet/config/puppet.rb | 4 ++-- templates/locales/en.yml | 13 ++++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/plugins/provisioners/puppet/config/puppet.rb b/plugins/provisioners/puppet/config/puppet.rb index 0e4fabaeb..37584fa11 100644 --- a/plugins/provisioners/puppet/config/puppet.rb +++ b/plugins/provisioners/puppet/config/puppet.rb @@ -117,8 +117,8 @@ module VagrantPlugins # Calculate the manifests and module paths based on env this_expanded_module_paths = expanded_module_paths(machine.env.root_path) - if environment_path != UNSET_VALUE && manifests_path != UNSET_VALUE - errors << "You may not specify both environment_path and manifests_path. Please specify environment and environment_path only" + if environment_path != nil && manifests_path != nil + errors << I18n.t("vagrant.provisioners.puppet.environment_manifest_conflict") end # Manifests path/file validation diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 5159c6c9a..8ddc475db 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -1859,16 +1859,15 @@ en: %{manifest} environment_missing: |- - The configured Puppet environment folder '%{environment}' was not found in the + The configured Puppet environment folder %{environment} was not found in the specified environmentpath %{environmentpath}. Please specify a path to an existing Puppet directory environment. + environment_path_missing: "The environment path specified for Puppet does not exist: %{path}" manifests_path_missing: "The manifests path specified for Puppet does not exist: %{path}" - manifest_missing: |- - The configured Puppet envrionment is missing. Please specify a path to an - existing envrionment file: - - %{environment} - manifests_path_missing: "The environment path specified for Puppet does not exist: %{path}" + environment_manifest_conflict: |- + You may not specify both environment_path and manifests_path. + Please specify environment and environment_path without manifests_path, or + manifests_path without environment_path (deprecated). missing_shared_folders: |- Shared folders that Puppet requires are missing on the virtual machine. This is usually due to configuration changing after already booting the From c701bab2538d567602e82b42e8b49224d652c310 Mon Sep 17 00:00:00 2001 From: Ben Hines Date: Sun, 12 Apr 2015 01:26:41 -0700 Subject: [PATCH 09/15] Properly handle various combinations of Puppet options being specified. --- plugins/provisioners/puppet/config/puppet.rb | 29 +++++++++---------- .../provisioners/puppet/provisioner/puppet.rb | 5 ++-- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/plugins/provisioners/puppet/config/puppet.rb b/plugins/provisioners/puppet/config/puppet.rb index 37584fa11..56b7a4a0f 100644 --- a/plugins/provisioners/puppet/config/puppet.rb +++ b/plugins/provisioners/puppet/config/puppet.rb @@ -61,19 +61,18 @@ module VagrantPlugins if @environment_path == UNSET_VALUE if @manifests_path == UNSET_VALUE - if 1 #If puppet 3.4+ - puts "Puppet 3.4+, manifests_path is unset and environment_path is unset, presuming an environment" + if 1 #If both are unset, assume 'environment' mode. @environment_path = [:host, "environments"] else @manifests_path = [:host, "manifests"] end end - if @manifests_path && !@manifests_path.is_a?(Array) + if @manifests_path != UNSET_VALUE && !@manifests_path.is_a?(Array) @manifests_path = [:host, @manifests_path] end else - if @environment_path && !@environment_path.is_a?(Array) + if @environment_path != UNSET_VALUE && !@environment_path.is_a?(Array) @environment_path = [:host, @environment_path] end end @@ -88,13 +87,15 @@ module VagrantPlugins @environment_path[0] = @environment_path[0].to_sym @environment = "production" if @environment == UNSET_VALUE @manifest_file = nil + @manifests_path = nil end - @module_path = nil if @module_path == UNSET_VALUE - @synced_folder_type = nil if @synced_folder_type == UNSET_VALUE - @temp_dir = "/tmp/vagrant-puppet" if @temp_dir == UNSET_VALUE - @working_directory = nil if @working_directory == UNSET_VALUE @binary_path = nil if @binary_path == UNSET_VALUE + @module_path = nil if @module_path == UNSET_VALUE + @synced_folder_type = nil if @synced_folder_type == UNSET_VALUE + @temp_dir = "/tmp/vagrant-puppet" if @temp_dir == UNSET_VALUE + @working_directory = nil if @working_directory == UNSET_VALUE + end # Returns the module paths as an array of paths expanded relative to the @@ -122,8 +123,7 @@ module VagrantPlugins end # Manifests path/file validation - puts "manifests_path is #{manifests_path}" - if manifests_path != UNSET_VALUE && manifests_path[0].to_sym == :host + if manifests_path != nil && manifests_path[0].to_sym == :host expanded_path = Pathname.new(manifests_path[1]). expand_path(machine.env.root_path) if !expanded_path.directory? @@ -136,10 +136,8 @@ module VagrantPlugins manifest: expanded_manifest_file.to_s) end end - end - - # Environments path/file validation - if environment_path != UNSET_VALUE && environment_path[0].to_sym == :host + elsif environment_path != nil && environment_path[0].to_sym == :host + # Environments path/file validation expanded_path = Pathname.new(environment_path[1]). expand_path(machine.env.root_path) if !expanded_path.directory? @@ -155,7 +153,7 @@ module VagrantPlugins end end - if environment_path == UNSET_VALUE && manifests_path == UNSET_VALUE + if environment_path == nil && manifests_path == nil errors << "Please specify either a Puppet environment_path + environment (preferred) or manifests_path (deprecated)." end @@ -166,7 +164,6 @@ module VagrantPlugins path: path) end end - { "puppet provisioner" => errors } end end diff --git a/plugins/provisioners/puppet/provisioner/puppet.rb b/plugins/provisioners/puppet/provisioner/puppet.rb index 0187d9d68..721b5ac3d 100644 --- a/plugins/provisioners/puppet/provisioner/puppet.rb +++ b/plugins/provisioners/puppet/provisioner/puppet.rb @@ -182,8 +182,7 @@ module VagrantPlugins end options << "--detailed-exitcodes" - - if !config.environment_path.empty? + if config.environment_path options << "#{environments_guest_path}/#{@config.environment}/manifests" options << "--environment #{@config.environment}" else @@ -219,7 +218,7 @@ module VagrantPlugins end end - if !config.environment_path.empty? + if config.environment_path @machine.ui.info(I18n.t( "vagrant.provisioners.puppet.running_puppet_env", environment: config.environment)) From c8f300e5f57c3f18bf350f08cc1d80cb51c4be1e Mon Sep 17 00:00:00 2001 From: Ben Hines Date: Sun, 12 Apr 2015 01:43:19 -0700 Subject: [PATCH 10/15] Correct environment path option to puppet apply. --- plugins/provisioners/puppet/provisioner/puppet.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/provisioners/puppet/provisioner/puppet.rb b/plugins/provisioners/puppet/provisioner/puppet.rb index 721b5ac3d..08e42500d 100644 --- a/plugins/provisioners/puppet/provisioner/puppet.rb +++ b/plugins/provisioners/puppet/provisioner/puppet.rb @@ -183,7 +183,7 @@ module VagrantPlugins options << "--detailed-exitcodes" if config.environment_path - options << "#{environments_guest_path}/#{@config.environment}/manifests" + options << "--environmentpath #{environments_guest_path}/" options << "--environment #{@config.environment}" else options << "--manifestdir #{manifests_guest_path}" From b40426aca5490bb9741fefd1e41a5b9643f259c1 Mon Sep 17 00:00:00 2001 From: Ben Hines Date: Sun, 12 Apr 2015 02:16:54 -0700 Subject: [PATCH 11/15] Properly parse out and use the environment's manifest file which is specified in environment.con. --- plugins/provisioners/puppet/provisioner/puppet.rb | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/plugins/provisioners/puppet/provisioner/puppet.rb b/plugins/provisioners/puppet/provisioner/puppet.rb index 08e42500d..e8aaea552 100644 --- a/plugins/provisioners/puppet/provisioner/puppet.rb +++ b/plugins/provisioners/puppet/provisioner/puppet.rb @@ -56,24 +56,21 @@ module VagrantPlugins end end - # For convenience, add in any module_paths from the Puppet environment.cfg to the vagrant module_paths - # This is needed because puppet apply does not read environment metadata (as of v3.6) def parse_environment_metadata 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| if type == :stdout - #modulepath = $basemodulepath:modules/private:modules/public - puts "got line #{data}" + # Parse out the environment manifest path since puppet apply doesnt do that for us. + if data =~ /\s+manifest\s+=\s(.*)/ + @environment_manifest_path = $1 + @environment_manifest_path.gsub! '$basemodulepath:', "#{environments_guest_path}/#{@config.environment}/" + end end end - puts "Found an environment cfg at: #{environment_conf} - #{conf}" - else - puts "env cfg not found, looked for #{environment_conf}" end end - def provision # If the machine has a wait for reboot functionality, then # do that (primarily Windows) @@ -87,6 +84,7 @@ module VagrantPlugins check << manifests_guest_path end if @config.environment_path.is_a?(Array) && @config.environment_path[0] == :host + @environment_manifest_path = "#{environments_guest_path}/#{@config.environment}/manifests/site.pp" check << environments_guest_path end @module_paths.each do |host_path, guest_path| @@ -183,6 +181,7 @@ module VagrantPlugins options << "--detailed-exitcodes" if config.environment_path + options << " #{@environment_manifest_path}" options << "--environmentpath #{environments_guest_path}/" options << "--environment #{@config.environment}" else From 0efb9a393245f88aaff7e676442a1b7352c8e42d Mon Sep 17 00:00:00 2001 From: Ben Hines Date: Sun, 12 Apr 2015 12:29:50 -0700 Subject: [PATCH 12/15] Fix resolution of puppet path for <4.0 --- plugins/provisioners/puppet/provisioner/puppet.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/provisioners/puppet/provisioner/puppet.rb b/plugins/provisioners/puppet/provisioner/puppet.rb index e8aaea552..b205b6b79 100644 --- a/plugins/provisioners/puppet/provisioner/puppet.rb +++ b/plugins/provisioners/puppet/provisioner/puppet.rb @@ -145,12 +145,12 @@ module VagrantPlugins def verify_binary(binary) if !machine.communicate.test("sh -c 'command -v #{binary}'") - @config.binary_path = "/opt/puppetlabs/bin" - @machine.communicate.sudo( - "test -x /opt/puppetlabs/bin/#{binary}", - error_class: PuppetError, - error_key: :not_detected, - binary: binary) + @config.binary_path = "/opt/puppetlabs/bin/" + @machine.communicate.sudo( + "test -x /opt/puppetlabs/bin/#{binary}", + error_class: PuppetError, + error_key: :not_detected, + binary: binary) end end @@ -208,7 +208,7 @@ module VagrantPlugins facter = "#{facts.join(" ")} " end - command = "#{facter} #{config.binary_path}/puppet apply #{options}" + command = "#{facter} #{config.binary_path}puppet apply #{options}" if config.working_directory if windows? command = "cd #{config.working_directory}; if (`$?) \{ #{command} \}" From ffcb58bcd90a2221bdd338c2181fd5c1f334247b Mon Sep 17 00:00:00 2001 From: Ben Hines Date: Sun, 12 Apr 2015 12:31:31 -0700 Subject: [PATCH 13/15] When using environments, allow specifying the 'main manifest' using manifest_path and manifest_file. --- plugins/provisioners/puppet/config/puppet.rb | 38 ++++++++----------- .../provisioners/puppet/provisioner/puppet.rb | 20 +++++----- templates/locales/en.yml | 4 -- 3 files changed, 27 insertions(+), 35 deletions(-) diff --git a/plugins/provisioners/puppet/config/puppet.rb b/plugins/provisioners/puppet/config/puppet.rb index 56b7a4a0f..99b06face 100644 --- a/plugins/provisioners/puppet/config/puppet.rb +++ b/plugins/provisioners/puppet/config/puppet.rb @@ -59,24 +59,18 @@ module VagrantPlugins def finalize! super - if @environment_path == UNSET_VALUE - if @manifests_path == UNSET_VALUE - if 1 #If both are unset, assume 'environment' mode. - @environment_path = [:host, "environments"] - else - @manifests_path = [:host, "manifests"] - end - end - - if @manifests_path != UNSET_VALUE && !@manifests_path.is_a?(Array) - @manifests_path = [:host, @manifests_path] - end - else - if @environment_path != UNSET_VALUE && !@environment_path.is_a?(Array) - @environment_path = [:host, @environment_path] - end + if @environment_path == UNSET_VALUE && @manifests_path == UNSET_VALUE + #If both are unset, assume 'manifests' mode for now. TBD: Switch to environments by default? + @manifests_path = [:host, "manifests"] end + # If the paths are just strings, assume they are 'host' paths (rather than guest) + if @environment_path != UNSET_VALUE && !@environment_path.is_a?(Array) + @environment_path = [:host, @environment_path] + end + if @manifests_path != UNSET_VALUE && !@manifests_path.is_a?(Array) + @manifests_path = [:host, @manifests_path] + end @hiera_config_path = nil if @hiera_config_path == UNSET_VALUE if @environment_path == UNSET_VALUE @@ -86,8 +80,12 @@ module VagrantPlugins else @environment_path[0] = @environment_path[0].to_sym @environment = "production" if @environment == UNSET_VALUE - @manifest_file = nil - @manifests_path = nil + if @manifests_path == UNSET_VALUE + @manifests_path = nil + end + if @manifest_file == UNSET_VALUE + @manifest_file = nil + end end @binary_path = nil if @binary_path == UNSET_VALUE @@ -118,10 +116,6 @@ module VagrantPlugins # Calculate the manifests and module paths based on env this_expanded_module_paths = expanded_module_paths(machine.env.root_path) - if environment_path != nil && manifests_path != nil - errors << I18n.t("vagrant.provisioners.puppet.environment_manifest_conflict") - end - # Manifests path/file validation if manifests_path != nil && manifests_path[0].to_sym == :host expanded_path = Pathname.new(manifests_path[1]). diff --git a/plugins/provisioners/puppet/provisioner/puppet.rb b/plugins/provisioners/puppet/provisioner/puppet.rb index b205b6b79..e68f8fa85 100644 --- a/plugins/provisioners/puppet/provisioner/puppet.rb +++ b/plugins/provisioners/puppet/provisioner/puppet.rb @@ -39,8 +39,8 @@ module VagrantPlugins File.expand_path(@config.environment_path[1], root_path), environments_guest_path, folder_opts) end - else - # Non-Environment mode + end + if @config.manifest_file @manifest_file = File.join(manifests_guest_path, @config.manifest_file) # Share the manifests directory with the guest if @config.manifests_path[0].to_sym == :host @@ -63,8 +63,8 @@ module VagrantPlugins if type == :stdout # Parse out the environment manifest path since puppet apply doesnt do that for us. if data =~ /\s+manifest\s+=\s(.*)/ - @environment_manifest_path = $1 - @environment_manifest_path.gsub! '$basemodulepath:', "#{environments_guest_path}/#{@config.environment}/" + @manifest_file = $1 + @manifest_file.gsub! '$basemodulepath:', "#{environments_guest_path}/#{@config.environment}/" end end end @@ -78,13 +78,17 @@ module VagrantPlugins @machine.guest.capability(:wait_for_reboot) end + # 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" + parse_environment_metadata + end # Check that the shared folders are properly shared check = [] if @config.manifests_path.is_a?(Array) && @config.manifests_path[0] == :host check << manifests_guest_path end if @config.environment_path.is_a?(Array) && @config.environment_path[0] == :host - @environment_manifest_path = "#{environments_guest_path}/#{@config.environment}/manifests/site.pp" check << environments_guest_path end @module_paths.each do |host_path, guest_path| @@ -111,7 +115,6 @@ module VagrantPlugins @machine.communicate.upload(local_hiera_path, @hiera_config_path) end - parse_environment_metadata run_puppet_apply end @@ -181,15 +184,14 @@ module VagrantPlugins options << "--detailed-exitcodes" if config.environment_path - options << " #{@environment_manifest_path}" options << "--environmentpath #{environments_guest_path}/" options << "--environment #{@config.environment}" else options << "--manifestdir #{manifests_guest_path}" - options << @manifest_file end + + options << @manifest_file options = options.join(" ") - @machine.ui.info("Running ye puppet apply with options #{options}") # Build up the custom facts if we have any diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 8ddc475db..f3782cdbf 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -1864,10 +1864,6 @@ en: Please specify a path to an existing Puppet directory environment. environment_path_missing: "The environment path specified for Puppet does not exist: %{path}" manifests_path_missing: "The manifests path specified for Puppet does not exist: %{path}" - environment_manifest_conflict: |- - You may not specify both environment_path and manifests_path. - Please specify environment and environment_path without manifests_path, or - manifests_path without environment_path (deprecated). missing_shared_folders: |- Shared folders that Puppet requires are missing on the virtual machine. This is usually due to configuration changing after already booting the From 602227ca7df1547af3590c0a4179beb40fea9d4c Mon Sep 17 00:00:00 2001 From: Ben Hines Date: Thu, 16 Apr 2015 00:50:53 -0700 Subject: [PATCH 14/15] Remove debug spam from development. --- plugins/provisioners/puppet/provisioner/puppet.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/provisioners/puppet/provisioner/puppet.rb b/plugins/provisioners/puppet/provisioner/puppet.rb index e68f8fa85..e2c7b17e1 100644 --- a/plugins/provisioners/puppet/provisioner/puppet.rb +++ b/plugins/provisioners/puppet/provisioner/puppet.rb @@ -192,7 +192,6 @@ module VagrantPlugins options << @manifest_file options = options.join(" ") - @machine.ui.info("Running ye puppet apply with options #{options}") # Build up the custom facts if we have any facter = "" From 9bbfbef9776cd107cb1c17893985059f8e570ef2 Mon Sep 17 00:00:00 2001 From: Ben Hines Date: Mon, 27 Apr 2015 23:09:07 -0700 Subject: [PATCH 15/15] Be a bit more robust when parsing environment.conf --- plugins/provisioners/puppet/provisioner/puppet.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/plugins/provisioners/puppet/provisioner/puppet.rb b/plugins/provisioners/puppet/provisioner/puppet.rb index e2c7b17e1..00cc1554c 100644 --- a/plugins/provisioners/puppet/provisioner/puppet.rb +++ b/plugins/provisioners/puppet/provisioner/puppet.rb @@ -57,14 +57,17 @@ module VagrantPlugins end def parse_environment_metadata + # 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| if type == :stdout - # Parse out the environment manifest path since puppet apply doesnt do that for us. - if data =~ /\s+manifest\s+=\s(.*)/ - @manifest_file = $1 - @manifest_file.gsub! '$basemodulepath:', "#{environments_guest_path}/#{@config.environment}/" + data.each_line do |line| + if line =~ /^\s*manifest\s+=\s+([^\s]+)/ + @manifest_file = $1 + @manifest_file.gsub! '$basemodulepath:', "#{environments_guest_path}/#{@config.environment}/" + @logger.debug("Using manifest from environment.conf: #{@manifest_file}") + end end end end