kitchen-salt 0.6.3 → 0.6.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fc4c23f9c2556d948694d9b5f16b05b8395eb714c3c963632466cf660c0da709
4
- data.tar.gz: d0f705172f2a84be6b4ef074a9c11bab6d757fe871744b8fa061d28671a410a3
3
+ metadata.gz: f264baa2768e6d4a343d428d316da1fa467f365e012804d0184927bdf441efc3
4
+ data.tar.gz: 8a9608d00cdd30471567e3de85073515d8aab496610f6b7867bcb520f888bb85
5
5
  SHA512:
6
- metadata.gz: 4cd2d5eca862930b06bf16a3ccca142b8fb43f3d059f8fb494b7f7838a78b1faf2480ee59ea21ac8c572c890a03e9335a0d4a48e08bef9380a6c66304ad5b266
7
- data.tar.gz: 8698a541bb29198667965c251607c6426285deccb5c5bbf5378c8c019afc5064a525e5c941f84bbafbcb94a372df40ddf9e94d082ca1270cc5df87c52ce0798f
6
+ metadata.gz: 8ca9f7b27528e62f990a791083606c657a070a856063eef2cc632dfc82ce0c00d0a2a87fd3d46b36b687b165b39f28daafe023e521c5920b4afa79972cac8448
7
+ data.tar.gz: 3c9ea1fbd395c1ee5dc4df1f6899ff980e29477e2ffab63f8395745350834eed1db09d83f566356f5e071df097f1e102884634c3b7df2619cd5ef547e210d136
@@ -42,15 +42,15 @@ function fetchGitFormula() {
42
42
  if ! [[ "${FETCHED[*]}" =~ $name ]]; then # dependency not yet fetched
43
43
  echo "Fetching: $name"
44
44
  if test -e "$GIT_FORMULAS_PATH/$name"; then
45
- pushd "$GIT_FORMULAS_PATH/$name" &>/dev/null
45
+ pushd "$GIT_FORMULAS_PATH/$name" &>/dev/null || exit
46
46
  test ! -e .git || git pull -r
47
- popd &>/dev/null
47
+ popd &>/dev/null || exit
48
48
  else
49
49
  echo "git clone $source $GIT_FORMULAS_PATH/$name -b $branch"
50
50
  git clone "$source" "$GIT_FORMULAS_PATH/$name" -b "$branch"
51
51
  fi
52
52
  # install dependencies
53
- FETCHED+=($name)
53
+ FETCHED+=("$name")
54
54
  if [ -e "$GIT_FORMULAS_PATH/$name/metadata.yml" ]; then
55
55
  fetchDependencies "$GIT_FORMULAS_PATH/$name/metadata.yml"
56
56
  fi
@@ -40,7 +40,12 @@ then
40
40
  elif [ -z "${SALT_VERSION}" -a "#{salt_install}" = "pip" ]
41
41
  then
42
42
  echo "Make sure setuptools and pip are new enough"
43
- #{sudo(salt_pip_bin)} install "setuptools>=30" "pip>=9"
43
+ export REQUIREMENTS_FILE=$(mktemp)
44
+ echo "setuptools >=30,<54.* ; python_version < '3.6'" > $REQUIREMENTS_FILE
45
+ echo "setuptools >=30,!=50.*,!=51.*,!=52.*; python_version >= '3.6'" > $REQUIREMENTS_FILE
46
+ echo "pip >=9,<21.0.0 ; python_version < '3.6'" >> $REQUIREMENTS_FILE
47
+ echo "pip >=9 ; python_version >= '3.6'" >> $REQUIREMENTS_FILE
48
+ #{sudo(salt_pip_bin)} install -r $REQUIREMENTS_FILE
44
49
  echo #{sudo(salt_pip_bin)} #{salt_pip_install_command} #{salt_pip_pkg}
45
50
  #{sudo(salt_pip_bin)} #{salt_pip_install_command} #{salt_pip_pkg}
46
51
  elif [ -z "${SALT_VERSION}" -a "#{salt_install}" = "apt" ]
@@ -5,7 +5,7 @@ salt_version = config[:salt_version]
5
5
  bootstrap_options = config[:salt_bootstrap_options] % [salt_version]
6
6
 
7
7
  <<-POWERSHELL
8
- if (Test-Path #{salt_call}) {
8
+ if (Get-Command #{salt_call}) {
9
9
  $installed_version = $(#{salt_call} --version).split(' ')[1]
10
10
  }
11
11
  if (-Not $(Test-Path c:\\temp)) {
@@ -15,6 +15,7 @@ if (-Not $installed_version -And "#{salt_install}" -eq "bootstrap") {
15
15
  [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
16
16
  (New-Object net.webclient).DownloadFile("#{salt_url}", "c:\\temp\\salt_bootstrap.ps1")
17
17
  #{sudo('powershell')} c:\\temp\\salt_bootstrap.ps1 #{bootstrap_options}
18
+ $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine")
18
19
  }
19
20
  $FULL_SALT_VERSION = $(#{salt_call} --version).split(' ')[1]
20
21
  if ($FULL_SALT_VERSION) {
@@ -9,7 +9,7 @@ file_roots:
9
9
  - <%= os_join(config[:root_path], config[:salt_spm_root], 'salt') %>
10
10
 
11
11
  pillar_roots:
12
- <%= config[:salt_env] %>:
12
+ <%= config[:pillar_env] || config[:salt_env] %>:
13
13
  - <%= os_join(config[:root_path], config[:salt_pillar_root]) %>
14
14
  - <%= os_join(config[:root_path], config[:salt_spm_root], 'pillar') %>
15
15
 
@@ -47,18 +47,19 @@ module Kitchen
47
47
  is_file_root: false,
48
48
  local_salt_root: nil,
49
49
  omnibus_cachier: false,
50
+ pillar_env: nil,
50
51
  pillars_from_directories: [],
51
52
  pip_bin: 'pip',
52
53
  pip_editable: false,
53
54
  pip_extra_index_url: [],
54
- pip_index_url: 'https://pypi.python.org/simple/',
55
+ pip_index_url: 'https://pypi.org/simple/',
55
56
  pip_pkg: 'salt==%s',
56
57
  remote_states: nil,
57
58
  require_chef: true,
58
- salt_apt_repo_key: 'https://repo.saltstack.com/apt/ubuntu/16.04/amd64/latest/SALTSTACK-GPG-KEY.pub',
59
- salt_apt_repo: 'https://repo.saltstack.com/apt/ubuntu/16.04/amd64/',
59
+ salt_apt_repo_key: 'https://repo.saltproject.io/apt/ubuntu/16.04/amd64/latest/SALTSTACK-GPG-KEY.pub',
60
+ salt_apt_repo: 'https://repo.saltproject.io/apt/ubuntu/16.04/amd64',
60
61
  salt_bootstrap_options: '',
61
- salt_bootstrap_url: 'https://bootstrap.saltstack.com',
62
+ salt_bootstrap_url: 'https://bootstrap.saltproject.io',
62
63
  salt_config: '/etc/salt',
63
64
  salt_copy_filter: [],
64
65
  salt_env: 'base',
@@ -76,10 +77,10 @@ module Kitchen
76
77
  salt_spm_root: '/srv/spm',
77
78
  salt_state_top: '/srv/salt/top.sls',
78
79
  salt_version: 'latest',
79
- salt_yum_repo_key: 'https://repo.saltstack.com/yum/redhat/$releasever/$basearch/archive/%s/SALTSTACK-GPG-KEY.pub',
80
- salt_yum_repo_latest: 'https://repo.saltstack.com/yum/redhat/salt-repo-latest-2.el7.noarch.rpm',
81
- salt_yum_repo: 'https://repo.saltstack.com/yum/redhat/$releasever/$basearch/archive/%s',
82
- salt_yum_rpm_key: 'https://repo.saltstack.com/yum/redhat/7/x86_64/archive/%s/SALTSTACK-GPG-KEY.pub',
80
+ salt_yum_repo_key: 'https://repo.saltproject.io/yum/redhat/$releasever/$basearch/archive/%s/SALTSTACK-GPG-KEY.pub',
81
+ salt_yum_repo_latest: 'https://repo.saltproject.io/yum/redhat/salt-repo-latest-2.el7.noarch.rpm',
82
+ salt_yum_repo: 'https://repo.saltproject.io/yum/redhat/$releasever/$basearch/archive/%s',
83
+ salt_yum_rpm_key: 'https://repo.saltproject.io/yum/redhat/7/x86_64/archive/%s/SALTSTACK-GPG-KEY.pub',
83
84
  state_collection: false,
84
85
  state_top_from_file: false,
85
86
  state_top: {},
@@ -90,7 +91,7 @@ module Kitchen
90
91
 
91
92
  WIN_DEFAULT_CONFIG = {
92
93
  chef_bootstrap_url: 'https://omnitruck.chef.io/install.ps1',
93
- salt_bootstrap_url: 'https://raw.githubusercontent.com/saltstack/salt-bootstrap/develop/bootstrap-salt.ps1'
94
+ salt_bootstrap_url: 'https://winbootstrap.saltproject.io/develop'
94
95
  }.freeze
95
96
 
96
97
  # salt-call version that supports the undocumented --retcode-passthrough command
@@ -139,8 +140,13 @@ module Kitchen
139
140
  # if salt_verison is set, bootstrap is being used & bootstrap_options is empty,
140
141
  # set the bootstrap_options string to git install the requested version
141
142
  if (salt_version != 'latest') && (config[:salt_install] == 'bootstrap') && config[:salt_bootstrap_options].empty?
142
- debug("Using bootstrap git to install #{salt_version}")
143
- config[:salt_bootstrap_options] = "-P git v#{salt_version}"
143
+ if windows_os?
144
+ debug("Using bootstrap to install #{salt_version}")
145
+ config[:salt_bootstrap_options] = "-version #{salt_version}"
146
+ else
147
+ debug("Using bootstrap git to install #{salt_version}")
148
+ config[:salt_bootstrap_options] = "-P git v#{salt_version}"
149
+ end
144
150
  end
145
151
 
146
152
  install_template = if windows_os?
@@ -276,7 +282,15 @@ module Kitchen
276
282
  if config[:pre_salt_command]
277
283
  cmd << "#{config[:pre_salt_command]} && "
278
284
  end
279
- cmd << sudo("#{salt_call} --state-output=changes --config-dir=#{os_join(config[:root_path], salt_config_path)} state.highstate")
285
+ cmd << sudo("#{salt_call}")
286
+ state_output = config[:salt_minion_extra_config][:state_output]
287
+ if state_output
288
+ cmd << " --state-output=#{state_output}"
289
+ else
290
+ cmd << " --state-output=changes"
291
+ end
292
+ cmd << " --config-dir=#{os_join(config[:root_path], salt_config_path)}"
293
+ cmd << " state.highstate"
280
294
  cmd << " --log-level=#{config[:log_level]}" if config[:log_level]
281
295
  cmd << " --id=#{config[:salt_minion_id]}" if config[:salt_minion_id]
282
296
  cmd << " test=#{config[:dry_run]}" if config[:dry_run]
@@ -413,6 +427,13 @@ module Kitchen
413
427
  end
414
428
 
415
429
  def prepare_dependencies
430
+ # Dependency scripts are bash scripts only
431
+ # Copying them clobbers the kitchen temp directory
432
+ # with a file named `kitchen`. If adding Windows
433
+ # support for dependencies, relocate into a
434
+ # sub-directory
435
+ return if windows_os?
436
+
416
437
  # upload scripts
417
438
  sandbox_scripts_path = File.join(sandbox_path, config[:salt_config], 'scripts')
418
439
  info("Preparing scripts into #{config[:salt_config]}/scripts")
@@ -15,28 +15,27 @@ module Kitchen
15
15
  default_config :tests, []
16
16
  default_config :save, {}
17
17
  default_config :windows, nil
18
+ default_config :windows do |verifier|
19
+ verifier.windows_os? ? true : false
20
+ end
18
21
  default_config :verbose, false
19
22
  default_config :run_destructive, false
20
23
  default_config :runtests, false
21
24
  default_config :coverage, false
22
25
  default_config :junitxml, false
23
26
  default_config :from_filenames, []
27
+ default_config :from_filenames_basename, "changed-files-list.txt"
28
+ default_config :from_filenames_path, false
24
29
  default_config :enable_filenames, false
25
30
  default_config :passthrough_opts, []
26
31
  default_config :output_columns, 120
27
32
  default_config :sysinfo, true
28
33
  default_config :sys_stats, false
29
34
  default_config :environment_vars, {}
35
+ default_config :zip_windows_artifacts, false
30
36
 
31
37
  def call(state)
32
- if config[:windows].nil?
33
- # Since windows is not set, lets try and guess since kitchen actually knows this infomation
34
- if instance.platform.os_type == 'windows'
35
- config[:windows] = true
36
- else
37
- config[:windows] = false
38
- end
39
- end
38
+ create_sandbox
40
39
  debug("Detected platform for instance #{instance.name}: #{instance.platform.os_type}. Config's windows setting value: #{config[:windows]}")
41
40
  if (ENV['ONLY_DOWNLOAD_ARTEFACTS'] || '') == '1'
42
41
  only_download_artefacts = true
@@ -57,16 +56,32 @@ module Kitchen
57
56
  info("[#{name}] Only downloading artefacts from instance #{instance.name} with state=#{state}")
58
57
  else
59
58
  info("[#{name}] Verify on instance #{instance.name} with state=#{state}")
59
+ if ENV['NOX_ENABLE_FROM_FILENAMES']
60
+ config[:enable_filenames] = true
61
+ end
62
+
63
+ if config[:enable_filenames] and ENV['CHANGE_TARGET'] and ENV['BRANCH_NAME'] and ENV['FORCE_FULL'] != 'true'
64
+ require 'git'
65
+ repo = Git.open(Dir.pwd)
66
+ config[:from_filenames] = repo.diff("origin/#{ENV['CHANGE_TARGET']}",
67
+ "origin/#{ENV['BRANCH_NAME']}").name_status.keys.select{|file| file.end_with?('.py')}
68
+ debug("Populating `from_filenames` with: #{config[:from_filenames]}")
69
+ if config[:windows] && config[:from_filenames].any?
70
+ # On windows, if the changed files list is too big, it will error.
71
+ # Let's then pass an absolute path to a text file which contains the list of changed
72
+ # files, one per line.
73
+ config[:from_filenames_path] = File.join(sandbox_path, config[:from_filenames_basename])
74
+ from_filenames_contents = "#{config[:from_filenames].join('\n')}"
75
+ File.open(config[:from_filenames_path], "w") { |f| f.write from_filenames_contents }
76
+ info("Created #{config[:from_filenames_path]} with contents:\n#{from_filenames_contents}")
77
+ end
78
+ end
60
79
  end
61
80
  root_path = (config[:windows] ? '%TEMP%\\kitchen' : '/tmp/kitchen')
62
81
  if ENV['KITCHEN_TESTS']
63
82
  ENV['KITCHEN_TESTS'].split(' ').each{|test| config[:tests].push(test)}
64
83
  end
65
84
 
66
- if ENV['NOX_ENABLE_FROM_FILENAMES']
67
- config[:enable_filenames] = true
68
- end
69
-
70
85
  if ENV['NOX_PASSTHROUGH_OPTS']
71
86
  ENV['NOX_PASSTHROUGH_OPTS'].split(' ').each{|opt| config[:passthrough_opts].push(opt)}
72
87
  end
@@ -107,13 +122,6 @@ module Kitchen
107
122
  sys_stats = ''
108
123
  end
109
124
 
110
- if config[:enable_filenames] and ENV['CHANGE_TARGET'] and ENV['BRANCH_NAME'] and ENV['FORCE_FULL'] != 'true'
111
- require 'git'
112
- repo = Git.open(Dir.pwd)
113
- config[:from_filenames] = repo.diff("origin/#{ENV['CHANGE_TARGET']}",
114
- "origin/#{ENV['BRANCH_NAME']}").name_status.keys.select{|file| file.end_with?('.py')}
115
- end
116
-
117
125
  if config[:junitxml]
118
126
  junitxml = File.join(root_path, config[:testingdir], 'artifacts', 'xml-unittests-output')
119
127
  if noxenv.include? "pytest"
@@ -136,6 +144,7 @@ module Kitchen
136
144
  command = [
137
145
  'nox',
138
146
  "-f #{File.join(root_path, config[:testingdir], 'noxfile.py')}",
147
+ (config[:windows] ? "--envdir=C:\\Windows\\Temp\\nox" : ""),
139
148
  (config[:windows] ? "-e #{noxenv}" : "-e '#{noxenv}'"),
140
149
  '--',
141
150
  "--output-columns=#{config[:output_columns]}",
@@ -149,11 +158,19 @@ module Kitchen
149
158
 
150
159
  if tests.nil? || tests.empty?
151
160
  # If we're not targetting specific tests...
152
- extra_command = [
153
- (config[:from_filenames].any? ? "--from-filenames=#{config[:from_filenames].join(',')}" : ''),
154
- (config[:windows] ? "--names-file=#{root_path}\\testing\\tests\\whitelist.txt" : ''),
155
- ].join(' ')
156
- command = "#{command} #{extra_command}"
161
+ extra_command = []
162
+ if config[:windows]
163
+ extra_command.push("--names-file=#{root_path}\\testing\\tests\\whitelist.txt")
164
+ if config[:from_filenames_path]
165
+ # Add the required command flag for the tests runner
166
+ extra_command.push("--from-filenames=#{root_path}\\testing\\#{config[:from_filenames_basename]}")
167
+ end
168
+ else
169
+ if config[:from_filenames].any?
170
+ extra_command.push("--from-filenames=#{config[:from_filenames].join(',')}")
171
+ end
172
+ end
173
+ command = "#{command} #{extra_command.join(' ')}"
157
174
  else
158
175
  command = "#{command} #{tests}"
159
176
  end
@@ -166,6 +183,9 @@ module Kitchen
166
183
  # the one from config
167
184
  environment_vars.merge!(config[:environment_vars])
168
185
 
186
+ # Strip trailing whitespace
187
+ command = command.rstrip
188
+
169
189
  if config[:windows]
170
190
  command = "cmd.exe /c --% \"#{command}\" 2>&1"
171
191
  end
@@ -193,13 +213,31 @@ module Kitchen
193
213
  end
194
214
  end
195
215
  if not only_download_artefacts
216
+ if config[:from_filenames_path]
217
+ upload_file_path = "$env:KitchenTestingDir\\#{config[:from_filenames_basename]}"
218
+ info("Uploading #{config[:from_filenames_path]} to #{upload_file_path} on #{instance.to_str}")
219
+ conn.upload(config[:from_filenames_path], "#{upload_file_path}")
220
+ end
196
221
  info("Running Command: #{command}")
197
222
  conn.execute(sudo(command))
198
223
  end
199
224
  ensure
200
225
  if not dont_download_artefacts
201
226
  save.each do |remote, local|
202
- unless config[:windows]
227
+ if config[:windows]
228
+ if config[:zip_windows_artifacts]
229
+ begin
230
+ conn.execute("7z.exe a #{remote}artifacts.zip #{remote}")
231
+ rescue => e
232
+ begin
233
+ info("7z.exe failed, attempting zip with powershell Compress-Archive")
234
+ conn.execute("powershell Compress-Archive #{remote} #{remote}artifacts.zip -Force")
235
+ rescue => e2
236
+ error("Failed to create zip: #{e2}")
237
+ end
238
+ end
239
+ end
240
+ else
203
241
  begin
204
242
  conn.execute(sudo("chmod -R +r #{remote}"))
205
243
  rescue => e
@@ -208,7 +246,15 @@ module Kitchen
208
246
  end
209
247
  begin
210
248
  info("Copying #{remote} to #{local}")
211
- conn.download(remote, local)
249
+ if config[:windows]
250
+ if config[:zip_windows_artifacts]
251
+ conn.download(remote + "artifacts.zip", local + "/artifacts.zip")
252
+ system('unzip -o artifacts.zip')
253
+ system('rm artifacts.zip')
254
+ end
255
+ else
256
+ conn.download(remote, local)
257
+ end
212
258
  rescue => e
213
259
  error("Failed to copy #{remote} to #{local} :: #{e}")
214
260
  end
@@ -221,6 +267,8 @@ module Kitchen
221
267
  else
222
268
  debug("[#{name}] Verify completed.")
223
269
  end
270
+ ensure
271
+ cleanup_sandbox
224
272
  end
225
273
  end
226
274
  end
@@ -20,6 +20,9 @@ module Kitchen
20
20
  # load a top.sls from disk
21
21
  if config[:local_salt_root].nil?
22
22
  top_file = 'top.sls'
23
+ unless config[:state_collection].nil?
24
+ top_file = File.join(config[:state_collection], top_file)
25
+ end
23
26
  else
24
27
  top_file = File.join(config[:local_salt_root], 'salt/top.sls')
25
28
  end
@@ -77,7 +80,7 @@ module Kitchen
77
80
  cp_r_with_filter(File.join(path, formula), formula_dir, config[:salt_copy_filter])
78
81
 
79
82
  # copy across the _modules etc directories for python implementation
80
- %w(_modules _states _grains _renderers _returners).each do |extrapath|
83
+ %w(_modules _states _grains _renderers _returners _runners _utils).each do |extrapath|
81
84
  prepare_formula_dir(path, extrapath)
82
85
  end
83
86
  end
@@ -96,6 +99,9 @@ module Kitchen
96
99
 
97
100
  if config[:local_salt_root].nil?
98
101
  states_location = config[:kitchen_root]
102
+ unless config[:state_collection].nil?
103
+ states_location = File.join(states_location, config[:state_collection])
104
+ end
99
105
  else
100
106
  states_location = File.join(config[:local_salt_root], 'salt')
101
107
  end
@@ -57,7 +57,6 @@ module Kitchen
57
57
 
58
58
  def salt_call
59
59
  return config[:salt_call_command] if config[:salt_call_command]
60
- return 'c:\\salt\\salt-call.bat' if windows_os?
61
60
  'salt-call'
62
61
  end
63
62
 
@@ -1,5 +1,5 @@
1
1
  module Kitchen
2
2
  module Salt
3
- VERSION = '0.6.3'.freeze
3
+ VERSION = '0.6.4'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-salt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 0.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - SaltStack Inc
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-16 00:00:00.000000000 Z
11
+ date: 2022-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie
@@ -166,7 +166,7 @@ homepage: https://github.com/saltstack/kitchen-salt
166
166
  licenses:
167
167
  - Apache-2.0
168
168
  metadata: {}
169
- post_install_message:
169
+ post_install_message:
170
170
  rdoc_options: []
171
171
  require_paths:
172
172
  - lib
@@ -182,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
182
182
  version: '0'
183
183
  requirements: []
184
184
  rubygems_version: 3.0.3
185
- signing_key:
185
+ signing_key:
186
186
  specification_version: 4
187
187
  summary: salt provisioner for test-kitchen
188
188
  test_files: []