kitchen-salt 0.0.29 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/lib/kitchen-salt/states.rb +17 -1
- data/lib/kitchen-salt/util.rb +2 -0
- data/lib/kitchen-salt/version.rb +1 -1
- data/lib/kitchen/provisioner/dependencies.erb +1 -0
- data/lib/kitchen/provisioner/formula-fetch.sh +3 -1
- data/lib/kitchen/provisioner/install.erb +19 -6
- data/lib/kitchen/provisioner/minion.erb +1 -0
- data/lib/kitchen/provisioner/salt_solo.rb +49 -2
- data/lib/kitchen/verifier/runtests.rb +62 -0
- metadata +60 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 603063a5f1b59537f46424ca4cd62cdadc7fcd2a666ca00137592f9d8fc82bc6
|
|
4
|
+
data.tar.gz: 2ad2433565df3ad9d109094f10dbad63bc13246a15ced4dbbd52ab51ed25e8a9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 970af9e45fb7c8adadcfede939438bcfc5a37b9aafd42cb2b0214e9ae9192a4cb6cac409bf56c1a5001e52fb8da2222adfbc5faad6a661e28c04014cd41f134a
|
|
7
|
+
data.tar.gz: 46172738dc22bdcd461a75a4d44f8462fe5dc265cc4aad1d5e687e79fef7bfb90c26ca479331167f8212d8e15e9d29c02a40899f0a57ec849f4bf3e3b74b2443
|
data/lib/kitchen-salt/states.rb
CHANGED
|
@@ -32,11 +32,12 @@ module Kitchen
|
|
|
32
32
|
def prepare_states
|
|
33
33
|
if config[:state_collection] || config[:is_file_root] || !config[:local_salt_root].nil?
|
|
34
34
|
prepare_state_collection
|
|
35
|
+
elsif config[:remote_states]
|
|
36
|
+
prepare_remote_states
|
|
35
37
|
else
|
|
36
38
|
prepare_formula config[:kitchen_root], config[:formula]
|
|
37
39
|
prepare_vendor_states
|
|
38
40
|
end
|
|
39
|
-
|
|
40
41
|
end
|
|
41
42
|
|
|
42
43
|
def prepare_vendor_states
|
|
@@ -102,6 +103,21 @@ module Kitchen
|
|
|
102
103
|
FileUtils.mkdir_p(collection_dir)
|
|
103
104
|
cp_r_with_filter(states_location, collection_dir, config[:salt_copy_filter])
|
|
104
105
|
end
|
|
106
|
+
|
|
107
|
+
def prepare_remote_states
|
|
108
|
+
info('Preparing remote states')
|
|
109
|
+
remoteconf = config[:remote_states]
|
|
110
|
+
if remoteconf[:repo] == 'git'
|
|
111
|
+
debug("Cloning #{remoteconf[:name]}")
|
|
112
|
+
require 'git'
|
|
113
|
+
repo = Git.clone(remoteconf[:name], File.join(sandbox_path, config[:salt_file_root]), opts={:branch => remoteconf[:branch]})
|
|
114
|
+
end
|
|
115
|
+
if remoteconf[:testingdir]
|
|
116
|
+
dest = File.join(sandbox_path, remoteconf[:testingdir])
|
|
117
|
+
FileUtils.mkdir_p(dest)
|
|
118
|
+
cp_r_with_filter(config[:kitchen_root], dest, config[:salt_copy_filter])
|
|
119
|
+
end
|
|
120
|
+
end
|
|
105
121
|
end
|
|
106
122
|
end
|
|
107
123
|
end
|
data/lib/kitchen-salt/util.rb
CHANGED
|
@@ -47,6 +47,8 @@ module Kitchen
|
|
|
47
47
|
FileUtils.cp_r "#{source}/.", target if File.symlink? source
|
|
48
48
|
elsif filtered
|
|
49
49
|
debug("Found #{source} in #{filter}, not copying file")
|
|
50
|
+
elsif File.symlink? source
|
|
51
|
+
FileUtils.symlink File.readlink(source), target
|
|
50
52
|
else
|
|
51
53
|
FileUtils.copy source, target
|
|
52
54
|
end
|
data/lib/kitchen-salt/version.rb
CHANGED
|
@@ -51,7 +51,9 @@ function fetchGitFormula() {
|
|
|
51
51
|
fi
|
|
52
52
|
# install dependencies
|
|
53
53
|
FETCHED+=($name)
|
|
54
|
-
|
|
54
|
+
if [ -e "$GIT_FORMULAS_PATH/$name/metadata.yml" ]; then
|
|
55
|
+
fetchDependencies "$GIT_FORMULAS_PATH/$name/metadata.yml"
|
|
56
|
+
fi
|
|
55
57
|
fi
|
|
56
58
|
else
|
|
57
59
|
echo Usage: fetchGitFormula "<git repo>" "[local formula directory name]" "[branch]"
|
|
@@ -10,6 +10,14 @@ salt_yum_rpm_key = config[:salt_yum_rpm_key] % [salt_version]
|
|
|
10
10
|
salt_yum_repo = config[:salt_yum_repo] % [salt_version]
|
|
11
11
|
salt_yum_repo_key = config[:salt_yum_repo_key] % [salt_version]
|
|
12
12
|
salt_yum_repo_latest = config[:salt_yum_repo_latest]
|
|
13
|
+
salt_pip_pkg = config[:pip_install]
|
|
14
|
+
salt_pip_bin = config[:pip_bin]
|
|
15
|
+
salt_pip_install_command = ' install'
|
|
16
|
+
salt_pip_install_command += ' -e' if config[:pip_editable]
|
|
17
|
+
salt_pip_install_command += ' --index-url ' + config[:pip_index_url] if config[:pip_index_url]
|
|
18
|
+
config[:pip_extra_index_url].each do |url|
|
|
19
|
+
salt_pip_install_command += ' --extra-index-url ' + url
|
|
20
|
+
end
|
|
13
21
|
|
|
14
22
|
<<-INSTALL
|
|
15
23
|
sh -c '
|
|
@@ -19,12 +27,20 @@ sh -c '
|
|
|
19
27
|
command -v salt-call >/dev/null 2>&1 && SALT_VERSION=$(salt-call --version|cut -d " " -f 2)
|
|
20
28
|
command -v locale-gen >/dev/null 2>&1 && #{sudo('locale-gen')} en_US.UTF-8
|
|
21
29
|
set +x
|
|
22
|
-
|
|
30
|
+
export DEBIAN_FRONTEND=noninteractive
|
|
23
31
|
|
|
24
32
|
if [ -z "${SALT_VERSION}" -a "#{salt_install}" = "bootstrap" ]
|
|
25
33
|
then
|
|
26
|
-
|
|
27
|
-
#{
|
|
34
|
+
mkdir -p "#{config[:root_path]}"
|
|
35
|
+
BOOTSTRAP="#{config[:root_path]}/bootstrap.sh"
|
|
36
|
+
if ! test -f $BOOTSTRAP; then
|
|
37
|
+
do_download #{salt_url} "$BOOTSTRAP"
|
|
38
|
+
fi
|
|
39
|
+
#{sudo('sh')} $BOOTSTRAP #{bootstrap_options}
|
|
40
|
+
elif [ -z "${SALT_VERSION}" -a "#{salt_install}" = "pip" ]
|
|
41
|
+
then
|
|
42
|
+
echo #{sudo(salt_pip_bin)} #{salt_pip_install_command} #{salt_pip_pkg}
|
|
43
|
+
#{sudo(salt_pip_bin)} #{salt_pip_install_command} #{salt_pip_pkg}
|
|
28
44
|
elif [ -z "${SALT_VERSION}" -a "#{salt_install}" = "apt" ]
|
|
29
45
|
then
|
|
30
46
|
if [ ! $(command -v lsb_release &>/dev/null) ]; then
|
|
@@ -46,18 +62,15 @@ then
|
|
|
46
62
|
#{sudo('apt-get')} update
|
|
47
63
|
sleep 10
|
|
48
64
|
echo "-----> Installing salt-minion (#{salt_version})"
|
|
49
|
-
#{sudo('apt-get')} install -y python-support
|
|
50
65
|
#{sudo('apt-get')} install -y salt-minion salt-common salt-master
|
|
51
66
|
elif [ -z "${SALT_VERSION}" -a "#{salt_install}" = "distrib" ]
|
|
52
67
|
then
|
|
53
68
|
#{sudo('apt-get')} update
|
|
54
|
-
#{sudo('apt-get')} install -y python-support
|
|
55
69
|
#{sudo('apt-get')} install -y salt-minion salt-master
|
|
56
70
|
elif [ -z "${SALT_VERSION}" -a "#{salt_install}" = "ppa" ]
|
|
57
71
|
then
|
|
58
72
|
#{sudo('apt-add-repository')} -y #{salt_ppa}
|
|
59
73
|
#{sudo('apt-get')} update
|
|
60
|
-
#{sudo('apt-get')} install -y python-support
|
|
61
74
|
#{sudo('apt-get')} install -y salt-minion salt-common salt-master
|
|
62
75
|
elif [ -z "${SALT_VERSION}" -a "#{salt_install}" = "yum" ]
|
|
63
76
|
then
|
|
@@ -54,12 +54,13 @@ module Kitchen
|
|
|
54
54
|
salt_pillar_root: '/srv/pillar',
|
|
55
55
|
salt_spm_root: '/srv/spm',
|
|
56
56
|
salt_state_top: '/srv/salt/top.sls',
|
|
57
|
+
salt_force_color: false,
|
|
57
58
|
state_collection: false,
|
|
58
59
|
state_top: {},
|
|
59
60
|
state_top_from_file: false,
|
|
60
|
-
salt_run_highstate: true,
|
|
61
61
|
salt_copy_filter: [],
|
|
62
62
|
is_file_root: false,
|
|
63
|
+
remote_states: nil,
|
|
63
64
|
require_chef: true,
|
|
64
65
|
dependencies: [],
|
|
65
66
|
vendor_path: nil,
|
|
@@ -70,7 +71,13 @@ module Kitchen
|
|
|
70
71
|
salt_yum_rpm_key: 'https://repo.saltstack.com/yum/redhat/7/x86_64/archive/%s/SALTSTACK-GPG-KEY.pub',
|
|
71
72
|
salt_yum_repo: 'https://repo.saltstack.com/yum/redhat/$releasever/$basearch/archive/%s',
|
|
72
73
|
salt_yum_repo_key: 'https://repo.saltstack.com/yum/redhat/$releasever/$basearch/archive/%s/SALTSTACK-GPG-KEY.pub',
|
|
73
|
-
salt_yum_repo_latest: 'https://repo.saltstack.com/yum/redhat/salt-repo-latest-2.el7.noarch.rpm'
|
|
74
|
+
salt_yum_repo_latest: 'https://repo.saltstack.com/yum/redhat/salt-repo-latest-2.el7.noarch.rpm',
|
|
75
|
+
pip_pkg: 'salt==%s',
|
|
76
|
+
pip_editable: false,
|
|
77
|
+
pip_index_url: 'https://pypi.python.org/simple/',
|
|
78
|
+
pip_extra_index_url: [],
|
|
79
|
+
pip_bin: 'pip',
|
|
80
|
+
install_after_init_environment: false,
|
|
74
81
|
}
|
|
75
82
|
|
|
76
83
|
# salt-call version that supports the undocumented --retcode-passthrough command
|
|
@@ -81,6 +88,18 @@ module Kitchen
|
|
|
81
88
|
end
|
|
82
89
|
|
|
83
90
|
def install_command
|
|
91
|
+
unless config[:salt_install] == 'pip' || config[:install_after_init_environment]
|
|
92
|
+
setup_salt
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def prepare_command
|
|
97
|
+
if config[:salt_install] == 'pip' || config[:install_after_init_environment]
|
|
98
|
+
setup_salt
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def setup_salt
|
|
84
103
|
debug(diagnose)
|
|
85
104
|
salt_version = config[:salt_version]
|
|
86
105
|
|
|
@@ -145,6 +164,7 @@ module Kitchen
|
|
|
145
164
|
def create_sandbox
|
|
146
165
|
super
|
|
147
166
|
prepare_data
|
|
167
|
+
prepare_install
|
|
148
168
|
prepare_minion
|
|
149
169
|
prepare_pillars
|
|
150
170
|
prepare_grains
|
|
@@ -154,6 +174,32 @@ module Kitchen
|
|
|
154
174
|
prepare_dependencies
|
|
155
175
|
end
|
|
156
176
|
|
|
177
|
+
def prepare_install
|
|
178
|
+
salt_version = config[:salt_version]
|
|
179
|
+
if config[:salt_install] == 'pip'
|
|
180
|
+
debug("Using pip to install")
|
|
181
|
+
if File.exist?(config[:pip_pkg])
|
|
182
|
+
debug("Installing with pip from sdist")
|
|
183
|
+
sandbox_pip_path = File.join(sandbox_path, 'pip')
|
|
184
|
+
FileUtils.mkdir_p(sandbox_pip_path)
|
|
185
|
+
FileUtils.cp_r(config[:pip_pkg], sandbox_pip_path)
|
|
186
|
+
config[:pip_install] = File.join(config[:root_path], 'pip', File.basename(config[:pip_pkg]))
|
|
187
|
+
else
|
|
188
|
+
debug("Installing with pip from download")
|
|
189
|
+
if salt_version != 'latest'
|
|
190
|
+
config[:pip_install] = config[:pip_pkg] % [salt_version]
|
|
191
|
+
else
|
|
192
|
+
config[:pip_pkg].slice!('==%s')
|
|
193
|
+
config[:pip_install] = config[:pip_pkg]
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
elsif config[:salt_install] == 'bootstrap'
|
|
197
|
+
if File.exists?(config[:salt_bootstrap_url])
|
|
198
|
+
FileUtils.cp_r(config[:salt_bootstrap_url], File.join(sandbox_path, 'bootstrap.sh'))
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
end
|
|
202
|
+
|
|
157
203
|
def init_command
|
|
158
204
|
debug("Initialising Driver #{name}")
|
|
159
205
|
if windows_os?
|
|
@@ -186,6 +232,7 @@ module Kitchen
|
|
|
186
232
|
cmd << " --log-level=#{config[:log_level]}" if config[:log_level]
|
|
187
233
|
cmd << " --id=#{config[:salt_minion_id]}" if config[:salt_minion_id]
|
|
188
234
|
cmd << " test=#{config[:dry_run]}" if config[:dry_run]
|
|
235
|
+
cmd << " --force-color" if config[:salt_force_color]
|
|
189
236
|
if salt_version > RETCODE_VERSION || salt_version == 'latest'
|
|
190
237
|
# hope for the best and hope it works eventually
|
|
191
238
|
cmd << ' --retcode-passthrough'
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
require "kitchen/verifier/base"
|
|
4
|
+
|
|
5
|
+
module Kitchen
|
|
6
|
+
module Verifier
|
|
7
|
+
class Runtests < Kitchen::Verifier::Base
|
|
8
|
+
kitchen_verifier_api_version 1
|
|
9
|
+
|
|
10
|
+
plugin_version Kitchen::VERSION
|
|
11
|
+
|
|
12
|
+
default_config :testingdir, '/testing'
|
|
13
|
+
default_config :python_bin, 'python2'
|
|
14
|
+
default_config :verbose, false
|
|
15
|
+
default_config :run_destructive, false
|
|
16
|
+
default_config :xml, false
|
|
17
|
+
default_config :coverage_xml, false
|
|
18
|
+
default_config :types, []
|
|
19
|
+
default_config :tests, []
|
|
20
|
+
default_config :transport, false
|
|
21
|
+
default_config :save, {}
|
|
22
|
+
default_config :windows, false
|
|
23
|
+
|
|
24
|
+
def call(state)
|
|
25
|
+
info("[#{name}] Verify on instance #{instance.name} with state=#{state}")
|
|
26
|
+
root_path = (config[:windows] ? '$env:TEMP\\kitchen' : '/tmp/kitchen')
|
|
27
|
+
command = [
|
|
28
|
+
(config[:windows] ? 'python.exe' : config[:python_bin]),
|
|
29
|
+
File.join(root_path, config[:testingdir], '/tests/runtests.py'),
|
|
30
|
+
'--sysinfo',
|
|
31
|
+
'--output-columns=80',
|
|
32
|
+
(config[:windows] ? "--names-file=#{root_path}\\testing\\tests\\whitelist.txt" : ''),
|
|
33
|
+
(config[:transport] ? "--transport=#{config[:transport]}" : ''),
|
|
34
|
+
(config[:verbose] ? '-v' : ''),
|
|
35
|
+
(config[:run_destructive] ? "--run-destructive" : ''),
|
|
36
|
+
(config[:coverage_xml] ? "--coverage-xml=#{config[:coverage_xml]}" : ''),
|
|
37
|
+
(config[:xml] ? "--xml=#{config[:xml]}" : ''),
|
|
38
|
+
config[:types].collect{|type| "--#{type}"}.join(' '),
|
|
39
|
+
config[:tests].collect{|test| "-n #{test}"}.join(' '),
|
|
40
|
+
].join(' ')
|
|
41
|
+
info("Running Command: #{command}")
|
|
42
|
+
instance.transport.connection(state) do |conn|
|
|
43
|
+
begin
|
|
44
|
+
if config[:windows]
|
|
45
|
+
conn.execute('$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")')
|
|
46
|
+
end
|
|
47
|
+
conn.execute(sudo(command))
|
|
48
|
+
ensure
|
|
49
|
+
config[:save].each do |remote, local|
|
|
50
|
+
unless config[:windows]
|
|
51
|
+
conn.execute(sudo("chmod -R +r #{remote}"))
|
|
52
|
+
end
|
|
53
|
+
info("Copying #{remote} to #{local}")
|
|
54
|
+
conn.download(remote, local)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
debug("[#{name}] Verify completed.")
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
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.0
|
|
4
|
+
version: 0.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- SaltStack Inc
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2018-01-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: test-kitchen
|
|
@@ -52,6 +52,62 @@ dependencies:
|
|
|
52
52
|
- - "~>"
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
54
|
version: 0.7.3
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: coderay
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: rake
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: yard
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: maruku
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - ">="
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '0'
|
|
104
|
+
type: :development
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - ">="
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '0'
|
|
55
111
|
description: salt provisioner for test-kitchen so that you can test all the things
|
|
56
112
|
email:
|
|
57
113
|
- daniel@gtmanfred.com
|
|
@@ -71,6 +127,7 @@ files:
|
|
|
71
127
|
- lib/kitchen/provisioner/repository-setup.sh
|
|
72
128
|
- lib/kitchen/provisioner/salt_solo.rb
|
|
73
129
|
- lib/kitchen/provisioner/spm.erb
|
|
130
|
+
- lib/kitchen/verifier/runtests.rb
|
|
74
131
|
homepage: https://github.com/saltstack/kitchen-salt
|
|
75
132
|
licenses:
|
|
76
133
|
- Apache-2.0
|
|
@@ -91,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
91
148
|
version: '0'
|
|
92
149
|
requirements: []
|
|
93
150
|
rubyforge_project: "[none]"
|
|
94
|
-
rubygems_version: 2.
|
|
151
|
+
rubygems_version: 2.7.3
|
|
95
152
|
signing_key:
|
|
96
153
|
specification_version: 4
|
|
97
154
|
summary: salt provisioner for test-kitchen
|