specinfra 2.0.0.beta4 → 2.0.0.beta5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +23 -18
- data/lib/specinfra/backend/docker.rb +1 -0
- data/lib/specinfra/backend/exec.rb +2 -0
- data/lib/specinfra/backend/lxc.rb +3 -3
- data/lib/specinfra/backend/ssh.rb +6 -3
- data/lib/specinfra/command.rb +1 -0
- data/lib/specinfra/command/arch.rb +1 -1
- data/lib/specinfra/command/base.rb +8 -0
- data/lib/specinfra/command/darwin.rb +13 -0
- data/lib/specinfra/command/nixos.rb +28 -0
- data/lib/specinfra/configuration.rb +1 -1
- data/lib/specinfra/helper/os.rb +1 -0
- data/lib/specinfra/version.rb +1 -1
- data/spec/backend/ssh/build_command_spec.rb +6 -7
- data/specinfra.gemspec +0 -2
- metadata +3 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65e4d83475bbdd34b27754036496fc53ba0a2134
|
4
|
+
data.tar.gz: 46cbd1679ece1082f94dea53e3cb9ed5e54974c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2d221e45cb170df18ffa898388eb7018143e828e6045591bbd63e3f2f931283899192490bcb391d107a35421f0df967cbddfc1eb98dc28bc692339b41388a5f
|
7
|
+
data.tar.gz: 713db6f57e9ff241a5aa23c531e3a51c2c0584114ebd9f0f1d8917b005a21ec0667032c07d7c9b6bbf8248b7568f066a0f35d52febbefbf525eab3bd963c3928
|
data/Rakefile
CHANGED
@@ -1,30 +1,35 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
-
|
3
|
-
require "
|
2
|
+
begin
|
3
|
+
require "rspec/core/rake_task"
|
4
|
+
require "octorelease"
|
5
|
+
rescue LoadError
|
6
|
+
end
|
4
7
|
|
5
|
-
|
8
|
+
if defined?(RSpec)
|
9
|
+
task :spec => 'spec:all'
|
6
10
|
|
7
|
-
namespace :spec do
|
8
|
-
|
11
|
+
namespace :spec do
|
12
|
+
task :all => [ :helper, :backend, :configuration ]
|
9
13
|
|
10
|
-
|
11
|
-
|
12
|
-
|
14
|
+
RSpec::Core::RakeTask.new(:helper) do |t|
|
15
|
+
t.pattern = "spec/helper/*_spec.rb"
|
16
|
+
end
|
13
17
|
|
14
|
-
|
15
|
-
|
16
|
-
|
18
|
+
task :backend => 'backend:all'
|
19
|
+
namespace :backend do
|
20
|
+
backends = %w[exec ssh]
|
17
21
|
|
18
|
-
|
22
|
+
task :all => backends
|
19
23
|
|
20
|
-
|
21
|
-
|
22
|
-
|
24
|
+
backends.each do |backend|
|
25
|
+
RSpec::Core::RakeTask.new(backend) do |t|
|
26
|
+
t.pattern = "spec/backend/#{backend}/*_spec.rb"
|
27
|
+
end
|
23
28
|
end
|
24
29
|
end
|
25
|
-
end
|
26
30
|
|
27
|
-
|
28
|
-
|
31
|
+
RSpec::Core::RakeTask.new(:configuration) do |t|
|
32
|
+
t.pattern = "spec/configuration_spec.rb"
|
33
|
+
end
|
29
34
|
end
|
30
35
|
end
|
@@ -240,6 +240,8 @@ module Specinfra
|
|
240
240
|
{ :family => 'Gentoo', :release => nil, :arch => arch }
|
241
241
|
elsif run_command('ls /usr/lib/setup/Plamo-*').success?
|
242
242
|
{ :family => 'Plamo', :release => nil, :arch => arch }
|
243
|
+
elsif run_command('ls /var/run/current-system/sw').success?
|
244
|
+
{ :family => 'NixOS', :release => nil, :arch => arch }
|
243
245
|
elsif run_command('uname -s').stdout =~ /AIX/i
|
244
246
|
{ :family => 'AIX', :release => nil, :arch => arch }
|
245
247
|
elsif ( uname = run_command('uname -sr').stdout) && uname =~ /SunOS/i
|
@@ -6,9 +6,9 @@ module Specinfra
|
|
6
6
|
cmd = build_command(cmd)
|
7
7
|
cmd = add_pre_command(cmd)
|
8
8
|
out, ret = ct.execute do
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
out = `#{cmd} 2>&1`
|
10
|
+
[out, $?.dup]
|
11
|
+
end
|
12
12
|
if @example
|
13
13
|
@example.metadata[:command] = cmd
|
14
14
|
@example.metadata[:stdout] = out
|
@@ -4,6 +4,10 @@ require 'net/ssh'
|
|
4
4
|
module Specinfra
|
5
5
|
module Backend
|
6
6
|
class Ssh < Exec
|
7
|
+
def prompt
|
8
|
+
'Password: '
|
9
|
+
end
|
10
|
+
|
7
11
|
def run_command(cmd, opt={})
|
8
12
|
cmd = build_command(cmd)
|
9
13
|
cmd = add_pre_command(cmd)
|
@@ -24,7 +28,7 @@ module Specinfra
|
|
24
28
|
user = Specinfra.configuration.ssh_options[:user]
|
25
29
|
disable_sudo = Specinfra.configuration.disable_sudo
|
26
30
|
if user != 'root' && !disable_sudo
|
27
|
-
cmd = "#{sudo} #{cmd}"
|
31
|
+
cmd = "#{sudo} -p '#{prompt}' #{cmd}"
|
28
32
|
end
|
29
33
|
cmd
|
30
34
|
end
|
@@ -45,7 +49,6 @@ module Specinfra
|
|
45
49
|
stderr_data = ''
|
46
50
|
exit_status = nil
|
47
51
|
exit_signal = nil
|
48
|
-
pass_prompt = Specinfra.configuration.pass_prompt || /^\[sudo\] password for/
|
49
52
|
|
50
53
|
if Specinfra.configuration.ssh.nil?
|
51
54
|
Specinfra.configuration.ssh = Net::SSH.start(
|
@@ -65,7 +68,7 @@ module Specinfra
|
|
65
68
|
channel.exec("#{command}") do |ch, success|
|
66
69
|
abort "FAILED: couldn't execute command (ssh.channel.exec)" if !success
|
67
70
|
channel.on_data do |ch, data|
|
68
|
-
if data.match
|
71
|
+
if data.match /^#{prompt}/
|
69
72
|
channel.send_data "#{Specinfra.configuration.sudo_password}\n"
|
70
73
|
else
|
71
74
|
stdout_data += data
|
data/lib/specinfra/command.rb
CHANGED
@@ -59,6 +59,14 @@ module Specinfra
|
|
59
59
|
"test -f #{escape(file)}"
|
60
60
|
end
|
61
61
|
|
62
|
+
def get_file_mtime(file)
|
63
|
+
"stat -c %Y #{escape(file)}"
|
64
|
+
end
|
65
|
+
|
66
|
+
def get_file_size(file)
|
67
|
+
"stat -c %s #{escape(file)}"
|
68
|
+
end
|
69
|
+
|
62
70
|
def check_socket(file)
|
63
71
|
"test -S #{escape(file)}"
|
64
72
|
end
|
@@ -1,6 +1,19 @@
|
|
1
1
|
module Specinfra
|
2
2
|
module Command
|
3
3
|
class Darwin < Base
|
4
|
+
def check_enabled(service, level=nil)
|
5
|
+
"launchctl list | grep #{escape(service)}"
|
6
|
+
end
|
7
|
+
|
8
|
+
def check_running(service)
|
9
|
+
"launchctl list | grep #{escape(service)} | grep -E '^[0-9]+'"
|
10
|
+
end
|
11
|
+
|
12
|
+
def check_listening(port)
|
13
|
+
regexp = ":#{port} "
|
14
|
+
"lsof -nP -iTCP -sTCP:LISTEN | grep -- #{escape(regexp)}"
|
15
|
+
end
|
16
|
+
|
4
17
|
def check_file_md5checksum(file, expected)
|
5
18
|
"openssl md5 #{escape(file)} | cut -d'=' -f2 | cut -c 2- | grep -E ^#{escape(expected)}$"
|
6
19
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Specinfra
|
2
|
+
module Command
|
3
|
+
class NixOS < Linux
|
4
|
+
def check_enabled(service,level=3)
|
5
|
+
level = "multi-user.target" if level == 3
|
6
|
+
"systemctl --plain list-dependencies #{escape(level)} | grep '#{escape(service)}.service$'"
|
7
|
+
end
|
8
|
+
|
9
|
+
def check_installed(package, version=nil)
|
10
|
+
if version
|
11
|
+
"nix-store -q --references /var/run/current-system/sw | grep #{escape(package)}-#{escape(version)}"
|
12
|
+
else
|
13
|
+
"nix-store -q --references /var/run/current-system/sw | grep #{escape(package)}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
alias :check_installed_by_nix :check_installed
|
18
|
+
|
19
|
+
def check_running(service)
|
20
|
+
"systemctl is-active #{escape(service)}.service"
|
21
|
+
end
|
22
|
+
|
23
|
+
def install(package)
|
24
|
+
"nix-env -i #{package}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/specinfra/helper/os.rb
CHANGED
data/lib/specinfra/version.rb
CHANGED
@@ -30,11 +30,11 @@ describe Specinfra::Backend::Ssh do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'should prepend sudo' do
|
33
|
-
expect(backend.build_command('test -f /etc/passwd')).to eq
|
33
|
+
expect(backend.build_command('test -f /etc/passwd')).to eq %q{sudo -p 'Password: ' /bin/sh -c test\ -f\ /etc/passwd}
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'should escape special characters' do
|
37
|
-
expect(backend.build_command('test ! -f /etc/selinux/config || (getenforce | grep -i -- disabled && grep -i -- ^SELINUX=disabled$ /etc/selinux/config)')).to eq
|
37
|
+
expect(backend.build_command('test ! -f /etc/selinux/config || (getenforce | grep -i -- disabled && grep -i -- ^SELINUX=disabled$ /etc/selinux/config)')).to eq %q{sudo -p 'Password: ' /bin/sh -c test\ \!\ -f\ /etc/selinux/config\ \|\|\ \(getenforce\ \|\ grep\ -i\ --\ disabled\ \&\&\ grep\ -i\ --\ \^SELINUX\=disabled\$\ /etc/selinux/config\)}
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -54,11 +54,11 @@ describe Specinfra::Backend::Ssh do
|
|
54
54
|
end
|
55
55
|
|
56
56
|
it 'command pattern 1a' do
|
57
|
-
expect(backend.build_command('test -f /etc/passwd')).to eq
|
57
|
+
expect(backend.build_command('test -f /etc/passwd')).to eq %q{/usr/local/bin/sudo -p 'Password: ' /bin/sh -c test\ -f\ /etc/passwd}
|
58
58
|
end
|
59
59
|
|
60
60
|
it 'command pattern 2a' do
|
61
|
-
expect(backend.build_command('test ! -f /etc/selinux/config || (getenforce | grep -i -- disabled && grep -i -- ^SELINUX=disabled$ /etc/selinux/config)')).to eq
|
61
|
+
expect(backend.build_command('test ! -f /etc/selinux/config || (getenforce | grep -i -- disabled && grep -i -- ^SELINUX=disabled$ /etc/selinux/config)')).to eq %q{/usr/local/bin/sudo -p 'Password: ' /bin/sh -c test\ \!\ -f\ /etc/selinux/config\ \|\|\ \(getenforce\ \|\ grep\ -i\ --\ disabled\ \&\&\ grep\ -i\ --\ \^SELINUX\=disabled\$\ /etc/selinux/config\)}
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
@@ -93,7 +93,6 @@ describe Specinfra::Backend::Ssh do
|
|
93
93
|
RSpec.configure do |c|
|
94
94
|
set :ssh_options, :user => 'foo'
|
95
95
|
c.ssh = double(:ssh, Specinfra.configuration.ssh_options)
|
96
|
-
c.sudo_options = ['-p', '[sudo] password for']
|
97
96
|
c.sudo_path = nil
|
98
97
|
end
|
99
98
|
end
|
@@ -106,12 +105,12 @@ describe Specinfra::Backend::Ssh do
|
|
106
105
|
|
107
106
|
context 'command pattern 1a' do
|
108
107
|
subject { backend.build_command('test -f /etc/passwd') }
|
109
|
-
it { should eq
|
108
|
+
it { should eq %q{sudo -p 'Password: ' /bin/sh -c test\ -f\ /etc/passwd} }
|
110
109
|
end
|
111
110
|
|
112
111
|
context 'command pattern 2a' do
|
113
112
|
subject { backend.build_command('test ! -f /etc/selinux/config || (getenforce | grep -i -- disabled && grep -i -- ^SELINUX=disabled$ /etc/selinux/config)') }
|
114
|
-
it { should eq
|
113
|
+
it { should eq %q{sudo -p 'Password: ' /bin/sh -c test\ \!\ -f\ /etc/selinux/config\ \|\|\ \(getenforce\ \|\ grep\ -i\ --\ disabled\ \&\&\ grep\ -i\ --\ \^SELINUX\=disabled\$\ /etc/selinux/config\)} }
|
115
114
|
end
|
116
115
|
end
|
117
116
|
end
|
data/specinfra.gemspec
CHANGED
@@ -23,6 +23,4 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_development_dependency "bundler", "~> 1.3"
|
24
24
|
spec.add_development_dependency "rake", "~> 10.1.1"
|
25
25
|
spec.add_development_dependency "rspec"
|
26
|
-
spec.add_development_dependency "octokit", "~> 2.7.2"
|
27
|
-
spec.add_development_dependency "octorelease"
|
28
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: specinfra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.
|
4
|
+
version: 2.0.0.beta5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gosuke Miyashita
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-ssh
|
@@ -66,34 +66,6 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: octokit
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: 2.7.2
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: 2.7.2
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: octorelease
|
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
69
|
description: Common layer for serverspec and configspec
|
98
70
|
email:
|
99
71
|
- gosukenator@gmail.com
|
@@ -145,6 +117,7 @@ files:
|
|
145
117
|
- lib/specinfra/command/freebsd10.rb
|
146
118
|
- lib/specinfra/command/gentoo.rb
|
147
119
|
- lib/specinfra/command/linux.rb
|
120
|
+
- lib/specinfra/command/nixos.rb
|
148
121
|
- lib/specinfra/command/openbsd.rb
|
149
122
|
- lib/specinfra/command/opensuse.rb
|
150
123
|
- lib/specinfra/command/plamo.rb
|