From 852812f7787e0300afae5cfd78099e48dcb41b13 Mon Sep 17 00:00:00 2001 From: Jeff Singer Date: Thu, 3 Oct 2013 15:28:35 -0400 Subject: [PATCH] Adding overstate support to the salt provisioner --- plugins/provisioners/salt/config.rb | 3 +++ plugins/provisioners/salt/provisioner.rb | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/plugins/provisioners/salt/config.rb b/plugins/provisioners/salt/config.rb index 77fe6c121..3861d9f88 100644 --- a/plugins/provisioners/salt/config.rb +++ b/plugins/provisioners/salt/config.rb @@ -13,6 +13,7 @@ module VagrantPlugins attr_accessor :master_key attr_accessor :master_pub attr_accessor :run_highstate + attr_accessor :run_overstate attr_accessor :always_install attr_accessor :bootstrap_script attr_accessor :verbose @@ -36,6 +37,7 @@ module VagrantPlugins @master_key = UNSET_VALUE @master_pub = UNSET_VALUE @run_highstate = UNSET_VALUE + @run_overstate = UNSET_VALUE @always_install = UNSET_VALUE @bootstrap_script = UNSET_VALUE @verbose = UNSET_VALUE @@ -58,6 +60,7 @@ module VagrantPlugins @master_key = nil if @master_key == UNSET_VALUE @master_pub = nil if @master_pub == UNSET_VALUE @run_highstate = nil if @run_highstate == UNSET_VALUE + @run_overstate = nil if @run_overstate == UNSET_VALUE @always_install = nil if @always_install == UNSET_VALUE @bootstrap_script = nil if @bootstrap_script == UNSET_VALUE @verbose = nil if @verbose == UNSET_VALUE diff --git a/plugins/provisioners/salt/provisioner.rb b/plugins/provisioners/salt/provisioner.rb index b179da786..49404398d 100644 --- a/plugins/provisioners/salt/provisioner.rb +++ b/plugins/provisioners/salt/provisioner.rb @@ -7,6 +7,7 @@ module VagrantPlugins upload_configs upload_keys run_bootstrap_script + call_overstate call_highstate end @@ -222,6 +223,23 @@ module VagrantPlugins @machine.env.ui.info "Salt did not need installing or configuring." end end + def call_overstate + if @config.run_overstate + if @config.install_master + @machine.env.ui.info "Calling state.overstate... (this may take a while)" + @machine.communicate.sudo("salt '*' saltutil.sync_all") + @machine.communicate.sudo("salt-run state.over") do |type, data| + if @config.verbose + @machine.env.ui.info(data) + end + end + else + @machine.env.ui.info "run_overstate does not make sense on a minion. Not running state.overstate." + end + else + @machine.env.ui.info "run_overstate set to false. Not running state.overstate." + end + end def call_highstate if @config.run_highstate