specinfra 2.0.0.beta2 → 2.0.0.beta3
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.rb +7 -6
- data/lib/specinfra/backend/exec.rb +35 -21
- data/lib/specinfra/backend/powershell/support/find_scheduled_task.ps1 +7 -0
- data/lib/specinfra/command.rb +2 -0
- data/lib/specinfra/command/fedora.rb +29 -0
- data/lib/specinfra/command/redhat7.rb +9 -0
- data/lib/specinfra/command/windows.rb +7 -0
- data/lib/specinfra/configuration.rb +9 -0
- data/lib/specinfra/helper/detect_os.rb +8 -4
- data/lib/specinfra/helper/os.rb +2 -0
- data/lib/specinfra/runner.rb +8 -0
- data/lib/specinfra/version.rb +1 -1
- data/spec/backend/exec/build_command_spec.rb +30 -25
- data/spec/configuration_spec.rb +5 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6f99779115167f0d7345a3ba9261f32f01754b5
|
4
|
+
data.tar.gz: f9643ec0810fddd98b30816509711d7d6b64db09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb6aee27e06d5116f93650bec947195de18b01abc9d2be7eeabf4491827549e166e568cb2261187f15bc24001b6f56eee31cbb3332f455504c096e63c0a2a8fb
|
7
|
+
data.tar.gz: 9c80d72827ac059467fcd71b34d562fb3232220a40cd5c204c9f9a7d5cbcb04761d1dc9cade8dc79deb8d1e56b43fc3333d966ba3cb7055622ed703b14eb4cc4
|
data/lib/specinfra.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
1
|
+
require 'specinfra/version'
|
2
|
+
require 'specinfra/helper'
|
3
|
+
require 'specinfra/backend'
|
4
|
+
require 'specinfra/command'
|
5
|
+
require 'specinfra/command_result'
|
6
|
+
require 'specinfra/configuration'
|
7
|
+
require 'specinfra/runner'
|
7
8
|
|
8
9
|
include Specinfra
|
9
10
|
|
@@ -185,20 +185,34 @@ module Specinfra
|
|
185
185
|
|
186
186
|
def check_os
|
187
187
|
return Specinfra.configuration.os if Specinfra.configuration.os
|
188
|
-
|
188
|
+
arch = run_command('uname -m').stdout.strip
|
189
|
+
# Fedora also has an /etc/redhat-release so the Fedora check must
|
190
|
+
# come before the RedHat check
|
191
|
+
if run_command('ls /etc/fedora-release').success?
|
192
|
+
line = run_command('cat /etc/redhat-release').stdout
|
193
|
+
if line =~ /release (\d[\d]*)/
|
194
|
+
release = $1
|
195
|
+
end
|
196
|
+
{ :family => 'Fedora', :release => release }
|
197
|
+
elsif run_command('ls /etc/redhat-release').success?
|
189
198
|
line = run_command('cat /etc/redhat-release').stdout
|
190
199
|
if line =~ /release (\d[\d.]*)/
|
191
200
|
release = $1
|
192
201
|
end
|
193
|
-
|
202
|
+
|
203
|
+
if release =~ /7./
|
204
|
+
{ :family => 'RedHat7', :release => release, :arch => arch }
|
205
|
+
else
|
206
|
+
{ :family => 'RedHat', :release => release, :arch => arch }
|
207
|
+
end
|
194
208
|
elsif run_command('ls /etc/system-release').success?
|
195
|
-
{ :family => 'RedHat', :release => nil } # Amazon Linux
|
209
|
+
{ :family => 'RedHat', :release => nil, :arch => arch } # Amazon Linux
|
196
210
|
elsif run_command('ls /etc/SuSE-release').success?
|
197
211
|
line = run_command('cat /etc/SuSE-release').stdout
|
198
212
|
if line =~ /SUSE Linux Enterprise Server (\d+)/
|
199
213
|
release = $1
|
200
214
|
end
|
201
|
-
{ :family => 'SuSE', :release => release }
|
215
|
+
{ :family => 'SuSE', :release => release, :arch => arch }
|
202
216
|
elsif run_command('ls /etc/debian_version').success?
|
203
217
|
lsb_release = run_command("lsb_release -ir")
|
204
218
|
if lsb_release.success?
|
@@ -217,37 +231,37 @@ module Specinfra
|
|
217
231
|
end
|
218
232
|
distro ||= 'Debian'
|
219
233
|
release ||= nil
|
220
|
-
{ :family => distro.strip, :release => release }
|
234
|
+
{ :family => distro.strip, :release => release, :arch => arch }
|
221
235
|
elsif run_command('ls /etc/gentoo-release').success?
|
222
|
-
{ :family => 'Gentoo', :release => nil }
|
236
|
+
{ :family => 'Gentoo', :release => nil, :arch => arch }
|
223
237
|
elsif run_command('ls /usr/lib/setup/Plamo-*').success?
|
224
|
-
{ :family => 'Plamo', :release => nil }
|
238
|
+
{ :family => 'Plamo', :release => nil, :arch => arch }
|
225
239
|
elsif run_command('uname -s').stdout =~ /AIX/i
|
226
|
-
{ :family => 'AIX', :release => nil }
|
227
|
-
elsif (
|
228
|
-
if
|
229
|
-
{ :family => 'Solaris10', :release => nil }
|
240
|
+
{ :family => 'AIX', :release => nil, :arch => arch }
|
241
|
+
elsif ( uname = run_command('uname -sr').stdout) && uname =~ /SunOS/i
|
242
|
+
if uname =~ /5.10/
|
243
|
+
{ :family => 'Solaris10', :release => nil, :arch => arch }
|
230
244
|
elsif run_command('grep -q "Oracle Solaris 11" /etc/release').success?
|
231
|
-
{ :family => 'Solaris11', :release => nil }
|
245
|
+
{ :family => 'Solaris11', :release => nil, :arch => arch }
|
232
246
|
elsif run_command('grep -q SmartOS /etc/release').success?
|
233
|
-
{ :family => 'SmartOS', :release => nil }
|
247
|
+
{ :family => 'SmartOS', :release => nil, :arch => arch }
|
234
248
|
else
|
235
|
-
{ :family => 'Solaris', :release => nil }
|
249
|
+
{ :family => 'Solaris', :release => nil, :arch => arch }
|
236
250
|
end
|
237
251
|
elsif run_command('uname -s').stdout =~ /Darwin/i
|
238
252
|
{ :family => 'Darwin', :release => nil }
|
239
|
-
elsif (
|
240
|
-
if
|
241
|
-
{ :family => 'FreeBSD10', :release => nil }
|
253
|
+
elsif ( uname = run_command('uname -sr').stdout ) && uname =~ /FreeBSD/i
|
254
|
+
if uname =~ /10./
|
255
|
+
{ :family => 'FreeBSD10', :release => nil, :arch => arch }
|
242
256
|
else
|
243
|
-
{ :family => 'FreeBSD', :release => nil }
|
257
|
+
{ :family => 'FreeBSD', :release => nil, :arch => arch }
|
244
258
|
end
|
245
259
|
elsif run_command('uname -sr').stdout =~ /Arch/i
|
246
|
-
{ :family => 'Arch', :release => nil }
|
260
|
+
{ :family => 'Arch', :release => nil, :arch => arch }
|
247
261
|
elsif run_command('uname -s').stdout =~ /OpenBSD/i
|
248
|
-
{ :family => 'OpenBSD', :release => nil }
|
262
|
+
{ :family => 'OpenBSD', :release => nil, :arch => arch }
|
249
263
|
else
|
250
|
-
{ :family => 'Base', :release => nil }
|
264
|
+
{ :family => 'Base', :release => nil, :arch => arch }
|
251
265
|
end
|
252
266
|
end
|
253
267
|
|
data/lib/specinfra/command.rb
CHANGED
@@ -8,7 +8,9 @@ require "specinfra/command/ubuntu"
|
|
8
8
|
require "specinfra/command/gentoo"
|
9
9
|
require "specinfra/command/plamo"
|
10
10
|
require "specinfra/command/redhat"
|
11
|
+
require "specinfra/command/redhat7"
|
11
12
|
require "specinfra/command/suse"
|
13
|
+
require "specinfra/command/fedora"
|
12
14
|
|
13
15
|
# Solaris
|
14
16
|
require "specinfra/command/solaris"
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Specinfra
|
2
|
+
module Command
|
3
|
+
class Fedora < RedHat
|
4
|
+
def check_enabled(service, target="multi-user.target")
|
5
|
+
host = Specinfra.configuration.ssh ? Specinfra.configuration.ssh.host : 'localhost'
|
6
|
+
if property.has_key?(:os_by_host) && property[:os_by_host][host][:release].to_i < 15
|
7
|
+
super
|
8
|
+
else
|
9
|
+
# Fedora 15+ uses systemd which no longer has runlevels but targets
|
10
|
+
# For backwards compatibility, Fedora provides pseudo targets for
|
11
|
+
# runlevels
|
12
|
+
if target.is_a? Integer
|
13
|
+
target = "runlevel#{target}.target"
|
14
|
+
end
|
15
|
+
"systemctl --plain list-dependencies #{target} | grep '^#{escape(service)}.service$'"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def check_running(service)
|
20
|
+
host = Specinfra.configuration.ssh ? Specinfra.configuration.ssh.host : 'localhost'
|
21
|
+
if property.has_key?(:os_by_host) && property[:os_by_host][host][:release].to_i < 15
|
22
|
+
super
|
23
|
+
else
|
24
|
+
"systemctl is-active #{escape(service)}.service"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -305,6 +305,13 @@ module Specinfra
|
|
305
305
|
end
|
306
306
|
end
|
307
307
|
|
308
|
+
def check_scheduled_task(name)
|
309
|
+
Backend::PowerShell::Command.new do
|
310
|
+
using 'find_scheduled_task.ps1'
|
311
|
+
exec "(FindScheduledTask -name '#{name}').TaskName -eq '\\#{name}'"
|
312
|
+
end
|
313
|
+
end
|
314
|
+
|
308
315
|
private
|
309
316
|
|
310
317
|
def item_has_attribute item, attribute
|
@@ -20,6 +20,15 @@ module Specinfra
|
|
20
20
|
VALID_OPTIONS_KEYS.inject({}) { |o, k| o.merge!(k => send(k)) }
|
21
21
|
end
|
22
22
|
|
23
|
+
# Define os method explicitly to avoid stack level
|
24
|
+
# too deep caused by Helpet::DetectOS#os
|
25
|
+
def os
|
26
|
+
if @os.nil? && defined?(RSpec) && RSpec.configuration.respond_to?(:os)
|
27
|
+
@os = RSpec.configuration.os
|
28
|
+
end
|
29
|
+
@os
|
30
|
+
end
|
31
|
+
|
23
32
|
def method_missing(meth, val=nil)
|
24
33
|
key = meth.to_s
|
25
34
|
key.gsub!(/=$/, '')
|
@@ -2,17 +2,21 @@ module Specinfra
|
|
2
2
|
module Helper
|
3
3
|
module DetectOS
|
4
4
|
def commands
|
5
|
+
self.class.const_get('Specinfra').const_get('Command').const_get(os[:family]).new
|
6
|
+
end
|
7
|
+
|
8
|
+
def os
|
5
9
|
property[:os_by_host] = {} if ! property[:os_by_host]
|
6
10
|
host = Specinfra.configuration.ssh ? Specinfra.configuration.ssh.host : 'localhost'
|
7
11
|
|
8
12
|
if property[:os_by_host][host]
|
9
|
-
|
13
|
+
os_by_host = property[:os_by_host][host]
|
10
14
|
else
|
11
15
|
# Set command object explicitly to avoid `stack too deep`
|
12
|
-
|
13
|
-
property[:os_by_host][host] =
|
16
|
+
os_by_host = backend(Specinfra::Command::Base.new).check_os
|
17
|
+
property[:os_by_host][host] = os_by_host
|
14
18
|
end
|
15
|
-
|
19
|
+
os_by_host
|
16
20
|
end
|
17
21
|
end
|
18
22
|
end
|
data/lib/specinfra/helper/os.rb
CHANGED
data/lib/specinfra/version.rb
CHANGED
@@ -78,56 +78,61 @@ describe 'check_os' do
|
|
78
78
|
context 'test ubuntu with lsb_release command' do
|
79
79
|
subject { backend.check_os }
|
80
80
|
it do
|
81
|
-
mock_success_response = double(
|
82
|
-
:run_command_response,
|
83
|
-
:success? => true,
|
84
|
-
:stdout => "Distributor ID:\tUbuntu\nRelease:\t12.04\n"
|
85
|
-
)
|
86
|
-
mock_failure_response = double :run_command_response, :success? => false
|
87
81
|
backend.should_receive(:run_command).at_least(1).times do |args|
|
88
82
|
if ['ls /etc/debian_version', 'lsb_release -ir'].include? args
|
89
|
-
|
83
|
+
double(
|
84
|
+
:run_command_response,
|
85
|
+
:success? => true,
|
86
|
+
:stdout => "Distributor ID:\tUbuntu\nRelease:\t12.04\n"
|
87
|
+
)
|
88
|
+
elsif args == 'uname -m'
|
89
|
+
double :run_command_response, :success? => true, :stdout => "x86_64\n"
|
90
90
|
else
|
91
|
-
|
91
|
+
double :run_command_response, :success? => false
|
92
92
|
end
|
93
93
|
end
|
94
|
-
should eq({:family => 'Ubuntu', :release => '12.04'})
|
94
|
+
should eq({:family => 'Ubuntu', :release => '12.04', :arch => 'x86_64' })
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
98
|
context 'test ubuntu with /etc/lsb-release' do
|
99
99
|
subject { backend.check_os }
|
100
100
|
it do
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
101
|
+
backend.should_receive(:run_command).at_least(1).times do |args|
|
102
|
+
if ['ls /etc/debian_version', 'cat /etc/lsb-release'].include? args
|
103
|
+
double(
|
104
|
+
:run_command_response,
|
105
|
+
:success? => true,
|
106
|
+
:stdout => <<-EOF
|
107
|
+
DISTRIB_ID=Ubuntu
|
105
108
|
DISTRIB_RELEASE=12.04
|
106
109
|
DISTRIB_CODENAME=precise
|
107
110
|
DISTRIB_DESCRIPTION="Ubuntu 12.04.2 LTS"
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
if ['ls /etc/debian_version', 'cat /etc/lsb-release'].include? args
|
113
|
-
mock_success_response
|
111
|
+
EOF
|
112
|
+
)
|
113
|
+
elsif args == 'uname -m'
|
114
|
+
double :run_command_response, :success? => true, :stdout => "x86_64\n"
|
114
115
|
else
|
115
|
-
|
116
|
+
double :run_command_response, :success? => false
|
116
117
|
end
|
117
118
|
end
|
118
|
-
should eq({:family => 'Ubuntu', :release => '12.04'})
|
119
|
+
should eq({:family => 'Ubuntu', :release => '12.04', :arch => 'x86_64' })
|
119
120
|
end
|
120
121
|
end
|
121
122
|
|
122
123
|
context 'test debian (no lsb_release or lsb-release)' do
|
123
124
|
subject { backend.check_os }
|
124
125
|
it do
|
125
|
-
mock_success_response = double :run_command_response, :success? => true
|
126
|
-
mock_failure_response = double :run_command_response, :success? => false
|
127
126
|
backend.should_receive(:run_command).at_least(1).times do |args|
|
128
|
-
args == 'ls /etc/debian_version'
|
127
|
+
if args == 'ls /etc/debian_version'
|
128
|
+
double :run_command_response, :success? => true
|
129
|
+
elsif args == 'uname -m'
|
130
|
+
double :run_command_response, :success? => true, :stdout => "x86_64\n"
|
131
|
+
else
|
132
|
+
double :run_command_response, :success? => false
|
133
|
+
end
|
129
134
|
end
|
130
|
-
should eq({:family => 'Debian', :release => nil})
|
135
|
+
should eq({:family => 'Debian', :release => nil, :arch => 'x86_64' })
|
131
136
|
end
|
132
137
|
end
|
133
138
|
end
|
data/spec/configuration_spec.rb
CHANGED
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.beta3
|
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-05-
|
11
|
+
date: 2014-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -110,6 +110,7 @@ files:
|
|
110
110
|
- lib/specinfra/backend/powershell/support/find_iis_component.ps1
|
111
111
|
- lib/specinfra/backend/powershell/support/find_installed_application.ps1
|
112
112
|
- lib/specinfra/backend/powershell/support/find_installed_hot_fix.ps1
|
113
|
+
- lib/specinfra/backend/powershell/support/find_scheduled_task.ps1
|
113
114
|
- lib/specinfra/backend/powershell/support/find_service.ps1
|
114
115
|
- lib/specinfra/backend/powershell/support/find_user.ps1
|
115
116
|
- lib/specinfra/backend/powershell/support/find_usergroup.ps1
|
@@ -125,6 +126,7 @@ files:
|
|
125
126
|
- lib/specinfra/command/base.rb
|
126
127
|
- lib/specinfra/command/darwin.rb
|
127
128
|
- lib/specinfra/command/debian.rb
|
129
|
+
- lib/specinfra/command/fedora.rb
|
128
130
|
- lib/specinfra/command/freebsd.rb
|
129
131
|
- lib/specinfra/command/freebsd10.rb
|
130
132
|
- lib/specinfra/command/gentoo.rb
|
@@ -132,6 +134,7 @@ files:
|
|
132
134
|
- lib/specinfra/command/openbsd.rb
|
133
135
|
- lib/specinfra/command/plamo.rb
|
134
136
|
- lib/specinfra/command/redhat.rb
|
137
|
+
- lib/specinfra/command/redhat7.rb
|
135
138
|
- lib/specinfra/command/smartos.rb
|
136
139
|
- lib/specinfra/command/solaris.rb
|
137
140
|
- lib/specinfra/command/solaris10.rb
|
@@ -150,6 +153,7 @@ files:
|
|
150
153
|
- lib/specinfra/helper/os.rb
|
151
154
|
- lib/specinfra/helper/properties.rb
|
152
155
|
- lib/specinfra/properties.rb
|
156
|
+
- lib/specinfra/runner.rb
|
153
157
|
- lib/specinfra/version.rb
|
154
158
|
- spec/backend/exec/build_command_spec.rb
|
155
159
|
- spec/backend/ssh/build_command_spec.rb
|