From 74d22069d41b35bae50e32c1c68a92a4958afebb Mon Sep 17 00:00:00 2001 From: David Cournapeau Date: Tue, 11 Mar 2014 20:31:40 +0000 Subject: [PATCH 1/2] BUG: naive attempt at fixing #2970. --- plugins/provisioners/salt/config.rb | 22 ++++++++++++++++++++++ plugins/provisioners/salt/provisioner.rb | 5 +++++ 2 files changed, 27 insertions(+) diff --git a/plugins/provisioners/salt/config.rb b/plugins/provisioners/salt/config.rb index 4d97d942c..f31b65786 100644 --- a/plugins/provisioners/salt/config.rb +++ b/plugins/provisioners/salt/config.rb @@ -19,6 +19,7 @@ module VagrantPlugins attr_accessor :bootstrap_script attr_accessor :verbose attr_accessor :seed_master + attr_accessor :config_dir attr_reader :pillar_data attr_accessor :colorize attr_accessor :log_level @@ -56,6 +57,7 @@ module VagrantPlugins @install_syndic = UNSET_VALUE @no_minion = UNSET_VALUE @bootstrap_options = UNSET_VALUE + @config_dir = UNSET_VALUE end def finalize! @@ -82,6 +84,7 @@ module VagrantPlugins @install_syndic = nil if @install_syndic == UNSET_VALUE @no_minion = nil if @no_minion == UNSET_VALUE @bootstrap_options = nil if @bootstrap_options == UNSET_VALUE + @config_dir = nil if @config_dir == UNSET_VALUE end @@ -90,6 +93,21 @@ module VagrantPlugins @pillar_data = Vagrant::Util::DeepMerge.deep_merge(@pillar_data, data) end + def default_config_dir(machine) + guest_type = machine.config.vm.guest + if guest_type == nil + guest_type = :linux + end + + # FIXME: there should be a way to do that a bit smarter + if guest_type == :windows + return "C:\\salt" + else + return "/etc/salt" + end + + end + def validate(machine) errors = _detected_errors if @minion_config @@ -129,6 +147,10 @@ module VagrantPlugins errors << I18n.t("vagrant.provisioners.salt.must_accept_keys") end + if @config_dir == nil + @config_dir = default_config_dir(machine) + end + return {"salt provisioner" => errors} end diff --git a/plugins/provisioners/salt/provisioner.rb b/plugins/provisioners/salt/provisioner.rb index 87af7cc7d..8b6c36578 100644 --- a/plugins/provisioners/salt/provisioner.rb +++ b/plugins/provisioners/salt/provisioner.rb @@ -305,6 +305,11 @@ module VagrantPlugins end def call_highstate + if @config.minion_config + @machine.env.ui.info "Copying salt minion config to #{@config.config dir}" + @machine.communicate.upload(expanded_path(@config.minion_config).to_s, @config.config_dir + "/minion") + end + if @config.run_highstate @machine.env.ui.info "Calling state.highstate... (this may take a while)" if @config.install_master From 0b85e04399e56e6a9fe2d8271592376b960f9c51 Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Sat, 30 May 2015 11:39:18 -0700 Subject: [PATCH 2/2] Minor style fixes for salt config_dir --- plugins/provisioners/salt/config.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/plugins/provisioners/salt/config.rb b/plugins/provisioners/salt/config.rb index f31b65786..545ea4aa5 100644 --- a/plugins/provisioners/salt/config.rb +++ b/plugins/provisioners/salt/config.rb @@ -94,10 +94,7 @@ module VagrantPlugins end def default_config_dir(machine) - guest_type = machine.config.vm.guest - if guest_type == nil - guest_type = :linux - end + guest_type = machine.config.vm.guest || :linux # FIXME: there should be a way to do that a bit smarter if guest_type == :windows @@ -105,7 +102,6 @@ module VagrantPlugins else return "/etc/salt" end - end def validate(machine) @@ -147,7 +143,7 @@ module VagrantPlugins errors << I18n.t("vagrant.provisioners.salt.must_accept_keys") end - if @config_dir == nil + if @config_dir.nil? @config_dir = default_config_dir(machine) end