specinfra 2.0.0.beta3 → 2.0.0.beta4
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 +4 -4
- data/lib/specinfra/backend/exec.rb +5 -1
- data/lib/specinfra/backend/ssh.rb +10 -1
- data/lib/specinfra/command.rb +1 -0
- data/lib/specinfra/command/base.rb +4 -0
- data/lib/specinfra/command/opensuse.rb +14 -0
- data/lib/specinfra/command/ubuntu.rb +14 -0
- data/lib/specinfra/configuration.rb +1 -0
- data/lib/specinfra/helper.rb +3 -0
- data/lib/specinfra/helper/os.rb +1 -0
- data/lib/specinfra/helper/set.rb +5 -0
- data/lib/specinfra/version.rb +1 -1
- data/spec/backend/ssh/build_command_spec.rb +10 -5
- data/spec/helper/backend_spec.rb +6 -0
- data/spec/helper/set_spec.rb +14 -0
- data/specinfra.gemspec +2 -0
- metadata +20 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9e3df085341c6a98609ce2cbeec6286def53483
|
4
|
+
data.tar.gz: 1d63bd9b0f96b59f4722625d023b07d737c5e6e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a30812a5492202d26e6b0dfa88dd263a66c5ed70c051b100a03acdf408491cdf695c39195fa299b76a2dec455756b58fb5ea4237d0f5ba7e4fde2e088ed8e9a0
|
7
|
+
data.tar.gz: 2884c197f8e70a841d8f7f65bf5b929b745b3d8e3253a9ed3241cad4ba4e819d41838e4d9509bda6506a14aaf85bf120fccadb33cea960d8f42cc34a97500ce7
|
@@ -211,8 +211,12 @@ module Specinfra
|
|
211
211
|
line = run_command('cat /etc/SuSE-release').stdout
|
212
212
|
if line =~ /SUSE Linux Enterprise Server (\d+)/
|
213
213
|
release = $1
|
214
|
+
family = 'SuSE'
|
215
|
+
elsif line =~ /openSUSE (\d+\.\d+|\d+)/
|
216
|
+
release = $1
|
217
|
+
family = 'OpenSUSE'
|
214
218
|
end
|
215
|
-
{ :family =>
|
219
|
+
{ :family => family, :release => release, :arch => arch }
|
216
220
|
elsif run_command('ls /etc/debian_version').success?
|
217
221
|
lsb_release = run_command("lsb_release -ir")
|
218
222
|
if lsb_release.success?
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'specinfra/backend/exec'
|
2
|
+
require 'net/ssh'
|
2
3
|
|
3
4
|
module Specinfra
|
4
5
|
module Backend
|
@@ -20,7 +21,7 @@ module Specinfra
|
|
20
21
|
|
21
22
|
def build_command(cmd)
|
22
23
|
cmd = super(cmd)
|
23
|
-
user = Specinfra.configuration.
|
24
|
+
user = Specinfra.configuration.ssh_options[:user]
|
24
25
|
disable_sudo = Specinfra.configuration.disable_sudo
|
25
26
|
if user != 'root' && !disable_sudo
|
26
27
|
cmd = "#{sudo} #{cmd}"
|
@@ -46,6 +47,14 @@ module Specinfra
|
|
46
47
|
exit_signal = nil
|
47
48
|
pass_prompt = Specinfra.configuration.pass_prompt || /^\[sudo\] password for/
|
48
49
|
|
50
|
+
if Specinfra.configuration.ssh.nil?
|
51
|
+
Specinfra.configuration.ssh = Net::SSH.start(
|
52
|
+
Specinfra.configuration.host,
|
53
|
+
Specinfra.configuration.ssh_options[:user],
|
54
|
+
Specinfra.configuration.ssh_options
|
55
|
+
)
|
56
|
+
end
|
57
|
+
|
49
58
|
ssh = Specinfra.configuration.ssh
|
50
59
|
ssh.open_channel do |channel|
|
51
60
|
if Specinfra.configuration.sudo_password or Specinfra.configuration.request_pty
|
data/lib/specinfra/command.rb
CHANGED
@@ -121,6 +121,10 @@ module Specinfra
|
|
121
121
|
"ps aux | grep -w -- #{escape(process)} | grep -qv grep"
|
122
122
|
end
|
123
123
|
|
124
|
+
def check_process_count(process,count)
|
125
|
+
"test $(ps aux | grep -w -- #{escape(process)} | grep -v grep | wc -l) -eq #{escape(count)}"
|
126
|
+
end
|
127
|
+
|
124
128
|
def get_process(process, opts)
|
125
129
|
"ps -C #{escape(process)} -o #{opts[:format]} | head -1"
|
126
130
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Specinfra
|
2
|
+
module Command
|
3
|
+
class OpenSUSE < SuSE
|
4
|
+
def check_enabled(service, level=nil)
|
5
|
+
"systemctl is-enabled #{escape(service)}.service"
|
6
|
+
end
|
7
|
+
|
8
|
+
def check_running(service)
|
9
|
+
"systemctl is-active #{escape(service)}.service"
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -4,6 +4,20 @@ module Specinfra
|
|
4
4
|
def check_running(service)
|
5
5
|
"service #{escape(service)} status && service #{escape(service)} status | grep 'running'"
|
6
6
|
end
|
7
|
+
|
8
|
+
def check_ppa(package)
|
9
|
+
%Q{find /etc/apt/ -name \*.list | xargs grep -o "deb http://ppa.launchpad.net/#{to_apt_line_uri(package)}"}
|
10
|
+
end
|
11
|
+
|
12
|
+
def check_ppa_enabled(package)
|
13
|
+
%Q{find /etc/apt/ -name \*.list | xargs grep -o "^deb http://ppa.launchpad.net/#{to_apt_line_uri(package)}"}
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def to_apt_line_uri(repo)
|
19
|
+
escape(repo.gsub(/^ppa:/,''))
|
20
|
+
end
|
7
21
|
end
|
8
22
|
end
|
9
23
|
end
|
data/lib/specinfra/helper.rb
CHANGED
data/lib/specinfra/helper/os.rb
CHANGED
data/lib/specinfra/version.rb
CHANGED
@@ -7,7 +7,8 @@ describe Specinfra::Backend::Ssh do
|
|
7
7
|
context 'with root user' do
|
8
8
|
before do
|
9
9
|
RSpec.configure do |c|
|
10
|
-
|
10
|
+
set :ssh_options, :user => 'root'
|
11
|
+
c.ssh = double(:ssh, Specinfra.configuration.ssh_options)
|
11
12
|
end
|
12
13
|
end
|
13
14
|
|
@@ -23,7 +24,8 @@ describe Specinfra::Backend::Ssh do
|
|
23
24
|
context 'with non-root user' do
|
24
25
|
before do
|
25
26
|
RSpec.configure do |c|
|
26
|
-
|
27
|
+
set :ssh_options, :user => 'foo'
|
28
|
+
c.ssh = double(:ssh, Specinfra.configuration.ssh_options)
|
27
29
|
end
|
28
30
|
end
|
29
31
|
|
@@ -39,7 +41,8 @@ describe Specinfra::Backend::Ssh do
|
|
39
41
|
context 'with custom sudo path' do
|
40
42
|
before do
|
41
43
|
RSpec.configure do |c|
|
42
|
-
|
44
|
+
set :ssh_options, :user => 'foo'
|
45
|
+
c.ssh = double(:ssh, Specinfra.configuration.ssh_options)
|
43
46
|
c.sudo_path = '/usr/local/bin'
|
44
47
|
end
|
45
48
|
end
|
@@ -62,7 +65,8 @@ describe Specinfra::Backend::Ssh do
|
|
62
65
|
context 'without sudo' do
|
63
66
|
before do
|
64
67
|
RSpec.configure do |c|
|
65
|
-
|
68
|
+
set :ssh_options, :user => 'foo'
|
69
|
+
c.ssh = double(:ssh, Specinfra.configuration.ssh_options)
|
66
70
|
c.disable_sudo = true
|
67
71
|
end
|
68
72
|
end
|
@@ -87,7 +91,8 @@ describe Specinfra::Backend::Ssh do
|
|
87
91
|
context 'with sudo on alternative path' do
|
88
92
|
before do
|
89
93
|
RSpec.configure do |c|
|
90
|
-
|
94
|
+
set :ssh_options, :user => 'foo'
|
95
|
+
c.ssh = double(:ssh, Specinfra.configuration.ssh_options)
|
91
96
|
c.sudo_options = ['-p', '[sudo] password for']
|
92
97
|
c.sudo_path = nil
|
93
98
|
end
|
data/spec/helper/backend_spec.rb
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'backend_for(:type) returns correct backend object' do
|
4
|
+
before do
|
5
|
+
RSpec.configure do |c|
|
6
|
+
c.ssh = double(:ssh, :options => { :user => 'root' })
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
4
10
|
it 'backend_for(:exec) returns Specinfra::Backend::Exec' do
|
5
11
|
expect(backend_for(:exec)).to be_an_instance_of Specinfra::Backend::Exec
|
6
12
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'set method set value to Specinfra.configuration' do
|
4
|
+
it 'set method handle string value correctly' do
|
5
|
+
set :host, 'localhost'
|
6
|
+
expect(Specinfra.configuration.host).to eq 'localhost'
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'set method handle hash value correctly' do
|
10
|
+
set :ssh_options, :password => 'password', :port => 2222
|
11
|
+
ssh_options = { :password => 'password', :port => 2222 }
|
12
|
+
expect(Specinfra.configuration.ssh_options).to eq ssh_options
|
13
|
+
end
|
14
|
+
end
|
data/specinfra.gemspec
CHANGED
@@ -18,6 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
+
spec.add_runtime_dependency "net-ssh"
|
22
|
+
|
21
23
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
24
|
spec.add_development_dependency "rake", "~> 10.1.1"
|
23
25
|
spec.add_development_dependency "rspec"
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
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.beta4
|
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-
|
11
|
+
date: 2014-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: net-ssh
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -132,6 +146,7 @@ files:
|
|
132
146
|
- lib/specinfra/command/gentoo.rb
|
133
147
|
- lib/specinfra/command/linux.rb
|
134
148
|
- lib/specinfra/command/openbsd.rb
|
149
|
+
- lib/specinfra/command/opensuse.rb
|
135
150
|
- lib/specinfra/command/plamo.rb
|
136
151
|
- lib/specinfra/command/redhat.rb
|
137
152
|
- lib/specinfra/command/redhat7.rb
|
@@ -152,6 +167,7 @@ files:
|
|
152
167
|
- lib/specinfra/helper/lxc.rb
|
153
168
|
- lib/specinfra/helper/os.rb
|
154
169
|
- lib/specinfra/helper/properties.rb
|
170
|
+
- lib/specinfra/helper/set.rb
|
155
171
|
- lib/specinfra/properties.rb
|
156
172
|
- lib/specinfra/runner.rb
|
157
173
|
- lib/specinfra/version.rb
|
@@ -160,6 +176,7 @@ files:
|
|
160
176
|
- spec/configuration_spec.rb
|
161
177
|
- spec/helper/backend_spec.rb
|
162
178
|
- spec/helper/properties_spec.rb
|
179
|
+
- spec/helper/set_spec.rb
|
163
180
|
- spec/spec_helper.rb
|
164
181
|
- specinfra.gemspec
|
165
182
|
- wercker.yml
|
@@ -193,4 +210,5 @@ test_files:
|
|
193
210
|
- spec/configuration_spec.rb
|
194
211
|
- spec/helper/backend_spec.rb
|
195
212
|
- spec/helper/properties_spec.rb
|
213
|
+
- spec/helper/set_spec.rb
|
196
214
|
- spec/spec_helper.rb
|