Skip to content

Commit

Permalink
BUG: naive attempt at fixing #2970.
Browse files Browse the repository at this point in the history
  • Loading branch information
cournape authored and sethvargo committed May 30, 2015
1 parent 8c3eaae commit 74d2206
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
22 changes: 22 additions & 0 deletions plugins/provisioners/salt/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class Config < Vagrant.plugin("2", :config)
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
Expand Down Expand Up @@ -56,6 +57,7 @@ def initialize
@install_syndic = UNSET_VALUE
@no_minion = UNSET_VALUE
@bootstrap_options = UNSET_VALUE
@config_dir = UNSET_VALUE
end

def finalize!
Expand All @@ -82,6 +84,7 @@ def finalize!
@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

Expand All @@ -90,6 +93,21 @@ def pillar(data)
@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

This comment has been minimized.

Copy link
@bryson

bryson Sep 2, 2015

This causes failure in FreeBSD. SaltStack configuration files are stored in /usr/local/etc/salt/, just as all other configuration packages not included in the base OS. The only OS-specific check is for Windows. The else condition needs to be preceded by an else if or a series of else ifs with conditions for each operating system that Vagrant claims support for before failing over to the default of /etc/salt/.

return "/etc/salt"
end

end

def validate(machine)
errors = _detected_errors
if @minion_config
Expand Down Expand Up @@ -129,6 +147,10 @@ def validate(machine)
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

Expand Down
5 changes: 5 additions & 0 deletions plugins/provisioners/salt/provisioner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,11 @@ def call_overstate
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")

This comment has been minimized.

Copy link
@kevich

kevich Sep 11, 2015

@mitchellh This line created issue #5973 that is quite annoying because it's unable to salt provision anymore.

I suppose we do not have rights to move file to /etc/salt/minion as default, since I suppose it's made as vagrant user, not root, and no sudo

I suggest that this solution not really good anyway, because copy of minion config is done in bootstrap, and here it's made again. I suppose to fix issue #2970 it's needed to change bootstrap behaviour, not hacking highstate function

end

if @config.run_highstate
@machine.env.ui.info "Calling state.highstate... (this may take a while)"
if @config.install_master
Expand Down

0 comments on commit 74d2206

Please sign in to comment.