specinfra 2.0.0.beta4 → 2.0.0.beta5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b9e3df085341c6a98609ce2cbeec6286def53483
4
- data.tar.gz: 1d63bd9b0f96b59f4722625d023b07d737c5e6e6
3
+ metadata.gz: 65e4d83475bbdd34b27754036496fc53ba0a2134
4
+ data.tar.gz: 46cbd1679ece1082f94dea53e3cb9ed5e54974c8
5
5
  SHA512:
6
- metadata.gz: a30812a5492202d26e6b0dfa88dd263a66c5ed70c051b100a03acdf408491cdf695c39195fa299b76a2dec455756b58fb5ea4237d0f5ba7e4fde2e088ed8e9a0
7
- data.tar.gz: 2884c197f8e70a841d8f7f65bf5b929b745b3d8e3253a9ed3241cad4ba4e819d41838e4d9509bda6506a14aaf85bf120fccadb33cea960d8f42cc34a97500ce7
6
+ metadata.gz: b2d221e45cb170df18ffa898388eb7018143e828e6045591bbd63e3f2f931283899192490bcb391d107a35421f0df967cbddfc1eb98dc28bc692339b41388a5f
7
+ data.tar.gz: 713db6f57e9ff241a5aa23c531e3a51c2c0584114ebd9f0f1d8917b005a21ec0667032c07d7c9b6bbf8248b7568f066a0f35d52febbefbf525eab3bd963c3928
data/Rakefile CHANGED
@@ -1,30 +1,35 @@
1
1
  require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
- require "octorelease"
2
+ begin
3
+ require "rspec/core/rake_task"
4
+ require "octorelease"
5
+ rescue LoadError
6
+ end
4
7
 
5
- task :spec => 'spec:all'
8
+ if defined?(RSpec)
9
+ task :spec => 'spec:all'
6
10
 
7
- namespace :spec do
8
- task :all => [ :helper, :backend, :configuration ]
11
+ namespace :spec do
12
+ task :all => [ :helper, :backend, :configuration ]
9
13
 
10
- RSpec::Core::RakeTask.new(:helper) do |t|
11
- t.pattern = "spec/helper/*_spec.rb"
12
- end
14
+ RSpec::Core::RakeTask.new(:helper) do |t|
15
+ t.pattern = "spec/helper/*_spec.rb"
16
+ end
13
17
 
14
- task :backend => 'backend:all'
15
- namespace :backend do
16
- backends = %w[exec ssh]
18
+ task :backend => 'backend:all'
19
+ namespace :backend do
20
+ backends = %w[exec ssh]
17
21
 
18
- task :all => backends
22
+ task :all => backends
19
23
 
20
- backends.each do |backend|
21
- RSpec::Core::RakeTask.new(backend) do |t|
22
- t.pattern = "spec/backend/#{backend}/*_spec.rb"
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
- RSpec::Core::RakeTask.new(:configuration) do |t|
28
- t.pattern = "spec/configuration_spec.rb"
31
+ RSpec::Core::RakeTask.new(:configuration) do |t|
32
+ t.pattern = "spec/configuration_spec.rb"
33
+ end
29
34
  end
30
35
  end
@@ -3,6 +3,7 @@ module Specinfra
3
3
  class Docker < Exec
4
4
  def initialize
5
5
  @images = []
6
+ ::Docker.url = Specinfra.configuration.docker_url
6
7
  end
7
8
 
8
9
  def run_command(cmd, opts={})
@@ -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
- out = `#{cmd}`
10
- [out, $?.dup]
11
- end
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 pass_prompt
71
+ if data.match /^#{prompt}/
69
72
  channel.send_data "#{Specinfra.configuration.sudo_password}\n"
70
73
  else
71
74
  stdout_data += data
@@ -12,6 +12,7 @@ require "specinfra/command/redhat7"
12
12
  require "specinfra/command/suse"
13
13
  require "specinfra/command/opensuse"
14
14
  require "specinfra/command/fedora"
15
+ require "specinfra/command/nixos"
15
16
 
16
17
  # Solaris
17
18
  require "specinfra/command/solaris"
@@ -16,7 +16,7 @@ module Specinfra
16
16
 
17
17
  def check_installed(package,version=nil)
18
18
  if version
19
- "pacman -Q | grep #{escape(package)} #{espace(version)}"
19
+ "pacman -Q | grep #{escape(package)} #{escape(version)}"
20
20
  else
21
21
  "pacman -Q | grep #{escape(package)}"
22
22
  end
@@ -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
@@ -9,9 +9,9 @@ module Specinfra
9
9
  :stderr,
10
10
  :sudo_path,
11
11
  :disable_sudo,
12
- :pass_prompt,
13
12
  :sudo_options,
14
13
  :docker_image,
14
+ :docker_url,
15
15
  :lxc,
16
16
  :request_pty,
17
17
  :ssh_options,
@@ -10,6 +10,7 @@ module Specinfra
10
10
  'FreeBSD',
11
11
  'FreeBSD10',
12
12
  'Gentoo',
13
+ 'NixOS',
13
14
  'OpenBSD',
14
15
  'Plamo',
15
16
  'RedHat',
@@ -1,3 +1,3 @@
1
1
  module Specinfra
2
- VERSION = "2.0.0.beta4"
2
+ VERSION = "2.0.0.beta5"
3
3
  end
@@ -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 'sudo /bin/sh -c test\ -f\ /etc/passwd'
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 'sudo /bin/sh -c test\ \!\ -f\ /etc/selinux/config\ \|\|\ \(getenforce\ \|\ grep\ -i\ --\ disabled\ \&\&\ grep\ -i\ --\ \^SELINUX\=disabled\$\ /etc/selinux/config\)'
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 '/usr/local/bin/sudo /bin/sh -c test\ -f\ /etc/passwd'
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 '/usr/local/bin/sudo /bin/sh -c test\ \!\ -f\ /etc/selinux/config\ \|\|\ \(getenforce\ \|\ grep\ -i\ --\ disabled\ \&\&\ grep\ -i\ --\ \^SELINUX\=disabled\$\ /etc/selinux/config\)'
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 'sudo -p \[sudo\]\ password\ for /bin/sh -c test\ -f\ /etc/passwd' }
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 'sudo -p \[sudo\]\ password\ for /bin/sh -c test\ \!\ -f\ /etc/selinux/config\ \|\|\ \(getenforce\ \|\ grep\ -i\ --\ disabled\ \&\&\ grep\ -i\ --\ \^SELINUX\=disabled\$\ /etc/selinux/config\)' }
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.beta4
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-07 00:00:00.000000000 Z
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