added most recent version of salty-vagrant and bootstrap.sh
This commit is contained in:
parent
017baa1ddb
commit
e108995023
File diff suppressed because it is too large
Load Diff
|
@ -18,6 +18,7 @@ module VagrantPlugins
|
||||||
attr_accessor :bootstrap_script
|
attr_accessor :bootstrap_script
|
||||||
attr_accessor :verbose
|
attr_accessor :verbose
|
||||||
attr_accessor :seed_master
|
attr_accessor :seed_master
|
||||||
|
attr_reader :pillar_data
|
||||||
|
|
||||||
## bootstrap options
|
## bootstrap options
|
||||||
attr_accessor :temp_config_dir
|
attr_accessor :temp_config_dir
|
||||||
|
@ -41,6 +42,7 @@ module VagrantPlugins
|
||||||
@bootstrap_script = UNSET_VALUE
|
@bootstrap_script = UNSET_VALUE
|
||||||
@verbose = UNSET_VALUE
|
@verbose = UNSET_VALUE
|
||||||
@seed_master = UNSET_VALUE
|
@seed_master = UNSET_VALUE
|
||||||
|
@pillar_data = UNSET_VALUE
|
||||||
@temp_config_dir = UNSET_VALUE
|
@temp_config_dir = UNSET_VALUE
|
||||||
@install_type = UNSET_VALUE
|
@install_type = UNSET_VALUE
|
||||||
@install_args = UNSET_VALUE
|
@install_args = UNSET_VALUE
|
||||||
|
@ -63,6 +65,7 @@ module VagrantPlugins
|
||||||
@bootstrap_script = nil if @bootstrap_script == UNSET_VALUE
|
@bootstrap_script = nil if @bootstrap_script == UNSET_VALUE
|
||||||
@verbose = nil if @verbose == UNSET_VALUE
|
@verbose = nil if @verbose == UNSET_VALUE
|
||||||
@seed_master = nil if @seed_master == UNSET_VALUE
|
@seed_master = nil if @seed_master == UNSET_VALUE
|
||||||
|
@pillar_data = {} if @pillar_data == UNSET_VALUE
|
||||||
@temp_config_dir = nil if @temp_config_dir == UNSET_VALUE
|
@temp_config_dir = nil if @temp_config_dir == UNSET_VALUE
|
||||||
@install_type = nil if @install_type == UNSET_VALUE
|
@install_type = nil if @install_type == UNSET_VALUE
|
||||||
@install_args = nil if @install_args == UNSET_VALUE
|
@install_args = nil if @install_args == UNSET_VALUE
|
||||||
|
@ -73,6 +76,11 @@ module VagrantPlugins
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def pillar(data)
|
||||||
|
@pillar_data = {} if @pillar_data == UNSET_VALUE
|
||||||
|
@pillar_data.deep_merge!(data)
|
||||||
|
end
|
||||||
|
|
||||||
def validate(machine)
|
def validate(machine)
|
||||||
errors = []
|
errors = []
|
||||||
if @minion_key || @minion_pub
|
if @minion_key || @minion_pub
|
||||||
|
|
|
@ -3,15 +3,14 @@ require 'json'
|
||||||
module VagrantPlugins
|
module VagrantPlugins
|
||||||
module Salt
|
module Salt
|
||||||
class Provisioner < Vagrant.plugin("2", :provisioner)
|
class Provisioner < Vagrant.plugin("2", :provisioner)
|
||||||
|
|
||||||
def provision
|
def provision
|
||||||
upload_configs
|
upload_configs
|
||||||
upload_keys
|
upload_keys
|
||||||
run_bootstrap_script
|
run_bootstrap_script
|
||||||
|
|
||||||
if @config.seed_master and @config.install_master
|
# if @config.seed_master and @config.install_master
|
||||||
seed_master
|
# seed_master
|
||||||
end
|
# end
|
||||||
|
|
||||||
if @config.accept_keys
|
if @config.accept_keys
|
||||||
@machine.env.ui.warn "ATTENTION: 'salt.accept_keys' is deprecated. Please use salt.seed_master to upload your minion keys"
|
@machine.env.ui.warn "ATTENTION: 'salt.accept_keys' is deprecated. Please use salt.seed_master to upload your minion keys"
|
||||||
|
@ -23,7 +22,7 @@ module VagrantPlugins
|
||||||
|
|
||||||
def seed_master
|
def seed_master
|
||||||
@machine.env.ui.info 'Uploading %d keys to /etc/salt/pki/master/minions/' % config.seed_master.length
|
@machine.env.ui.info 'Uploading %d keys to /etc/salt/pki/master/minions/' % config.seed_master.length
|
||||||
staged_keys = accepted_keys
|
staged_keys = keys('minions_pre')
|
||||||
@config.seed_master.each do |name, keyfile|
|
@config.seed_master.each do |name, keyfile|
|
||||||
if staged_keys.include? name
|
if staged_keys.include? name
|
||||||
@machine.env.ui.warn "Accepting staged key: %s" %name
|
@machine.env.ui.warn "Accepting staged key: %s" %name
|
||||||
|
@ -39,12 +38,12 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return a list of accepted keys
|
# Return a list of accepted keys
|
||||||
def accepted_keys
|
def keys(group='minions')
|
||||||
out = @machine.communicate.sudo("salt-key -l acc --out json") do |type, output|
|
out = @machine.communicate.sudo("salt-key --out json") do |type, output|
|
||||||
begin
|
begin
|
||||||
if type == :stdout
|
if type == :stdout
|
||||||
out = JSON::load(output)
|
out = JSON::load(output)
|
||||||
break out['minions']
|
break out[group]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -115,6 +114,17 @@ module VagrantPlugins
|
||||||
options = "%s -c %s" % [options, config_dir]
|
options = "%s -c %s" % [options, config_dir]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if @config.seed_master and @config.install_master
|
||||||
|
seed_dir = "/tmp/minion-seed-keys"
|
||||||
|
@machine.communicate.sudo("mkdir -p -m777 #{seed_dir}")
|
||||||
|
@config.seed_master.each do |name, keyfile|
|
||||||
|
sourcepath = expanded_path(keyfile).to_s
|
||||||
|
dest = "#{seed_dir}/seed-#{name}.pub"
|
||||||
|
@machine.communicate.upload(sourcepath, dest)
|
||||||
|
end
|
||||||
|
options = "#{options} -k #{seed_dir}"
|
||||||
|
end
|
||||||
|
|
||||||
if configure and !install
|
if configure and !install
|
||||||
options = "%s -C" % options
|
options = "%s -C" % options
|
||||||
else
|
else
|
||||||
|
@ -123,6 +133,8 @@ module VagrantPlugins
|
||||||
options = "%s -M" % options
|
options = "%s -M" % options
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if @config.install_syndic
|
if @config.install_syndic
|
||||||
options = "%s -S" % options
|
options = "%s -S" % options
|
||||||
end
|
end
|
||||||
|
@ -148,6 +160,11 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
## Actions
|
## Actions
|
||||||
|
# Get pillar string to pass with the salt command
|
||||||
|
def get_pillar
|
||||||
|
" pillar='#{@config.pillar_data.to_json}'" if !@config.pillar_data.empty?
|
||||||
|
end
|
||||||
|
|
||||||
# Copy master and minion configs to VM
|
# Copy master and minion configs to VM
|
||||||
def upload_configs
|
def upload_configs
|
||||||
if @config.minion_config
|
if @config.minion_config
|
||||||
|
@ -240,7 +257,7 @@ module VagrantPlugins
|
||||||
|
|
||||||
key_staged = false
|
key_staged = false
|
||||||
|
|
||||||
keys = accepted_keys
|
keys = keys()
|
||||||
if keys.length > 0
|
if keys.length > 0
|
||||||
@machine.env.ui.info "Minion keys registered:"
|
@machine.env.ui.info "Minion keys registered:"
|
||||||
keys.each do |name|
|
keys.each do |name|
|
||||||
|
@ -283,14 +300,14 @@ module VagrantPlugins
|
||||||
@machine.env.ui.info "Calling state.highstate... (this may take a while)"
|
@machine.env.ui.info "Calling state.highstate... (this may take a while)"
|
||||||
if @config.install_master
|
if @config.install_master
|
||||||
@machine.communicate.sudo("salt '*' saltutil.sync_all")
|
@machine.communicate.sudo("salt '*' saltutil.sync_all")
|
||||||
@machine.communicate.sudo("salt '*' state.highstate --verbose") do |type, data|
|
@machine.communicate.sudo("salt '*' state.highstate --verbose#{get_pillar}") do |type, data|
|
||||||
if @config.verbose
|
if @config.verbose
|
||||||
@machine.env.ui.info(data)
|
@machine.env.ui.info(data)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@machine.communicate.sudo("salt-call saltutil.sync_all")
|
@machine.communicate.sudo("salt-call saltutil.sync_all")
|
||||||
@machine.communicate.sudo("salt-call state.highstate -l debug") do |type, data|
|
@machine.communicate.sudo("salt-call state.highstate -l debug#{get_pillar}") do |type, data|
|
||||||
if @config.verbose
|
if @config.verbose
|
||||||
@machine.env.ui.info(data)
|
@machine.env.ui.info(data)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue