Skip to content

Commit

Permalink
Adding config to set version to install
Browse files Browse the repository at this point in the history
  • Loading branch information
PatOShea committed Jul 4, 2015
1 parent 28a4212 commit eab702d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
14 changes: 10 additions & 4 deletions plugins/provisioners/salt/bootstrap-salt.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Salt version to install
$version = '2014.7.1'
Param(
[string]$version
)

# Salt version to install - default to latest if there is an issue
if ($version -notmatch "201[0-9]\.[0-9]\.[0-9](\-\d{1})?"){
$version = '2015.5.2'
}

# Create C:\tmp\ - if Vagrant doesn't upload keys and/or config it might not exist
New-Item C:\tmp\ -ItemType directory -force | out-null
Expand All @@ -21,7 +27,7 @@ if ([IntPtr]::Size -eq 4) {
}

# Download minion setup file
Write-Host "Downloading Salt minion installer ($arch)..."
Write-Host "Downloading Salt minion installer $version-$arch..."
$webclient = New-Object System.Net.WebClient
$url = "https://docs.saltstack.com/downloads/Salt-Minion-$version-$arch-Setup.exe"
$file = "C:\tmp\salt.exe"
Expand Down Expand Up @@ -64,4 +70,4 @@ if ($service.Status -eq "Stopped") {
exit 1
}

Write-Host "Salt minion successfully installed"
Write-Host "Salt minion successfully installed"
7 changes: 5 additions & 2 deletions plugins/provisioners/salt/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Config < Vagrant.plugin("2", :config)
attr_accessor :install_syndic
attr_accessor :no_minion
attr_accessor :bootstrap_options
attr_accessor :version

def initialize
@minion_config = UNSET_VALUE
Expand Down Expand Up @@ -63,6 +64,7 @@ def initialize
@config_dir = UNSET_VALUE
@masterless = UNSET_VALUE
@minion_id = UNSET_VALUE
@version = UNSET_VALUE
end

def finalize!
Expand Down Expand Up @@ -90,8 +92,9 @@ def finalize!
@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
@masterless = false if @masterless == UNSET_VALUE
@minion_id = nil if @minion_id == UNSET_VALUE
@version = nil if @version == UNSET_VALUE
end

def pillar(data)
Expand Down
7 changes: 5 additions & 2 deletions plugins/provisioners/salt/provisioner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def binaries_found
end

def need_configure
@config.minion_config or @config.minion_key or @config.master_config or @config.master_key or @config.grains_config
@config.minion_config or @config.minion_key or @config.master_config or @config.master_key or @config.grains_config or @config.version
end

def need_install
Expand Down Expand Up @@ -237,6 +237,9 @@ def run_bootstrap_script

bootstrap_path = get_bootstrap
if @machine.config.vm.communicator == :winrm
if @config.version
options = "-version %s" % @config.version
end
bootstrap_destination = File.join(config_dir, "bootstrap_salt.ps1")
else
bootstrap_destination = File.join(config_dir, "bootstrap_salt.sh")
Expand All @@ -248,7 +251,7 @@ def run_bootstrap_script
@machine.communicate.upload(bootstrap_path.to_s, bootstrap_destination)
@machine.communicate.sudo("chmod +x %s" % bootstrap_destination)
if @machine.config.vm.communicator == :winrm
bootstrap = @machine.communicate.sudo("powershell.exe -executionpolicy bypass -file %s" % [bootstrap_destination]) do |type, data|
bootstrap = @machine.communicate.sudo("powershell.exe -executionpolicy bypass -file %s %s" % [bootstrap_destination, options]) do |type, data|
if data[0] == "\n"
# Remove any leading newline but not whitespace. If we wanted to
# remove newlines and whitespace we would have used data.lstrip
Expand Down

0 comments on commit eab702d

Please sign in to comment.