beaker 1.21.0 → 2.0.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 +8 -8
- data/.gitignore +1 -0
- data/.rspec +1 -0
- data/CONTRIBUTING.md +1 -0
- data/HISTORY.md +17288 -2
- data/Rakefile +6 -2
- data/beaker.gemspec +15 -19
- data/lib/beaker.rb +2 -5
- data/lib/beaker/answers.rb +2 -0
- data/lib/beaker/answers/version34.rb +37 -1
- data/lib/beaker/cli.rb +4 -0
- data/lib/beaker/command.rb +16 -84
- data/lib/beaker/command_factory.rb +13 -2
- data/lib/beaker/dsl/assertions.rb +25 -2
- data/lib/beaker/dsl/ezbake_utils.rb +2 -2
- data/lib/beaker/dsl/helpers.rb +66 -12
- data/lib/beaker/dsl/install_utils.rb +128 -66
- data/lib/beaker/dsl/wrappers.rb +41 -3
- data/lib/beaker/host.rb +42 -6
- data/lib/beaker/host/mac.rb +62 -0
- data/lib/beaker/host/mac/group.rb +96 -0
- data/lib/beaker/host/mac/user.rb +93 -0
- data/lib/beaker/host/unix/exec.rb +1 -1
- data/lib/beaker/host/unix/pkg.rb +11 -11
- data/lib/beaker/host/windows.rb +4 -4
- data/lib/beaker/host_prebuilt_steps.rb +194 -58
- data/lib/beaker/hypervisor.rb +16 -9
- data/lib/beaker/hypervisor/aws_sdk.rb +61 -17
- data/lib/beaker/hypervisor/docker.rb +14 -2
- data/lib/beaker/hypervisor/ec2_helper.rb +15 -3
- data/lib/beaker/hypervisor/vagrant.rb +22 -10
- data/lib/beaker/hypervisor/vagrant_libvirt.rb +11 -0
- data/lib/beaker/hypervisor/vagrant_virtualbox.rb +1 -1
- data/lib/beaker/hypervisor/vcloud_pooled.rb +8 -39
- data/lib/beaker/logger.rb +15 -9
- data/lib/beaker/network_manager.rb +2 -2
- data/lib/beaker/options/command_line_parser.rb +1 -1
- data/lib/beaker/options/parser.rb +1 -8
- data/lib/beaker/options/presets.rb +70 -45
- data/lib/beaker/perf.rb +3 -4
- data/lib/beaker/platform.rb +2 -1
- data/lib/beaker/result.rb +3 -9
- data/lib/beaker/ssh_connection.rb +2 -0
- data/lib/beaker/test_case.rb +2 -21
- data/lib/beaker/test_suite.rb +21 -25
- data/lib/beaker/version.rb +1 -1
- data/spec/beaker/answers_spec.rb +36 -0
- data/spec/beaker/cli_spec.rb +45 -45
- data/spec/beaker/command_spec.rb +25 -36
- data/spec/beaker/dsl/assertions_spec.rb +20 -27
- data/spec/beaker/dsl/ezbake_utils_spec.rb +5 -5
- data/spec/beaker/dsl/helpers_spec.rb +293 -208
- data/spec/beaker/dsl/install_utils_spec.rb +310 -189
- data/spec/beaker/dsl/outcomes_spec.rb +6 -6
- data/spec/beaker/dsl/roles_spec.rb +27 -18
- data/spec/beaker/dsl/structure_spec.rb +11 -11
- data/spec/beaker/dsl/wrappers_spec.rb +35 -11
- data/spec/beaker/host/mac/group_spec.rb +124 -0
- data/spec/beaker/host/mac/user_spec.rb +134 -0
- data/spec/beaker/host/unix/pkg_spec.rb +40 -24
- data/spec/beaker/host/windows/group_spec.rb +1 -1
- data/spec/beaker/host_prebuilt_steps_spec.rb +194 -68
- data/spec/beaker/host_spec.rb +145 -67
- data/spec/beaker/hypervisor/aixer_spec.rb +6 -6
- data/spec/beaker/hypervisor/aws_sdk_spec.rb +22 -7
- data/spec/beaker/hypervisor/docker_spec.rb +71 -50
- data/spec/beaker/hypervisor/ec2_helper_spec.rb +25 -4
- data/spec/beaker/hypervisor/fusion_spec.rb +2 -2
- data/spec/beaker/hypervisor/hypervisor_spec.rb +20 -27
- data/spec/beaker/hypervisor/hypervisor_spec.rb.orig +80 -0
- data/spec/beaker/hypervisor/solaris_spec.rb +8 -8
- data/spec/beaker/hypervisor/vagrant_fusion_spec.rb +6 -8
- data/spec/beaker/hypervisor/vagrant_libvirt_spec.rb +34 -0
- data/spec/beaker/hypervisor/vagrant_spec.rb +34 -33
- data/spec/beaker/hypervisor/vagrant_virtualbox_spec.rb +18 -8
- data/spec/beaker/hypervisor/vagrant_workstation_spec.rb +6 -8
- data/spec/beaker/hypervisor/vcloud_pooled_spec.rb +8 -8
- data/spec/beaker/hypervisor/vcloud_spec.rb +10 -10
- data/spec/beaker/hypervisor/vsphere_helper_spec.rb +8 -8
- data/spec/beaker/hypervisor/vsphere_spec.rb +1 -1
- data/spec/beaker/logger_spec.rb +45 -31
- data/spec/beaker/options/command_line_parser_spec.rb +10 -2
- data/spec/beaker/options/hosts_file_parser_spec.rb +9 -2
- data/spec/beaker/options/options_hash_spec.rb +2 -2
- data/spec/beaker/options/parser_spec.rb +2 -2
- data/spec/beaker/options/pe_version_scaper_spec.rb +6 -1
- data/spec/beaker/options/presets_spec.rb +11 -1
- data/spec/beaker/shared/error_handler_spec.rb +5 -5
- data/spec/beaker/shared/host_manager_spec.rb +3 -2
- data/spec/beaker/shared/repetition_spec.rb +18 -18
- data/spec/beaker/ssh_connection_spec.rb +33 -4
- data/spec/beaker/test_case_spec.rb +9 -9
- data/spec/beaker/test_suite_spec.rb +14 -14
- data/spec/helpers.rb +4 -4
- data/spec/matchers.rb +4 -4
- data/spec/mocks.rb +5 -1
- data/spec/spec_helper.rb +2 -8
- metadata +114 -80
- data/lib/beaker/hypervisor/blimper.rb +0 -108
- data/spec/beaker/hypervisor/blimper_spec.rb +0 -42
- data/spec/beaker/options/data/LATEST +0 -1
- data/spec/beaker/puppet_command_spec.rb +0 -161
- data/spec/mock_blimpy.rb +0 -48
data/lib/beaker/host.rb
CHANGED
|
@@ -31,6 +31,8 @@ module Beaker
|
|
|
31
31
|
Windows::Host.new name, options
|
|
32
32
|
when /aix/
|
|
33
33
|
Aix::Host.new name, options
|
|
34
|
+
when /osx/
|
|
35
|
+
Mac::Host.new name, options
|
|
34
36
|
else
|
|
35
37
|
Unix::Host.new name, options
|
|
36
38
|
end
|
|
@@ -204,6 +206,38 @@ module Beaker
|
|
|
204
206
|
@x86_64 ||= determine_if_x86_64
|
|
205
207
|
end
|
|
206
208
|
|
|
209
|
+
#Add the provided key/val to the current ssh environment
|
|
210
|
+
#@param [String] key The key to add the value to
|
|
211
|
+
#@param [String] val The value for the key
|
|
212
|
+
#@example
|
|
213
|
+
# host.add_env_var('PATH', '/usr/bin:PATH')
|
|
214
|
+
def add_env_var key, val
|
|
215
|
+
key = key.to_s.upcase
|
|
216
|
+
escaped_val = Regexp.escape(val).gsub('/', '\/').gsub(';', '\;')
|
|
217
|
+
#see if the key/value pair already exists
|
|
218
|
+
if exec(Beaker::Command.new("grep -e #{key}=.*#{escaped_val} #{self[:ssh_env_file]}"), :acceptable_exit_codes => (0..255) ).exit_code == 0
|
|
219
|
+
return #nothing to do here, key value pair already exists
|
|
220
|
+
#see if the key already exists
|
|
221
|
+
elsif exec(Beaker::Command.new("grep #{key} #{self[:ssh_env_file]}"), :acceptable_exit_codes => (0..255) ).exit_code == 0
|
|
222
|
+
exec(Beaker::Command.new("sed -i -e \"s/#{key}=/#{key}=#{escaped_val}:/\" #{self[:ssh_env_file]}"))
|
|
223
|
+
else
|
|
224
|
+
exec(Beaker::Command.new("echo \"#{key}=#{val}\" >> #{self[:ssh_env_file]}"))
|
|
225
|
+
end
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
#Delete the provided key/val from the current ssh environment
|
|
229
|
+
#@param [String] key The key to delete the value from
|
|
230
|
+
#@param [String] val The value to delete for the key
|
|
231
|
+
#@example
|
|
232
|
+
# host.delete_env_var('PATH', '/usr/bin:PATH')
|
|
233
|
+
def delete_env_var key, val
|
|
234
|
+
val = Regexp.escape(val).gsub('/', '\/').gsub(';', '\;')
|
|
235
|
+
#if the key only has that single value remove the entire line
|
|
236
|
+
exec(Beaker::Command.new("sed -i -e \"/#{key}=#{val}$/d\" #{self[:ssh_env_file]}"))
|
|
237
|
+
#if the key has multiple values and we only need to remove the provided val
|
|
238
|
+
exec(Beaker::Command.new("sed -i -e \"s/#{key}=\\(.*[:;]*\\)#{val}[:;]*/#{key}=\\1/\" #{self[:ssh_env_file]}"))
|
|
239
|
+
end
|
|
240
|
+
|
|
207
241
|
def connection
|
|
208
242
|
@connection ||= SshConnection.connect( reachable_name,
|
|
209
243
|
self['user'],
|
|
@@ -246,7 +280,7 @@ module Beaker
|
|
|
246
280
|
# No, TestCase has the knowledge about whether its failed, checking acceptable
|
|
247
281
|
# exit codes at the host level and then raising...
|
|
248
282
|
# is it necessary to break execution??
|
|
249
|
-
|
|
283
|
+
if !options[:accept_all_exit_codes] && !result.exit_code_in?(Array(options[:acceptable_exit_codes] || 0))
|
|
250
284
|
raise CommandFailure, "Host '#{self}' exited with #{result.exit_code} running:\n #{cmdline}\nLast #{@options[:trace_limit]} lines of output were:\n#{result.formatted_output(@options[:trace_limit])}"
|
|
251
285
|
end
|
|
252
286
|
end
|
|
@@ -266,7 +300,7 @@ module Beaker
|
|
|
266
300
|
# scp files from the localhost to this test host, if a directory is provided it is recursively copied
|
|
267
301
|
# @param source [String] The path to the file/dir to upload
|
|
268
302
|
# @param target [String] The destination path on the host
|
|
269
|
-
# @param [Hash{Symbol=>String}]
|
|
303
|
+
# @param options [Hash{Symbol=>String}] Options to alter execution
|
|
270
304
|
# @option options [Array<String>] :ignore An array of file/dir paths that will not be copied to the host
|
|
271
305
|
def do_scp_to source, target, options
|
|
272
306
|
@logger.notify "localhost $ scp #{source} #{@name}:#{target} {:ignore => #{options[:ignore]}}"
|
|
@@ -283,6 +317,9 @@ module Beaker
|
|
|
283
317
|
end
|
|
284
318
|
|
|
285
319
|
# either a single file, or a directory with no ignores
|
|
320
|
+
if not File.file?(source) and not File.directory?(source)
|
|
321
|
+
raise IOError, "No such file or directory - #{source}"
|
|
322
|
+
end
|
|
286
323
|
if File.file?(source) or (File.directory?(source) and not has_ignore)
|
|
287
324
|
source_file = source
|
|
288
325
|
if has_ignore and (source =~ ignore_re)
|
|
@@ -306,11 +343,10 @@ module Beaker
|
|
|
306
343
|
@logger.quiet(true)
|
|
307
344
|
required_dirs = (dir_source.map{ | dir | File.dirname(dir) }).uniq
|
|
308
345
|
require 'pathname'
|
|
309
|
-
source_path = Pathname.new(source)
|
|
310
346
|
required_dirs.each do |dir|
|
|
311
347
|
dir_path = Pathname.new(dir)
|
|
312
348
|
if dir_path.absolute?
|
|
313
|
-
mkdir_p(File.join(target,
|
|
349
|
+
mkdir_p(File.join(target, dir.gsub(source, '')))
|
|
314
350
|
else
|
|
315
351
|
mkdir_p( File.join(target, dir) )
|
|
316
352
|
end
|
|
@@ -321,7 +357,7 @@ module Beaker
|
|
|
321
357
|
dir_source.each do |s|
|
|
322
358
|
s_path = Pathname.new(s)
|
|
323
359
|
if s_path.absolute?
|
|
324
|
-
file_path = File.join(target,
|
|
360
|
+
file_path = File.join(target, s.gsub(source,''))
|
|
325
361
|
else
|
|
326
362
|
file_path = File.join(target, s)
|
|
327
363
|
end
|
|
@@ -343,7 +379,7 @@ module Beaker
|
|
|
343
379
|
|
|
344
380
|
end
|
|
345
381
|
|
|
346
|
-
[ 'windows', 'unix', 'aix' ].each do |lib|
|
|
382
|
+
[ 'windows', 'unix', 'aix', 'mac' ].each do |lib|
|
|
347
383
|
require "beaker/host/#{lib}"
|
|
348
384
|
end
|
|
349
385
|
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
[ 'host', 'command_factory', 'command', 'options' ].each do |lib|
|
|
2
|
+
require "beaker/#{lib}"
|
|
3
|
+
end
|
|
4
|
+
|
|
5
|
+
module Mac
|
|
6
|
+
class Host < Beaker::Host
|
|
7
|
+
|
|
8
|
+
[ 'exec', 'file' ].each do |lib|
|
|
9
|
+
require "beaker/host/unix/#{lib}"
|
|
10
|
+
end
|
|
11
|
+
[ 'user', 'group' ].each do |lib|
|
|
12
|
+
require "beaker/host/mac/#{lib}"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
include Mac::User
|
|
16
|
+
include Mac::Group
|
|
17
|
+
include Unix::File
|
|
18
|
+
include Unix::Exec
|
|
19
|
+
|
|
20
|
+
def self.pe_defaults
|
|
21
|
+
h = Beaker::Options::OptionsHash.new
|
|
22
|
+
h.merge({
|
|
23
|
+
'user' => 'root',
|
|
24
|
+
'group' => 'pe-puppet',
|
|
25
|
+
'puppetserver-confdir' => '/etc/puppetlabs/puppetserver/conf.d',
|
|
26
|
+
'puppetservice' => 'pe-httpd',
|
|
27
|
+
'puppetpath' => '/etc/puppetlabs/puppet',
|
|
28
|
+
'puppetbin' => '/opt/puppet/bin/puppet',
|
|
29
|
+
'puppetbindir' => '/opt/puppet/bin',
|
|
30
|
+
'puppetsbindir' => '/opt/puppet/sbin',
|
|
31
|
+
'puppetvardir' => '/var/opt/lib/pe-puppet',
|
|
32
|
+
'hieradatadir' => '/var/lib/hiera',
|
|
33
|
+
'hieraconf' => '/etc/puppetlabs/puppet/hiera.yaml',
|
|
34
|
+
'distmoduledir' => '/etc/puppetlabs/puppet/modules',
|
|
35
|
+
'sitemoduledir' => '/opt/puppet/share/puppet/modules',
|
|
36
|
+
'pathseparator' => ':',
|
|
37
|
+
})
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def self.foss_defaults
|
|
41
|
+
h = Beaker::Options::OptionsHash.new
|
|
42
|
+
h.merge({
|
|
43
|
+
'user' => 'root',
|
|
44
|
+
'group' => 'puppet',
|
|
45
|
+
'puppetserver-confdir' => '/etc/puppetserver/conf.d',
|
|
46
|
+
'puppetservice' => 'puppetmaster',
|
|
47
|
+
'puppetpath' => '/etc/puppet',
|
|
48
|
+
'puppetvardir' => '/var/lib/puppet',
|
|
49
|
+
'puppetbin' => '/usr/bin/puppet',
|
|
50
|
+
'puppetbindir' => '/usr/bin',
|
|
51
|
+
'hieralibdir' => '/opt/puppet-git-repos/hiera/lib',
|
|
52
|
+
'hierapuppetlibdir' => '/opt/puppet-git-repos/hiera-puppet/lib',
|
|
53
|
+
'hierabindir' => '/opt/puppet-git-repos/hiera/bin',
|
|
54
|
+
'hieradatadir' => '/etc/puppet/hieradata',
|
|
55
|
+
'hieraconf' => '/etc/puppet/hiera.yaml',
|
|
56
|
+
'distmoduledir' => '/etc/puppet/modules',
|
|
57
|
+
'sitemoduledir' => '/usr/share/puppet/modules',
|
|
58
|
+
'pathseparator' => ':',
|
|
59
|
+
})
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
module Mac::Group
|
|
2
|
+
include Beaker::CommandFactory
|
|
3
|
+
|
|
4
|
+
# Gets a list of group names on the system
|
|
5
|
+
#
|
|
6
|
+
# @param [Proc] block Additional actions or insertions
|
|
7
|
+
#
|
|
8
|
+
# @return [Array<String>] The list of group names on the system
|
|
9
|
+
def group_list(&block)
|
|
10
|
+
execute('dscacheutil -q group') do |result|
|
|
11
|
+
groups = []
|
|
12
|
+
result.stdout.each_line do |line|
|
|
13
|
+
groups << line.split(': ')[1].strip if line =~ /^name:/
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
yield result if block_given?
|
|
17
|
+
|
|
18
|
+
groups
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Gets the group information in /etc/group format
|
|
23
|
+
#
|
|
24
|
+
# @param [String] name Name of the group you want
|
|
25
|
+
# @param [Proc] block Additional actions or insertions
|
|
26
|
+
#
|
|
27
|
+
# @yield [String] The actual mac dscacheutil output
|
|
28
|
+
# @return [String] Group information in /etc/group format
|
|
29
|
+
# @raise [FailTest] Raises an Assertion failure if it can't find the name
|
|
30
|
+
# queried for in the returned block
|
|
31
|
+
def group_get(name, &block)
|
|
32
|
+
execute("dscacheutil -q group -a name #{name}") do |result|
|
|
33
|
+
fail_test "failed to get group #{name}" unless result.stdout =~ /^name: #{name}/
|
|
34
|
+
gi = Hash.new # group info
|
|
35
|
+
result.stdout.each_line { |line|
|
|
36
|
+
pieces = line.split(': ')
|
|
37
|
+
gi[pieces[0].to_sym] = pieces[1].strip if pieces[1] != nil
|
|
38
|
+
}
|
|
39
|
+
answer = "#{gi[:name]}:#{gi[:password]}:#{gi[:gid]}"
|
|
40
|
+
|
|
41
|
+
yield answer if block_given?
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Gets the gid of the given group
|
|
46
|
+
#
|
|
47
|
+
# @param [String] name Name of the group
|
|
48
|
+
#
|
|
49
|
+
# @return [String] gid of the group
|
|
50
|
+
def group_gid(name)
|
|
51
|
+
gid = -1
|
|
52
|
+
execute("dscacheutil -q group -a name #{name}") do |result|
|
|
53
|
+
result.stdout.each_line { |line|
|
|
54
|
+
if line =~ /^gid:/
|
|
55
|
+
gid = (line[5, line.length - 5]).chomp
|
|
56
|
+
break
|
|
57
|
+
end
|
|
58
|
+
}
|
|
59
|
+
gid
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Makes sure the group is present, creating it if necessary
|
|
64
|
+
#
|
|
65
|
+
# @param [String] name Name of the group
|
|
66
|
+
# @param [Proc] block Additional actions or insertions
|
|
67
|
+
def group_present(name, &block)
|
|
68
|
+
group_exists = false
|
|
69
|
+
execute("dscacheutil -q user -a name #{name}") do |result|
|
|
70
|
+
group_exists = result.stdout =~ /^name: #{name}/
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
return if group_exists
|
|
74
|
+
|
|
75
|
+
gid = gid_next
|
|
76
|
+
create_cmd = "dscl . create /Groups/#{name}"
|
|
77
|
+
create_cmd << " && dscl . create /Groups/#{name} PrimaryGroupID #{gid}"
|
|
78
|
+
execute(create_cmd)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Makes sure the group is absent, deleting it if necessary
|
|
82
|
+
#
|
|
83
|
+
# @param [String] name Name of the group
|
|
84
|
+
# @param [Proc] block Additional actions or insertions
|
|
85
|
+
def group_absent(name, &block)
|
|
86
|
+
execute("if dscl . -list /Groups/#{name}; then dscl . -delete /Groups/#{name}; fi", {}, &block)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# Gives the next gid not used on the system
|
|
90
|
+
#
|
|
91
|
+
# @return [Fixnum] The next gid not used on the system
|
|
92
|
+
def gid_next
|
|
93
|
+
gid_last = execute("dscl . -list /Groups PrimaryGroupID | sort -k 2 -g | tail -1 | awk '{print $2}'")
|
|
94
|
+
gid_last.to_i + 1
|
|
95
|
+
end
|
|
96
|
+
end
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
module Mac::User
|
|
2
|
+
include Beaker::CommandFactory
|
|
3
|
+
|
|
4
|
+
# Gets a list of user names on the system
|
|
5
|
+
#
|
|
6
|
+
# @param [Proc] block Additional actions or insertions
|
|
7
|
+
#
|
|
8
|
+
# @return [Array<String>] The list of user names on the system
|
|
9
|
+
def user_list(&block)
|
|
10
|
+
execute('dscacheutil -q user') do |result|
|
|
11
|
+
users = []
|
|
12
|
+
result.stdout.each_line do |line|
|
|
13
|
+
users << line.split(': ')[1].strip if line =~ /^name:/
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
yield result if block_given?
|
|
17
|
+
|
|
18
|
+
users
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Gets the user information in /etc/passwd format
|
|
23
|
+
#
|
|
24
|
+
# @param [String] name Name of the user
|
|
25
|
+
# @param [Proc] block Additional actions or insertions
|
|
26
|
+
#
|
|
27
|
+
# @yield [String] The actual mac dscacheutil output
|
|
28
|
+
# @return [String] User information in /etc/passwd format
|
|
29
|
+
# @raise [FailTest] Raises an Assertion failure if it can't find the name
|
|
30
|
+
# queried for in the returned block
|
|
31
|
+
def user_get(name, &block)
|
|
32
|
+
answer = ""
|
|
33
|
+
execute("dscacheutil -q user -a name #{name}") do |result|
|
|
34
|
+
fail_test "failed to get user #{name}" unless result.stdout =~ /^name: #{name}/
|
|
35
|
+
ui = Hash.new # user info
|
|
36
|
+
result.stdout.each_line { |line|
|
|
37
|
+
pieces = line.split(': ')
|
|
38
|
+
ui[pieces[0].to_sym] = pieces[1].strip if pieces[1] != nil
|
|
39
|
+
}
|
|
40
|
+
answer = "#{ui[:name]}:#{ui[:password]}:#{ui[:uid]}:#{ui[:gid]}:"
|
|
41
|
+
answer << "#{ui[:name]}:#{ui[:dir]}:#{ui[:shell]}"
|
|
42
|
+
|
|
43
|
+
yield result if block_given?
|
|
44
|
+
end
|
|
45
|
+
answer
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Makes sure the user is present, creating them if necessary
|
|
49
|
+
#
|
|
50
|
+
# @param [String] name Name of the user
|
|
51
|
+
# @param [Proc] block Additional actions or insertions
|
|
52
|
+
def user_present(name, &block)
|
|
53
|
+
user_exists = false
|
|
54
|
+
execute("dscacheutil -q user -a name #{name}") do |result|
|
|
55
|
+
user_exists = result.stdout =~ /^name: #{name}/
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
return if user_exists
|
|
59
|
+
|
|
60
|
+
uid = uid_next
|
|
61
|
+
gid = gid_next
|
|
62
|
+
create_cmd = "dscl . create /Users/#{name}"
|
|
63
|
+
create_cmd << " && dscl . create /Users/#{name} NFSHomeDirectory /Users/#{name}"
|
|
64
|
+
create_cmd << " && dscl . create /Users/#{name} UserShell /bin/bash"
|
|
65
|
+
create_cmd << " && dscl . create /Users/#{name} UniqueID #{uid}"
|
|
66
|
+
create_cmd << " && dscl . create /Users/#{name} PrimaryGroupID #{gid}"
|
|
67
|
+
execute(create_cmd)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Makes sure the user is absent, deleting them if necessary
|
|
71
|
+
#
|
|
72
|
+
# @param [String] name Name of the user
|
|
73
|
+
# @param [Proc] block Additional actions or insertions
|
|
74
|
+
def user_absent(name, &block)
|
|
75
|
+
execute("if dscl . -list /Users/#{name}; then dscl . -delete /Users/#{name}; fi", {}, &block)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# Gives the next uid not used on the system
|
|
79
|
+
#
|
|
80
|
+
# @return [Fixnum] The next uid not used on the system
|
|
81
|
+
def uid_next
|
|
82
|
+
uid_last = execute("dscl . -list /Users UniqueID | sort -k 2 -g | tail -1 | awk '{print $2}'")
|
|
83
|
+
uid_last.to_i + 1
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# Gives the next gid not used on the system
|
|
87
|
+
#
|
|
88
|
+
# @return [Fixnum] The next gid not used on the system
|
|
89
|
+
def gid_next
|
|
90
|
+
gid_last = execute("dscl . -list /Users PrimaryGroupID | sort -k 2 -g | tail -1 | awk '{print $2}'")
|
|
91
|
+
gid_last.to_i + 1
|
|
92
|
+
end
|
|
93
|
+
end
|
|
@@ -14,7 +14,7 @@ module Unix::Exec
|
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
def get_ip
|
|
17
|
-
if self['platform'].include?
|
|
17
|
+
if self['platform'].include?('solaris') || self['platform'].include?('osx')
|
|
18
18
|
execute("ifconfig -a inet| awk '/broadcast/ {print $2}' | cut -d/ -f1 | head -1").strip
|
|
19
19
|
else
|
|
20
20
|
execute("ip a|awk '/global/{print$2}' | cut -d/ -f1 | head -1").strip
|
data/lib/beaker/host/unix/pkg.rb
CHANGED
|
@@ -24,9 +24,9 @@ module Unix::Pkg
|
|
|
24
24
|
when /el-4/
|
|
25
25
|
@logger.debug("Package query not supported on rhel4")
|
|
26
26
|
return false
|
|
27
|
-
when /fedora|centos|el-/
|
|
27
|
+
when /fedora|centos|eos|el-/
|
|
28
28
|
result = exec(Beaker::Command.new("rpm -q #{name}"), :acceptable_exit_codes => (0...127))
|
|
29
|
-
when /ubuntu|debian/
|
|
29
|
+
when /ubuntu|debian|cumulus/
|
|
30
30
|
result = exec(Beaker::Command.new("dpkg -s #{name}"), :acceptable_exit_codes => (0...127))
|
|
31
31
|
when /solaris-11/
|
|
32
32
|
result = exec(Beaker::Command.new("pkg info #{name}"), :acceptable_exit_codes => (0...127))
|
|
@@ -41,7 +41,7 @@ module Unix::Pkg
|
|
|
41
41
|
# If apt has not been updated since the last repo deployment it is
|
|
42
42
|
# updated. Otherwise this is a noop
|
|
43
43
|
def update_apt_if_needed
|
|
44
|
-
if self['platform'] =~ /debian|ubuntu/
|
|
44
|
+
if self['platform'] =~ /debian|ubuntu|cumulus/
|
|
45
45
|
if @apt_needs_update
|
|
46
46
|
execute("apt-get update")
|
|
47
47
|
@apt_needs_update = false
|
|
@@ -55,12 +55,12 @@ module Unix::Pkg
|
|
|
55
55
|
execute("zypper --non-interactive in #{name}")
|
|
56
56
|
when /el-4/
|
|
57
57
|
@logger.debug("Package installation not supported on rhel4")
|
|
58
|
-
when /fedora|centos|el-/
|
|
58
|
+
when /fedora|centos|eos|el-/
|
|
59
59
|
if version
|
|
60
60
|
name = "#{name}-#{version}"
|
|
61
61
|
end
|
|
62
62
|
execute("yum -y #{cmdline_args} install #{name}")
|
|
63
|
-
when /ubuntu|debian/
|
|
63
|
+
when /ubuntu|debian|cumulus/
|
|
64
64
|
if version
|
|
65
65
|
name = "#{name}=#{version}"
|
|
66
66
|
end
|
|
@@ -81,9 +81,9 @@ module Unix::Pkg
|
|
|
81
81
|
execute("zypper --non-interactive rm #{name}")
|
|
82
82
|
when /el-4/
|
|
83
83
|
@logger.debug("Package uninstallation not supported on rhel4")
|
|
84
|
-
when /fedora|centos|el-/
|
|
84
|
+
when /fedora|centos|eos|el-/
|
|
85
85
|
execute("yum -y #{cmdline_args} remove #{name}")
|
|
86
|
-
when /ubuntu|debian/
|
|
86
|
+
when /ubuntu|debian|cumulus/
|
|
87
87
|
execute("apt-get purge #{cmdline_args} -y #{name}")
|
|
88
88
|
when /solaris-11/
|
|
89
89
|
execute("pkg #{cmdline_args} uninstall #{name}")
|
|
@@ -105,9 +105,9 @@ module Unix::Pkg
|
|
|
105
105
|
execute("zypper --non-interactive --no-gpg-checks up #{name}")
|
|
106
106
|
when /el-4/
|
|
107
107
|
@logger.debug("Package upgrade is not supported on rhel4")
|
|
108
|
-
when /fedora|centos|el-/
|
|
108
|
+
when /fedora|centos|eos|el-/
|
|
109
109
|
execute("yum -y #{cmdline_args} update #{name}")
|
|
110
|
-
when /ubuntu|debian/
|
|
110
|
+
when /ubuntu|debian|cumulus/
|
|
111
111
|
update_apt_if_needed
|
|
112
112
|
execute("apt-get install -o Dpkg::Options::='--force-confold' #{cmdline_args} -y --force-yes #{name}")
|
|
113
113
|
when /solaris-11/
|
|
@@ -189,9 +189,9 @@ module Unix::Pkg
|
|
|
189
189
|
case self['platform']
|
|
190
190
|
when /el-4/
|
|
191
191
|
@logger.debug("Package repo deploy is not supported on rhel4")
|
|
192
|
-
when /fedora|centos|el-/
|
|
192
|
+
when /fedora|centos|eos|el-/
|
|
193
193
|
deploy_yum_repo(path, name, version)
|
|
194
|
-
when /ubuntu|debian/
|
|
194
|
+
when /ubuntu|debian|cumulus/
|
|
195
195
|
deploy_apt_repo(path, name, version)
|
|
196
196
|
when /sles/
|
|
197
197
|
deploy_zyp_repo(path, name, version)
|
data/lib/beaker/host/windows.rb
CHANGED
|
@@ -25,8 +25,8 @@ module Windows
|
|
|
25
25
|
'puppetvardir' => '`cygpath -smF 35`/PuppetLabs/puppet/var',
|
|
26
26
|
'distmoduledir' => '`cygpath -smF 35`/PuppetLabs/puppet/etc/modules',
|
|
27
27
|
'sitemoduledir' => 'C:/usr/share/puppet/modules',
|
|
28
|
-
#
|
|
29
|
-
'puppetbindir' => '
|
|
28
|
+
#let's just add both potential bin dirs to the path
|
|
29
|
+
'puppetbindir' => '/cygdrive/c/Program Files (x86)/Puppet Labs/Puppet Enterprise/bin:/cygdrive/c/Program Files/Puppet Labs/Puppet Enterprise/bin',
|
|
30
30
|
'pathseparator' => ';',
|
|
31
31
|
})
|
|
32
32
|
end
|
|
@@ -43,8 +43,8 @@ module Windows
|
|
|
43
43
|
'sitemoduledir' => 'C:/usr/share/puppet/modules',
|
|
44
44
|
'hieralibdir' => '`cygpath -w /opt/puppet-git-repos/hiera/lib`',
|
|
45
45
|
'hierapuppetlibdir' => '`cygpath -w /opt/puppet-git-repos/hiera-puppet/lib`',
|
|
46
|
-
#
|
|
47
|
-
'puppetbindir' => '
|
|
46
|
+
#let's just add both potential bin dirs to the path
|
|
47
|
+
'puppetbindir' => '/cygdrive/c/Program Files (x86)/Puppet Labs/Puppet/bin:/cygdrive/c/Program Files/Puppet Labs/Puppet/bin',
|
|
48
48
|
'hierabindir' => '/opt/puppet-git-repos/hiera/bin',
|
|
49
49
|
'pathseparator' => ';',
|
|
50
50
|
})
|