Skip to content

Commit

Permalink
Merge pull request #340 from dafyddj/fix/salt-call
Browse files Browse the repository at this point in the history
fix: handle v3004+ which can be installed to any location on Windows
  • Loading branch information
krionbsd authored Jan 10, 2022
2 parents ffa2c8d + a157be9 commit cf5c41b
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 11 deletions.
3 changes: 1 addition & 2 deletions docs/provisioner_options.md
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,7 @@ If `false` bypassed the `salt-call` command execution. For cases where the guest

### salt_call_command ###

default for Windows: `c:\salt\salt-call.bat`
default for others: `salt-call`
default: `salt-call`

Command used to invoke `salt-call`.

Expand Down
21 changes: 16 additions & 5 deletions .kitchen.yml → kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@ driver:
socket: <%= ENV['DOCKER_HOST'] || 'unix:///var/run/docker.sock' %>
provision_command:
- DEBIAN_FRONTEND=noninteractive apt-get install -y python3-pip python3-dev gcc git locales console-data gnupg
- pip3 install --upgrade pip
- mkdir -p /run/sshd
- echo en_US.UTF-8 UTF-8 >> /etc/locale.gen; locale-gen; update-locale 'LANG="en_US.UTF-8"'
- echo export LANG=en_US.UTF-8 > ~kitchen/.bashrc
- echo 'export PATH=$PATH:/usr/sbin:/sbin' >> ~kitchen/.bashrc
provisioner:
name: salt_solo
salt_install: bootstrap
salt_version: 3000.6
salt_version: 3004
salt_bootstrap_url: https://bootstrap.saltproject.io
salt_bootstrap_options: -X -x python3 -p git -p curl -p sudo stable 3000.6
salt_bootstrap_options: -X -x python3 -p git -p curl -p sudo stable 3004
pip_bin: pip3
formula: tests
require_chef: false
Expand Down Expand Up @@ -85,7 +86,7 @@ platforms:
sudo mkdir -p /tmp/kitchen/var/cache/salt/master
sudo apt-get update
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y software-properties-common
salt_bootstrap_options: -X -x python3 -p git -p curl -p sudo -p software-properties-common stable 3000.6
salt_bootstrap_options: -X -x python3 -p git -p curl -p sudo -p software-properties-common stable 3004
- name: debian-10
provisioner:
salt_apt_repo: 'https://repo.saltproject.io/py3/debian/10/amd64/archive'
Expand All @@ -104,10 +105,11 @@ platforms:
<% if @vagrant != false %>
- name: windows-2012r2
driver:
box: opentable/win-2012r2-datacenter-amd64-nocm
box: devopsgroup-io/windows_server-2012r2-standard-amd64-nocm
communicator: winrm
linked_clone: true
name: vagrant
gui: true
gui: false
provisioner:
# On Osx 'brew install unix2dos' or Centos 'yum install tofrodos'
cache_commands:
Expand All @@ -120,8 +122,17 @@ platforms:
$OldPath = (Get-ItemProperty -Path "$Reg" -Name PATH).Path
$NewPath= $OldPath + ’;’ + $AddedLocation
Set-ItemProperty -Path "$Reg" -Name PATH –Value $NewPath
pillars:
top.sls:
base:
"*": []
salt_bootstrap_url: https://winbootstrap.saltproject.io/develop
salt_bootstrap_options: ''
salt_minion_extra_config:
file_roots:
base:
- C:\Users\vagrant\AppData\Local\Temp\kitchen\srv\salt
- C:\Users\vagrant\AppData\Local\Temp\kitchen\srv\salt\tests\formula-foo
state_top:
base:
"*":
Expand Down
1 change: 0 additions & 1 deletion lib/kitchen-salt/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ def _cp_r_with_filter(source_path, target_path, filter = [])

def salt_call
return config[:salt_call_command] if config[:salt_call_command]
return 'c:\\salt\\salt-call.bat' if windows_os?
'salt-call'
end

Expand Down
3 changes: 2 additions & 1 deletion lib/kitchen/provisioner/install_win.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ salt_version = config[:salt_version]
bootstrap_options = config[:salt_bootstrap_options] % [salt_version]

<<-POWERSHELL
if (Test-Path #{salt_call}) {
if (Get-Command #{salt_call}) {
$installed_version = $(#{salt_call} --version).split(' ')[1]
}
if (-Not $(Test-Path c:\\temp)) {
Expand All @@ -15,6 +15,7 @@ if (-Not $installed_version -And "#{salt_install}" -eq "bootstrap") {
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
(New-Object net.webclient).DownloadFile("#{salt_url}", "c:\\temp\\salt_bootstrap.ps1")
#{sudo('powershell')} c:\\temp\\salt_bootstrap.ps1 #{bootstrap_options}
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine")
}
$FULL_SALT_VERSION = $(#{salt_call} --version).split(' ')[1]
if ($FULL_SALT_VERSION) {
Expand Down
9 changes: 7 additions & 2 deletions lib/kitchen/provisioner/salt_solo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,13 @@ def setup_salt
# if salt_verison is set, bootstrap is being used & bootstrap_options is empty,
# set the bootstrap_options string to git install the requested version
if (salt_version != 'latest') && (config[:salt_install] == 'bootstrap') && config[:salt_bootstrap_options].empty?
debug("Using bootstrap git to install #{salt_version}")
config[:salt_bootstrap_options] = "-P git v#{salt_version}"
if windows_os?
debug("Using bootstrap to install #{salt_version}")
config[:salt_bootstrap_options] = "-version #{salt_version}"
else
debug("Using bootstrap git to install #{salt_version}")
config[:salt_bootstrap_options] = "-P git v#{salt_version}"
end
end

install_template = if windows_os?
Expand Down
1 change: 1 addition & 0 deletions tests/integration/test_salt.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def test_spm_depends(salt):
assert all([formula in dirs for formula in formulas])


@pytest.mark.skipif('windows' in os.environ.get('KITCHEN_INSTANCE'), reason='Dependencies not supported on windows')
def test_path_depends(salt):
formulas = set(['foo',])
dirs = salt('cp.list_master_dirs')
Expand Down
1 change: 1 addition & 0 deletions tests/pillars/git.sls
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ linux:
enabled: true
sudo: true
full_name: John Doe
gid: users
home: /home/jdoe

0 comments on commit cf5c41b

Please sign in to comment.