From 3528af2db915c8592cc8cc7959d44f681634ace8 Mon Sep 17 00:00:00 2001 From: David Cournapeau Date: Sat, 15 Mar 2014 20:56:24 +0000 Subject: [PATCH] ENH: simpler masterless configuration. --- plugins/provisioners/salt/config.rb | 9 ++++++--- plugins/provisioners/salt/provisioner.rb | 18 +++++++++++++++++- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/plugins/provisioners/salt/config.rb b/plugins/provisioners/salt/config.rb index 545ea4aa5..f47770d97 100644 --- a/plugins/provisioners/salt/config.rb +++ b/plugins/provisioners/salt/config.rb @@ -23,6 +23,8 @@ module VagrantPlugins attr_reader :pillar_data attr_accessor :colorize attr_accessor :log_level + attr_accessor :masterless + attr_accessor :minion_id ## bootstrap options attr_accessor :temp_config_dir @@ -58,6 +60,8 @@ module VagrantPlugins @no_minion = UNSET_VALUE @bootstrap_options = UNSET_VALUE @config_dir = UNSET_VALUE + @masterless = UNSET_VALUE + @minion_id = UNSET_VALUE end def finalize! @@ -85,7 +89,8 @@ module VagrantPlugins @no_minion = nil if @no_minion == UNSET_VALUE @bootstrap_options = nil if @bootstrap_options == UNSET_VALUE @config_dir = nil if @config_dir == UNSET_VALUE - + @masterless = false if @masterless == UNSET_VALUE + @minion_id = nil if @minion_id == UNSET_VALUE end def pillar(data) @@ -149,8 +154,6 @@ module VagrantPlugins return {"salt provisioner" => errors} end - - end end end diff --git a/plugins/provisioners/salt/provisioner.rb b/plugins/provisioners/salt/provisioner.rb index 8b6c36578..31ea11531 100644 --- a/plugins/provisioners/salt/provisioner.rb +++ b/plugins/provisioners/salt/provisioner.rb @@ -304,13 +304,29 @@ module VagrantPlugins end end + def call_masterless + @machine.env.ui.info "Calling state.highstate in local mode... (this may take a while)" + cmd = "salt-call state.highstate --local" + if @config.minion_id + cmd += " --id #{@config.minion_id}" + end + cmd += " -l debug#{get_pillar}" + @machine.communicate.sudo(cmd) do |type, data| + if @config.verbose + @machine.env.ui.info(data) + end + end + 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 + if @config.masterless + call_masterless + elsif @config.run_highstate @machine.env.ui.info "Calling state.highstate... (this may take a while)" if @config.install_master @machine.communicate.sudo("salt '*' saltutil.sync_all")