specinfra 2.21.1 → 2.22.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4e796a0b83f9bde7cfa6fc07448f33a4515af371
4
- data.tar.gz: 8851a409215866f9ea12b1be34432ad7a055871d
3
+ metadata.gz: 0bfa588a9ff12b8acac2ca45a3d330e9cb458bfa
4
+ data.tar.gz: 011fd091e8a33237f34ba487a6c1cc59526219fa
5
5
  SHA512:
6
- metadata.gz: 6e4b443bb4083979729929b28093e5f8a50d7acf7879ba025b34851935dd2ae1097a0448b80f5a47cb7e209e76ae238737e2032f8b8e6176d057f922190f5634
7
- data.tar.gz: 48ac0a3b80d41cb7d658d68e44d500c81abd55735b28413b30602a538b9c3fe143abec40858b6e678c94ed8ddac198d086039bb3d1b6bf5d7da27af19e803f83
6
+ metadata.gz: 13debcb36c02720cad205eafec9d4290e4bd48b36aedf581f4b011e754699640f31a235f33d8e7423916740dfc13f1a2941eec8c04b4a1ec1e3ad86d0d1be4e5
7
+ data.tar.gz: 2c35a3d831a4d4993aab5fc305d8a756801c839933a4ae75b3945e55766e27057b4f39dade5d3298443939613970853c6663d4710557407981370e4c2f49654e
@@ -0,0 +1,46 @@
1
+ require 'specinfra'
2
+ require 'pp'
3
+
4
+ a = Specinfra::Backend::Exec.new
5
+
6
+ ssh_options = Net::SSH::Config.for(ENV['SSH_HOST'], [ENV['SSH_CONFIG']])
7
+ b = Specinfra::Backend::Ssh.new(
8
+ :host => ssh_options[:host_name],
9
+ :ssh_options => ssh_options,
10
+ )
11
+
12
+ threads = [a, b].map do |backend|
13
+ Thread.start(backend) do |backend|
14
+ result = []
15
+ result << backend.run_command("uname -a")
16
+ result << backend.command
17
+ result << backend.command.get(:install_package, 'dstat')
18
+ result
19
+ end
20
+ end
21
+
22
+ threads.each(&:join)
23
+ threads.each do |t|
24
+ pp t.value
25
+ end
26
+
27
+ # example:
28
+ # [#<Specinfra::CommandResult:0x007fb3b1352e30
29
+ # @exit_signal=nil,
30
+ # @exit_status=0,
31
+ # @stderr="",
32
+ # @stdout=
33
+ # "Darwin p411 14.1.0 Darwin Kernel Version 14.1.0: Thu Feb 26 19:26:47 PST 2015; root:xnu-2782.10.73~1/RELEASE_X86_64 x86_64\n">,
34
+ # #<Specinfra::CommandFactory:0x007fb3b1153508
35
+ # @os_info={:family=>"darwin", :release=>nil, :arch=>"x86_64"}>,
36
+ # "/usr/local/bin/brew install 'dstat'"]
37
+ # [#<Specinfra::CommandResult:0x007fb3b0b9c2e0
38
+ # @exit_signal=nil,
39
+ # @exit_status=0,
40
+ # @stderr="",
41
+ # @stdout=
42
+ # "Linux itamae-trusty 3.13.0-39-generic #66-Ubuntu SMP Tue Oct 28 13:30:27 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux\n">,
43
+ # #<Specinfra::CommandFactory:0x007fb3b0d4d4b8
44
+ # @os_info={:family=>"ubuntu", :release=>"14.04", :arch=>"x86_64"}>,
45
+ # "DEBIAN_FRONTEND='noninteractive' apt-get -y -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' install dstat"]
46
+
data/lib/specinfra.rb CHANGED
@@ -17,7 +17,7 @@ module Specinfra
17
17
  end
18
18
 
19
19
  def command
20
- Specinfra::CommandFactory
20
+ Specinfra::CommandFactory.instance
21
21
  end
22
22
 
23
23
  def backend
@@ -3,7 +3,36 @@ require 'specinfra/command_result'
3
3
 
4
4
  module Specinfra::Backend
5
5
  class Base
6
- include Singleton
6
+ def self.instance
7
+ @instance ||= self.new
8
+ end
9
+
10
+ def initialize(config = {})
11
+ @config = config
12
+ end
13
+
14
+ def get_config(key)
15
+ @config[key] || Specinfra.configuration.send(key)
16
+ end
17
+
18
+ def set_config(key, value)
19
+ @config[key] = value
20
+ end
21
+
22
+ def os_info
23
+ return @os_info if @os_info
24
+
25
+ Specinfra::Helper::DetectOs.subclasses.each do |klass|
26
+ if @os_info = klass.new(self).detect
27
+ @os_info[:arch] ||= self.run_command('uname -m').stdout.strip
28
+ return @os_info
29
+ end
30
+ end
31
+ end
32
+
33
+ def command
34
+ CommandFactory.new(os_info)
35
+ end
7
36
 
8
37
  def set_example(e)
9
38
  @example = e
@@ -6,7 +6,7 @@ module Specinfra
6
6
  include PowerShell::ScriptHelper
7
7
 
8
8
  def run_command(cmd, opts={})
9
- Specinfra.configuration.os = { :family => 'windows' }
9
+ set_config(:os, { :family => 'windows' })
10
10
  script = create_script(cmd)
11
11
  result = execute_script %Q{#{powershell} -encodedCommand #{encode_script(script)}}
12
12
 
@@ -39,7 +39,7 @@ module Specinfra
39
39
  private
40
40
 
41
41
  def powershell
42
- architecture = @example.metadata[:architecture] || Specinfra.configuration.architecture
42
+ architecture = @example.metadata[:architecture] || get_config(:architecture)
43
43
 
44
44
  case architecture
45
45
  when :i386 then x86_powershell
@@ -7,15 +7,15 @@ module Specinfra::Backend
7
7
  fail "Docker client library is not available. Try installing `docker-api' gem."
8
8
  end
9
9
 
10
- ::Docker.url = Specinfra.configuration.docker_url
10
+ ::Docker.url = get_config(:docker_url)
11
11
 
12
- if image = Specinfra.configuration.docker_image
12
+ if image = get_config(:docker_image)
13
13
  @images = []
14
14
  @base_image = get_or_pull_image(image)
15
15
 
16
16
  create_and_start_container
17
17
  ObjectSpace.define_finalizer(self, proc { cleanup_container })
18
- elsif container = Specinfra.configuration.docker_container
18
+ elsif container = get_config(:docker_container)
19
19
  @container = ::Docker::Container.get(container)
20
20
  else
21
21
  fail 'Please specify docker_image or docker_container.'
@@ -61,14 +61,14 @@ module Specinfra::Backend
61
61
 
62
62
  opts.merge!({'OpenStdin' => true})
63
63
 
64
- if path = Specinfra.configuration.path
64
+ if path = get_config(:path)
65
65
  (opts['Env'] ||= []) << "PATH=#{path}"
66
66
  end
67
67
 
68
- env = Specinfra.configuration.env.to_a.map { |v| v.join('=') }
68
+ env = get_config(:env).to_a.map { |v| v.join('=') }
69
69
  opts['Env'] = opts['Env'].to_a.concat(env)
70
70
 
71
- opts.merge!(Specinfra.configuration.docker_container_create_options || {})
71
+ opts.merge!(get_config(:docker_container_create_options) || {})
72
72
 
73
73
  @container = ::Docker::Container.create(opts)
74
74
  @container.start
@@ -4,10 +4,10 @@ module Specinfra::Backend
4
4
  def initialize
5
5
  @lines = []
6
6
  ObjectSpace.define_finalizer(self) {
7
- if Specinfra.configuration.dockerfile_finalizer.nil?
7
+ if get_config(:dockerfile_finalizer).nil?
8
8
  puts @lines
9
9
  else
10
- Specinfra.configuration.dockerfile_finalizer.call(@lines)
10
+ get_config(:dockerfile_finalizer).call(@lines)
11
11
  end
12
12
  }
13
13
  end
@@ -30,11 +30,11 @@ module Specinfra::Backend
30
30
  end
31
31
 
32
32
  def build_command(cmd)
33
- shell = Specinfra.configuration.shell || '/bin/sh'
33
+ shell = get_config(:shell) || '/bin/sh'
34
34
  cmd = cmd.shelljoin if cmd.is_a?(Array)
35
35
  cmd = "#{shell.shellescape} -c #{cmd.to_s.shellescape}"
36
36
 
37
- path = Specinfra.configuration.path
37
+ path = get_config(:path)
38
38
  if path
39
39
  cmd = %Q{env PATH="#{path}" #{cmd}}
40
40
  end
@@ -49,7 +49,7 @@ module Specinfra::Backend
49
49
 
50
50
  keys.each { |key| ENV["_SPECINFRA_#{key}"] = ENV[key] ; ENV.delete(key) }
51
51
 
52
- env = Specinfra.configuration.env || {}
52
+ env = get_config(:env) || {}
53
53
  env[:LANG] ||= 'C'
54
54
 
55
55
  env.each do |key, value|
@@ -68,8 +68,8 @@ module Specinfra::Backend
68
68
  end
69
69
 
70
70
  def add_pre_command(cmd)
71
- if Specinfra.configuration.pre_command
72
- pre_cmd = build_command(Specinfra.configuration.pre_command)
71
+ if get_config(:pre_command)
72
+ pre_cmd = build_command(get_config(:pre_command))
73
73
  "#{pre_cmd} && #{cmd}"
74
74
  else
75
75
  cmd
@@ -35,7 +35,7 @@ module Specinfra::Backend
35
35
  end
36
36
 
37
37
  def ct
38
- @ct ||= ::LXC::Container.new(Specinfra.configuration.lxc)
38
+ @ct ||= ::LXC::Container.new(get_config(:lxc))
39
39
  end
40
40
  end
41
41
  end
@@ -5,7 +5,7 @@ module Specinfra
5
5
  module PowerShell
6
6
  module ScriptHelper
7
7
  def build_command(cmd)
8
- path = Specinfra.configuration.path
8
+ path = get_config(:path)
9
9
  if path
10
10
  cmd.strip!
11
11
  cmd =
@@ -18,12 +18,12 @@ EOF
18
18
  end
19
19
 
20
20
  def add_pre_command(cmd)
21
- path = Specinfra.configuration.path
22
- if Specinfra.configuration.pre_command
21
+ path = get_config(:path)
22
+ if get_config(:pre_command)
23
23
  cmd.strip!
24
24
  cmd =
25
25
  <<-EOF
26
- if (#{Specinfra.configuration.pre_command})
26
+ if (#{get_config(:pre_command)})
27
27
  {
28
28
  #{cmd}
29
29
  }
@@ -45,10 +45,10 @@ module Specinfra::Backend
45
45
  end
46
46
 
47
47
  def with_env
48
- env = Specinfra.configuration.env || {}
48
+ env = get_config(:env) || {}
49
49
  env[:LANG] ||= 'C'
50
50
 
51
- ssh_options = Specinfra.configuration.ssh_options || {}
51
+ ssh_options = get_config(:ssh_options) || {}
52
52
  ssh_options[:send_env] ||= []
53
53
 
54
54
  env.each do |key, value|
@@ -68,14 +68,14 @@ module Specinfra::Backend
68
68
 
69
69
  def create_ssh
70
70
  Net::SSH.start(
71
- Specinfra.configuration.host,
72
- Specinfra.configuration.ssh_options[:user],
73
- Specinfra.configuration.ssh_options
71
+ get_config(:host),
72
+ get_config(:ssh_options)[:user],
73
+ get_config(:ssh_options)
74
74
  )
75
75
  end
76
76
 
77
77
  def create_scp
78
- ssh = Specinfra.configuration.ssh
78
+ ssh = get_config(:ssh)
79
79
  if ssh.nil?
80
80
  ssh = create_ssh
81
81
  end
@@ -83,12 +83,12 @@ module Specinfra::Backend
83
83
  end
84
84
 
85
85
  def scp_upload!(from, to, opt={})
86
- if Specinfra.configuration.scp.nil?
87
- Specinfra.configuration.scp = create_scp
86
+ if get_config(:scp).nil?
87
+ set_config(:scp, create_scp)
88
88
  end
89
89
 
90
90
  tmp = File.join('/tmp', File.basename(to))
91
- scp = Specinfra.configuration.scp
91
+ scp = get_config(:scp)
92
92
  scp.upload!(from, tmp, opt)
93
93
  run_command(Specinfra.command.get(:move_file, tmp, to))
94
94
  end
@@ -100,13 +100,13 @@ module Specinfra::Backend
100
100
  exit_signal = nil
101
101
  retry_prompt = /^Sorry, try again/
102
102
 
103
- if Specinfra.configuration.ssh.nil?
104
- Specinfra.configuration.ssh = create_ssh
103
+ if get_config(:ssh).nil?
104
+ set_config(:ssh, create_ssh)
105
105
  end
106
106
 
107
- ssh = Specinfra.configuration.ssh
107
+ ssh = get_config(:ssh)
108
108
  ssh.open_channel do |channel|
109
- if Specinfra.configuration.sudo_password or Specinfra.configuration.request_pty
109
+ if get_config(:sudo_password) or get_config(:request_pty)
110
110
  channel.request_pty do |ch, success|
111
111
  abort "Could not obtain pty " if !success
112
112
  end
@@ -117,7 +117,7 @@ module Specinfra::Backend
117
117
  if data.match retry_prompt
118
118
  abort 'Wrong sudo password! Please confirm your password.'
119
119
  elsif data.match /^#{prompt}/
120
- channel.send_data "#{Specinfra.configuration.sudo_password}\n"
120
+ channel.send_data "#{get_config(:sudo_password)}\n"
121
121
  else
122
122
  stdout_data += data
123
123
  end
@@ -149,13 +149,13 @@ module Specinfra::Backend
149
149
  end
150
150
 
151
151
  def sudo
152
- if sudo_path = Specinfra.configuration.sudo_path
152
+ if sudo_path = get_config(:sudo_path)
153
153
  sudo_path += '/sudo'
154
154
  else
155
155
  sudo_path = 'sudo'
156
156
  end
157
157
 
158
- sudo_options = Specinfra.configuration.sudo_options
158
+ sudo_options = get_config(:sudo_options)
159
159
  if sudo_options
160
160
  sudo_options = sudo_options.shelljoin if sudo_options.is_a?(Array)
161
161
  sudo_options = ' ' + sudo_options
@@ -165,8 +165,8 @@ module Specinfra::Backend
165
165
  end
166
166
 
167
167
  def sudo?
168
- user = Specinfra.configuration.ssh_options[:user]
169
- disable_sudo = Specinfra.configuration.disable_sudo
168
+ user = get_config(:ssh_options)[:user]
169
+ disable_sudo = get_config(:disable_sudo)
170
170
  user != 'root' && !disable_sudo
171
171
  end
172
172
  end
@@ -29,7 +29,7 @@ module Specinfra::Backend
29
29
  end
30
30
 
31
31
  def with_env
32
- env = Specinfra.configuration.env || {}
32
+ env = get_config(:env) || {}
33
33
  env[:LANG] ||= 'C'
34
34
 
35
35
  env.each do |key, value|
@@ -47,8 +47,8 @@ module Specinfra::Backend
47
47
  end
48
48
 
49
49
  def add_pre_command(cmd)
50
- if Specinfra.configuration.pre_command
51
- pre_cmd = build_command(Specinfra.configuration.pre_command)
50
+ if get_config(:pre_command)
51
+ pre_cmd = build_command(get_config(:pre_command))
52
52
  "#{pre_cmd} && #{cmd}"
53
53
  else
54
54
  cmd
@@ -61,10 +61,10 @@ module Specinfra::Backend
61
61
  exit_status = nil
62
62
  exit_signal = nil
63
63
  retry_prompt = /^Login: /
64
- if Specinfra.configuration.telnet.nil?
65
- Specinfra.configuration.telnet = create_telnet
64
+ if get_config(:telnet).nil?
65
+ set_config(:telnet, create_telnet)
66
66
  end
67
- telnet = Specinfra.configuration.telnet
67
+ telnet = get_config(:telnet)
68
68
  re = []
69
69
  unless telnet.nil?
70
70
  re = telnet.cmd( "#{command}; echo $?" ).split("\n")[0..-2]
@@ -75,10 +75,10 @@ module Specinfra::Backend
75
75
  end
76
76
 
77
77
  def create_telnet
78
- tel = Net::Telnet.new( "Host" => Specinfra.configuration.host )
78
+ tel = Net::Telnet.new( "Host" => get_config(:host) )
79
79
  tel.login(
80
- "Name" => Specinfra.configuration.telnet_options[:user],
81
- "Password" => Specinfra.configuration.telnet_options[:pass]
80
+ "Name" => get_config(:telnet_options)[:user],
81
+ "Password" => get_config(:telnet_options)[:pass]
82
82
  )
83
83
  tel
84
84
  rescue
@@ -86,13 +86,13 @@ module Specinfra::Backend
86
86
  end
87
87
 
88
88
  def sudo
89
- if sudo_path = Specinfra.configuration.sudo_path
89
+ if sudo_path = get_config(:sudo_path)
90
90
  sudo_path += '/sudo'
91
91
  else
92
92
  sudo_path = 'sudo'
93
93
  end
94
94
 
95
- sudo_options = Specinfra.configuration.sudo_options
95
+ sudo_options = get_config(:sudo_options)
96
96
  if sudo_options
97
97
  sudo_options = sudo_options.shelljoin if sudo_options.is_a?(Array)
98
98
  sudo_options = ' ' + sudo_options
@@ -3,9 +3,9 @@ module Specinfra::Backend
3
3
  include PowerShell::ScriptHelper
4
4
 
5
5
  def run_command(cmd, opts={})
6
- Specinfra.configuration.os = { :family => 'windows' }
6
+ set_config(:os, {:family => 'windows'})
7
7
  script = create_script(cmd)
8
- winrm = Specinfra.configuration.winrm
8
+ winrm = get_config(:winrm)
9
9
 
10
10
  result = winrm.powershell(script)
11
11
  stdout, stderr = [:stdout, :stderr].map do |s|
@@ -1,77 +1,83 @@
1
1
  class Specinfra::CommandFactory
2
- class << self
3
- @@types = nil
2
+ @@types = nil
4
3
 
5
- def get(meth, *args)
6
- action, resource_type, subaction = breakdown(meth)
7
- method = action
8
- method += "_#{subaction}" if subaction
9
- command_class = create_command_class(resource_type)
10
- if command_class.respond_to?(method)
11
- command_class.send(method, *args)
12
- else
13
- raise NotImplementedError.new("#{method} is not implemented in #{command_class}")
14
- end
15
- end
4
+ def self.instance
5
+ self.new(os)
6
+ end
16
7
 
17
- private
18
- def create_command_class(resource_type)
19
- family = os[:family]
20
- version = os[:release] ? "V#{os[:release].to_i}" : nil
8
+ def initialize(os_info)
9
+ @os_info = os_info
10
+ end
21
11
 
22
- common_class = Specinfra::Command
23
- base_class = common_class.const_get('Base')
24
- os_class = family.nil? ? base_class : common_class.const_get(family.capitalize)
12
+ def get(meth, *args)
13
+ action, resource_type, subaction = breakdown(meth)
14
+ method = action
15
+ method += "_#{subaction}" if subaction
16
+ command_class = create_command_class(resource_type)
17
+ if command_class.respond_to?(method)
18
+ command_class.send(method, *args)
19
+ else
20
+ raise NotImplementedError.new("#{method} is not implemented in #{command_class}")
21
+ end
22
+ end
25
23
 
26
- if family && version
27
- begin
28
- version_class = os_class.const_get(version)
29
- rescue
30
- version_class = os_class.const_get('Base')
31
- end
32
- elsif family.nil?
33
- version_class = os_class
34
- elsif family != 'base' && version.nil?
35
- version_class = os_class.const_get('Base')
36
- end
24
+ private
25
+ def create_command_class(resource_type)
26
+ family = @os_info[:family]
27
+ version = @os_info[:release] ? "V#{@os_info[:release].to_i}" : nil
28
+
29
+ common_class = Specinfra::Command
30
+ base_class = common_class.const_get('Base')
31
+ os_class = family.nil? ? base_class : common_class.const_get(family.capitalize)
37
32
 
33
+ if family && version
38
34
  begin
39
- command_class = version_class.const_get(resource_type.to_camel_case)
35
+ version_class = os_class.const_get(version)
40
36
  rescue
37
+ version_class = os_class.const_get('Base')
41
38
  end
39
+ elsif family.nil?
40
+ version_class = os_class
41
+ elsif family != 'base' && version.nil?
42
+ version_class = os_class.const_get('Base')
43
+ end
42
44
 
43
- if command_class.nil? ||( (command_class < Specinfra::Command::Base).nil? && (command_class < Specinfra::Command::Windows::Base).nil? )
44
- command_class = base_class.const_get(resource_type.to_camel_case)
45
- end
45
+ begin
46
+ command_class = version_class.const_get(resource_type.to_camel_case)
47
+ rescue
48
+ end
46
49
 
47
- command_class.create
50
+ if command_class.nil? ||( (command_class < Specinfra::Command::Base).nil? && (command_class < Specinfra::Command::Windows::Base).nil? )
51
+ command_class = base_class.const_get(resource_type.to_camel_case)
48
52
  end
49
53
 
50
- def breakdown(meth)
51
- # Somtimes `selinux_module' type matches `selinux' and error occurs.
52
- # Reverse sorting is needed to avoid this problem.
53
- types = resource_types.map {|t| t.to_snake_case }.sort.reverse.join('|')
54
- md = meth.to_s.match(/^([^_]+)_(#{types})_?(.+)?$/)
55
- if md.nil?
56
- message = "Could not break down `#{meth}' to appropriate type and method.\n"
57
- message += "The method name shoud be in the form of `action_type_subaction'."
58
- raise message
59
- end
60
- return md[1], md[2], md[3]
54
+ command_class.create
55
+ end
56
+
57
+ def breakdown(meth)
58
+ # Somtimes `selinux_module' type matches `selinux' and error occurs.
59
+ # Reverse sorting is needed to avoid this problem.
60
+ types = resource_types.map {|t| t.to_snake_case }.sort.reverse.join('|')
61
+ md = meth.to_s.match(/^([^_]+)_(#{types})_?(.+)?$/)
62
+ if md.nil?
63
+ message = "Could not break down `#{meth}' to appropriate type and method.\n"
64
+ message += "The method name shoud be in the form of `action_type_subaction'."
65
+ raise message
61
66
  end
67
+ return md[1], md[2], md[3]
68
+ end
62
69
 
63
- def resource_types
64
- if @@types.nil?
65
- @@types = []
66
- Specinfra::Command::Base.subclasses.each do |s|
67
- @@types << s.to_s.split(':')[-1]
68
- end
69
- Specinfra::Command::Windows::Base.subclasses.each do |s|
70
- @@types << s.to_s.split(':')[-1]
71
- end
72
- @@types.uniq!
70
+ def resource_types
71
+ if @@types.nil?
72
+ @@types = []
73
+ Specinfra::Command::Base.subclasses.each do |s|
74
+ @@types << s.to_s.split(':')[-1]
75
+ end
76
+ Specinfra::Command::Windows::Base.subclasses.each do |s|
77
+ @@types << s.to_s.split(':')[-1]
73
78
  end
74
- @@types
79
+ @@types.uniq!
75
80
  end
81
+ @@types
76
82
  end
77
83
  end
@@ -1,7 +1,19 @@
1
1
  module Specinfra::Helper
2
2
  class DetectOs
3
- def self.run_command(cmd)
4
- Specinfra.backend.run_command(cmd)
3
+ def self.detect
4
+ self.new(Specinfra.backend).detect
5
+ end
6
+
7
+ def initialize(backend)
8
+ @backend = backend
9
+ end
10
+
11
+ def run_command(cmd)
12
+ @backend.run_command(cmd)
13
+ end
14
+
15
+ def detect
16
+ raise NotImplementedError
5
17
  end
6
18
  end
7
19
  end
@@ -1,5 +1,5 @@
1
1
  class Specinfra::Helper::DetectOs::Aix < Specinfra::Helper::DetectOs
2
- def self.detect
2
+ def detect
3
3
  if run_command('uname -s').stdout =~ /AIX/i
4
4
  { :family => 'aix', :release => nil }
5
5
  end
@@ -1,5 +1,5 @@
1
1
  class Specinfra::Helper::DetectOs::Alpine < Specinfra::Helper::DetectOs
2
- def self.detect
2
+ def detect
3
3
  if run_command('ls /etc/alpine-release').success?
4
4
  release = run_command('cat /etc/alpine-release').stdout
5
5
  { :family => 'alpine', :release => release }
@@ -1,5 +1,5 @@
1
1
  class Specinfra::Helper::DetectOs::Arch < Specinfra::Helper::DetectOs
2
- def self.detect
2
+ def detect
3
3
  if run_command('ls /etc/arch-release').success?
4
4
  { :family => 'arch', :release => nil }
5
5
  end
@@ -1,5 +1,5 @@
1
1
  class Specinfra::Helper::DetectOs::Coreos < Specinfra::Helper::DetectOs
2
- def self.detect
2
+ def detect
3
3
  if run_command('ls /etc/coreos/update.conf').success?
4
4
  distro = nil
5
5
  release = nil
@@ -1,5 +1,5 @@
1
1
  class Specinfra::Helper::DetectOs::Darwin < Specinfra::Helper::DetectOs
2
- def self.detect
2
+ def detect
3
3
  if run_command('uname -s').stdout =~ /Darwin/i
4
4
  { :family => 'darwin', :release => nil }
5
5
  end
@@ -1,5 +1,5 @@
1
1
  class Specinfra::Helper::DetectOs::Debian < Specinfra::Helper::DetectOs
2
- def self.detect
2
+ def detect
3
3
  if run_command('ls /etc/debian_version').success?
4
4
  distro = nil
5
5
  release = nil
@@ -1,5 +1,5 @@
1
1
  class Specinfra::Helper::DetectOs::Esxi < Specinfra::Helper::DetectOs
2
- def self.detect
2
+ def detect
3
3
  if run_command('vmware -v').success?
4
4
  line = run_command('vmware -v').stdout
5
5
  if line =~ /VMware ESXi (.*)/
@@ -1,5 +1,5 @@
1
1
  class Specinfra::Helper::DetectOs::Freebsd < Specinfra::Helper::DetectOs
2
- def self.detect
2
+ def detect
3
3
  if ( uname = run_command('uname -sr').stdout ) && uname =~ /FreeBSD/i
4
4
  if uname =~ /10./
5
5
  { :family => 'freebsd', :release => 10 }
@@ -1,5 +1,5 @@
1
1
  class Specinfra::Helper::DetectOs::Gentoo < Specinfra::Helper::DetectOs
2
- def self.detect
2
+ def detect
3
3
  if run_command('ls /etc/gentoo-release').success?
4
4
  { :family => 'gentoo', :release => nil }
5
5
  end
@@ -1,5 +1,5 @@
1
1
  class Specinfra::Helper::DetectOs::Nixos < Specinfra::Helper::DetectOs
2
- def self.detect
2
+ def detect
3
3
  if run_command('ls /var/run/current-system/sw').success?
4
4
  { :family => 'nixos', :release => nil }
5
5
  end
@@ -1,5 +1,5 @@
1
1
  class Specinfra::Helper::DetectOs::Openbsd < Specinfra::Helper::DetectOs
2
- def self.detect
2
+ def detect
3
3
  if run_command('uname -s').stdout =~ /OpenBSD/i
4
4
  { :family => 'openbsd', :release => nil }
5
5
  end
@@ -1,5 +1,5 @@
1
1
  class Specinfra::Helper::DetectOs::Plamo < Specinfra::Helper::DetectOs
2
- def self.detect
2
+ def detect
3
3
  if run_command('ls /usr/lib/setup/Plamo-*').success?
4
4
  { :family => 'plamo', :release => nil }
5
5
  end
@@ -1,5 +1,5 @@
1
1
  class Specinfra::Helper::DetectOs::Redhat < Specinfra::Helper::DetectOs
2
- def self.detect
2
+ def detect
3
3
  # Fedora also has an /etc/redhat-release so the Fedora check must
4
4
  # come before the RedHat check
5
5
  if run_command('ls /etc/fedora-release').success?
@@ -1,5 +1,5 @@
1
1
  class Specinfra::Helper::DetectOs::Solaris < Specinfra::Helper::DetectOs
2
- def self.detect
2
+ def detect
3
3
  if ( uname = run_command('uname -sr').stdout) && uname =~ /SunOS/i
4
4
  if uname =~ /5.10/
5
5
  { :family => 'solaris', :release => 10 }
@@ -1,5 +1,5 @@
1
1
  class Specinfra::Helper::DetectOs::Suse < Specinfra::Helper::DetectOs
2
- def self.detect
2
+ def detect
3
3
  if run_command('ls /etc/SuSE-release').success?
4
4
  line = run_command('cat /etc/SuSE-release').stdout
5
5
  if line =~ /SUSE Linux Enterprise Server (\d+)/
@@ -1,3 +1,3 @@
1
1
  module Specinfra
2
- VERSION = "2.21.1"
2
+ VERSION = "2.22.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: specinfra
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.21.1
4
+ version: 2.22.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gosuke Miyashita
@@ -109,6 +109,7 @@ files:
109
109
  - LICENSE.txt
110
110
  - README.md
111
111
  - Rakefile
112
+ - examples/multiple_backends.rb
112
113
  - lib/specinfra.rb
113
114
  - lib/specinfra/backend.rb
114
115
  - lib/specinfra/backend/base.rb