rouster 0.63 → 0.64
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -1
- data/Gemfile.lock +0 -5
- data/Rakefile +2 -2
- data/lib/rouster.rb +11 -8
- data/lib/rouster/deltas.rb +4 -4
- data/lib/rouster/tests.rb +4 -3
- data/test/functional/deltas/test_get_groups.rb +1 -1
- data/test/functional/deltas/test_get_os.rb +1 -1
- data/test/functional/deltas/test_get_packages.rb +2 -2
- data/test/functional/test_is_in_file.rb +40 -0
- data/test/unit/testing/test_get_services.rb +4 -4
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 008791a032a42eb032e726fc8f87a7ff0b8a6fcd
|
4
|
+
data.tar.gz: 034c72fff747de93fb5fd4d3067d95af5dacf9c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97db5c53999f5a51747cfc5047bbc237b92dbe17b605c23ac749ee5687518e621a4391aa43efbeebe723b9d575780f77ac2fff3aa7d8df7836277d3cb0239ab1
|
7
|
+
data.tar.gz: 878f36117813b34e06d99b3ba9fd44ab5c5a25c14e76b6c9b316eb833148afb544a2fd00ab61052f733ac7d572fd7618f55e556e9a696a9860c6e2bfa138f2a0
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -52,7 +52,6 @@ GEM
|
|
52
52
|
nokogiri (1.6.3.1)
|
53
53
|
mini_portile (= 0.6.0)
|
54
54
|
power_assert (0.1.4)
|
55
|
-
rake (10.4.2)
|
56
55
|
test-unit (3.0.2)
|
57
56
|
power_assert
|
58
57
|
|
@@ -65,8 +64,4 @@ DEPENDENCIES
|
|
65
64
|
log4r (~> 1.1.9)
|
66
65
|
net-scp
|
67
66
|
net-ssh
|
68
|
-
rake (= 10.4.2)
|
69
67
|
test-unit (~> 3.0.0)
|
70
|
-
|
71
|
-
BUNDLED WITH
|
72
|
-
1.10.6
|
data/Rakefile
CHANGED
data/lib/rouster.rb
CHANGED
@@ -12,7 +12,7 @@ require 'rouster/vagrant'
|
|
12
12
|
class Rouster
|
13
13
|
|
14
14
|
# sporadically updated version number
|
15
|
-
VERSION = 0.
|
15
|
+
VERSION = 0.64
|
16
16
|
|
17
17
|
# custom exceptions -- what else do we want them to include/do?
|
18
18
|
class ArgumentError < StandardError; end # thrown by methods that take parameters from users
|
@@ -514,18 +514,21 @@ class Rouster
|
|
514
514
|
files = {
|
515
515
|
:ubuntu => '/etc/os-release', # debian too
|
516
516
|
:solaris => '/etc/release',
|
517
|
-
:
|
517
|
+
:rhel => ['/etc/os-release', '/etc/redhat-release'], # and centos
|
518
518
|
:osx => '/System/Library/CoreServices/SystemVersion.plist',
|
519
519
|
}
|
520
520
|
|
521
521
|
res = :invalid
|
522
522
|
|
523
|
-
files.
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
523
|
+
files.each_pair do |os, f|
|
524
|
+
[ f ].flatten.each do |candidate|
|
525
|
+
if self.is_file?(candidate)
|
526
|
+
next if candidate.eql?('/etc/os-release') and ! self.is_in_file?(candidate, os.to_s, 'i') # CentOS detection
|
527
|
+
@logger.debug(sprintf('determined OS to be[%s] via[%s]', os, candidate))
|
528
|
+
res = os
|
529
|
+
end
|
528
530
|
end
|
531
|
+
break unless res.eql?(:invalid)
|
529
532
|
end
|
530
533
|
|
531
534
|
@logger.error(sprintf('unable to determine OS, looking for[%s]', files)) if res.eql?(:invalid)
|
@@ -628,7 +631,7 @@ class Rouster
|
|
628
631
|
case os_type
|
629
632
|
when :osx
|
630
633
|
self.run('shutdown -r now')
|
631
|
-
when :
|
634
|
+
when :rhel, :ubuntu, :debian
|
632
635
|
self.run('/sbin/shutdown -rf now')
|
633
636
|
when :solaris
|
634
637
|
self.run('shutdown -y -i5 -g0')
|
data/lib/rouster/deltas.rb
CHANGED
@@ -315,7 +315,7 @@ class Rouster
|
|
315
315
|
|
316
316
|
end
|
317
317
|
|
318
|
-
elsif os.eql?(:
|
318
|
+
elsif os.eql?(:rhel)
|
319
319
|
raw = self.run('rpm -qa --qf "%{n}@%{v}@%{arch}\n"')
|
320
320
|
raw.split("\n").each do |line|
|
321
321
|
next if line.match(/(.*?)\@(.*?)\@(.*)/).nil?
|
@@ -383,7 +383,7 @@ class Rouster
|
|
383
383
|
res = Hash.new()
|
384
384
|
os = self.os_type()
|
385
385
|
|
386
|
-
if os.eql?(:
|
386
|
+
if os.eql?(:rhel) or os.eql?(:ubuntu) or os.eql?(:debian)
|
387
387
|
|
388
388
|
raw = self.run('netstat -ln')
|
389
389
|
|
@@ -472,7 +472,7 @@ class Rouster
|
|
472
472
|
:systemv => 'service --status-all 2>&1',
|
473
473
|
:upstart => 'initctl list',
|
474
474
|
},
|
475
|
-
:
|
475
|
+
:rhel => {
|
476
476
|
:systemv => '/sbin/service --status-all',
|
477
477
|
:upstart => 'initctl list',
|
478
478
|
},
|
@@ -592,7 +592,7 @@ class Rouster
|
|
592
592
|
end
|
593
593
|
end
|
594
594
|
|
595
|
-
elsif os.eql?(:
|
595
|
+
elsif os.eql?(:rhel)
|
596
596
|
|
597
597
|
raw.split("\n").each do |line|
|
598
598
|
if provider.eql?(:systemv)
|
data/lib/rouster/tests.rb
CHANGED
@@ -257,8 +257,9 @@ class Rouster
|
|
257
257
|
# parameters
|
258
258
|
# * <file> - path of filename to examine
|
259
259
|
# * <regex> - regular expression/string to be passed to grep
|
260
|
+
# * <flags> - flags to include in grep command
|
260
261
|
# * [scp] - downloads file to host machine before grepping (functionality not implemented, was planned when a new SSH connection was required for each run() command, not sure it is necessary any longer)
|
261
|
-
def is_in_file?(file, regex, scp=false)
|
262
|
+
def is_in_file?(file, regex, flags='', scp=false)
|
262
263
|
|
263
264
|
res = nil
|
264
265
|
|
@@ -268,7 +269,7 @@ class Rouster
|
|
268
269
|
end
|
269
270
|
|
270
271
|
begin
|
271
|
-
command = sprintf("grep -c '%s' %s", regex, file)
|
272
|
+
command = sprintf("grep -c%s '%s' %s", flags, regex, file)
|
272
273
|
res = self.run(command)
|
273
274
|
rescue Rouster::RemoteExecutionError
|
274
275
|
return false
|
@@ -380,7 +381,7 @@ class Rouster
|
|
380
381
|
os = self.os_type()
|
381
382
|
|
382
383
|
case os
|
383
|
-
when :
|
384
|
+
when :rhel, :osx, :ubuntu, :debian
|
384
385
|
res = self.run(sprintf('ps ax | grep -c %s', name))
|
385
386
|
else
|
386
387
|
raise InternalError.new(sprintf('currently unable to determine running process list on OS[%s]', os))
|
@@ -51,7 +51,7 @@ class TestDeltasGetGroups < Test::Unit::TestCase
|
|
51
51
|
new_group = sprintf('rouster-%s', Time.now.to_i)
|
52
52
|
|
53
53
|
## create a group here
|
54
|
-
if @app.os_type.eql?(:
|
54
|
+
if @app.os_type.eql?(:rhel)
|
55
55
|
@app.run(sprintf('groupadd %s', new_group))
|
56
56
|
else
|
57
57
|
omit('only doing group creation on RHEL hosts')
|
@@ -11,7 +11,7 @@ class TestValidateFileFunctional < Test::Unit::TestCase
|
|
11
11
|
FLAG_FILES = {
|
12
12
|
:ubuntu => '/etc/os-release', # debian too
|
13
13
|
:solaris => '/etc/release',
|
14
|
-
:
|
14
|
+
:rhel => '/etc/redhat-release', # centos too
|
15
15
|
:osx => '/System/Library/CoreServices/SystemVersion.plist',
|
16
16
|
}
|
17
17
|
|
@@ -66,7 +66,7 @@ class TestDeltasGetPackages < Test::Unit::TestCase
|
|
66
66
|
end
|
67
67
|
|
68
68
|
# RHEL processing doesn't do anything different in deep/not-deep calls
|
69
|
-
if ! (@app.os_type.eql?(:
|
69
|
+
if ! (@app.os_type.eql?(:rhel) or @app.os_type.eql?(:ubuntu))
|
70
70
|
res.each_key do |k|
|
71
71
|
assert_not_nil(res[k])
|
72
72
|
assert_match(/\?/, res[k][:arch])
|
@@ -101,7 +101,7 @@ class TestDeltasGetPackages < Test::Unit::TestCase
|
|
101
101
|
def test_arch_determination
|
102
102
|
after, install = nil, nil
|
103
103
|
|
104
|
-
if @app.os_type.eql?(:
|
104
|
+
if @app.os_type.eql?(:rhel)
|
105
105
|
packages = [ 'glibc.x86_64', 'glibc.i686' ]
|
106
106
|
install = @app.run(sprintf('yum install -y %s', packages.join(' '))) # TODO these are already in the base, but just to be safe
|
107
107
|
after = @app.get_packages(false, false)
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require sprintf('%s/../../path_helper', File.dirname(File.expand_path(__FILE__)))
|
2
|
+
|
3
|
+
require 'rouster'
|
4
|
+
require 'rouster/tests'
|
5
|
+
require 'test/unit'
|
6
|
+
|
7
|
+
class TestIsInFile < Test::Unit::TestCase
|
8
|
+
|
9
|
+
SHIBBOLETH = 'foobar'
|
10
|
+
|
11
|
+
def setup
|
12
|
+
assert_nothing_raised do
|
13
|
+
# no reason not to do this as a passthrough once we can
|
14
|
+
@app = Rouster.new(:name => 'app', :sudo => false)
|
15
|
+
@app.up()
|
16
|
+
end
|
17
|
+
|
18
|
+
# create some temporary files
|
19
|
+
@dir_tmp = sprintf('/tmp/rouster-%s.%s', $$, Time.now.to_i)
|
20
|
+
@app.run(sprintf('mkdir %s', @dir_tmp))
|
21
|
+
|
22
|
+
@file = sprintf('%s/file', @dir_tmp)
|
23
|
+
@app.run(sprintf('echo "%s" >> %s', SHIBBOLETH, @file))
|
24
|
+
end
|
25
|
+
|
26
|
+
def teardown; end
|
27
|
+
|
28
|
+
def test_positive
|
29
|
+
|
30
|
+
assert_equal(true, @app.is_in_file?(@file, SHIBBOLETH))
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_negative
|
35
|
+
|
36
|
+
assert_equal(false, @app.is_in_file?(@file, 'fizzbuzz'))
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -17,7 +17,7 @@ class TestUnitGetPackages < Test::Unit::TestCase
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def test_rhel_systemv
|
20
|
-
@app.instance_variable_set(:@ostype, :
|
20
|
+
@app.instance_variable_set(:@ostype, :rhel)
|
21
21
|
services = {}
|
22
22
|
|
23
23
|
raw = File.read(sprintf('%s/../../../test/unit/testing/resources/rhel-systemv', File.dirname(File.expand_path(__FILE__))))
|
@@ -43,7 +43,7 @@ class TestUnitGetPackages < Test::Unit::TestCase
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def test_rhel_upstart
|
46
|
-
@app.instance_variable_set(:@ostype, :
|
46
|
+
@app.instance_variable_set(:@ostype, :rhel)
|
47
47
|
services = {}
|
48
48
|
|
49
49
|
raw = File.read(sprintf('%s/../../../test/unit/testing/resources/rhel-upstart', File.dirname(File.expand_path(__FILE__))))
|
@@ -66,7 +66,7 @@ class TestUnitGetPackages < Test::Unit::TestCase
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def test_rhel_both
|
69
|
-
@app.instance_variable_set(:@ostype, :
|
69
|
+
@app.instance_variable_set(:@ostype, :rhel)
|
70
70
|
services = {}
|
71
71
|
|
72
72
|
systemv_contents = File.read(sprintf('%s/../../../test/unit/testing/resources/rhel-systemv', File.dirname(File.expand_path(__FILE__))))
|
@@ -95,7 +95,7 @@ class TestUnitGetPackages < Test::Unit::TestCase
|
|
95
95
|
end
|
96
96
|
|
97
97
|
def test_rhel_both_real
|
98
|
-
@app.instance_variable_set(:@ostype, :
|
98
|
+
@app.instance_variable_set(:@ostype, :rhel)
|
99
99
|
services = {}
|
100
100
|
|
101
101
|
systemv_contents = File.read(sprintf('%s/../../../test/unit/testing/resources/rhel-systemv', File.dirname(File.expand_path(__FILE__))))
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rouster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.64'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Conor Horan-Kates
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -155,6 +155,7 @@ files:
|
|
155
155
|
- test/functional/test_inspect.rb
|
156
156
|
- test/functional/test_is_dir.rb
|
157
157
|
- test/functional/test_is_file.rb
|
158
|
+
- test/functional/test_is_in_file.rb
|
158
159
|
- test/functional/test_new.rb
|
159
160
|
- test/functional/test_passthroughs.rb
|
160
161
|
- test/functional/test_put.rb
|