specinfra 2.42.0 → 2.42.1

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: aa5a4e0dbe8336562680e6edd462840713fd926c
4
- data.tar.gz: 10341d7185fc49e9e711e4921db8f8189b35c0b9
3
+ metadata.gz: 211b97ff28d60bfeda6954c6e605af14e4cd12ec
4
+ data.tar.gz: 93c326f9dc28ff0c2698ca9f774d0f5717ea14db
5
5
  SHA512:
6
- metadata.gz: 916bd11416a36f4cdef5c0157f7dd22d97a019479243509368d386334edb49b5911102b6bd4cafee5a98eb293f53fa478e47427e715f42295140b09d789473d2
7
- data.tar.gz: 821b8f9cf6c7b44dc5d1f73fcc85c9d9cc42dc03dd0e9a5da6da81a8007d82ca5327c82bb5a78bdac08c87550219056591c56a9e23fc6e9b4e23750f8051f8d4
6
+ metadata.gz: 277f327b85a7fe633f67683b7b75c2528cb4c02cd17d747aa0d91cba93ef82c4057cf05c6fe1a642296f76effdc335c7e3d5a902006c8b9a2b8d134994056640
7
+ data.tar.gz: a380d86cc801f2e6a0a132b652ce652839ce2aabd0a001a0f5bc6d0de32dd58e9ea004c54ad9c6c2ee10295b3f6c7f2f4a5a39564132fd9042f65f09dc4ccdab
@@ -1,5 +1,17 @@
1
1
  class Specinfra::Command::Darwin::Base::Host < Specinfra::Command::Base::Host
2
2
  class << self
3
+ def check_is_resolvable(name, type)
4
+ if type == "dns"
5
+ ## try to resolve either A or AAAA record; grep is used to return the appropriate exit code
6
+ %Q{dig +short +time=1 -q #{escape(name)} a #{escape(name)} aaaa | grep -qie '^[0-9a-f:.]*$'}
7
+ elsif type == "hosts"
8
+ "sed 's/#.*$//' /etc/hosts | grep -w -- #{escape(name)}"
9
+ else
10
+ ## grep is required as dscacheutil always returns exit code 0
11
+ "dscacheutil -q host -a name #{escape(name)} | grep -q '_address:'"
12
+ end
13
+ end
14
+
3
15
  def check_is_reachable(host, port, proto, timeout)
4
16
  if port.nil?
5
17
  "ping -t #{escape(timeout)} -c 2 -n #{escape(host)}"
@@ -7,5 +19,21 @@ class Specinfra::Command::Darwin::Base::Host < Specinfra::Command::Base::Host
7
19
  "nc -vvvvz#{escape(proto[0].chr)} #{escape(host)} #{escape(port)} -w #{escape(timeout)}"
8
20
  end
9
21
  end
22
+
23
+ def get_ipaddress(name)
24
+ # If the query returns multiple records the most likey match is returned.
25
+ # Generally this means IPv6 wins over IPv4.
26
+ %Q{dscacheutil -q host -a name #{escape(name)} | } +
27
+ %Q{awk '/^ipv6_/{ ip = $2 }; /^$/{ exit }; /^ip_/{ ip = $2; exit}; END{ print ip }'}
28
+ end
29
+ def get_ipv4_address(name)
30
+ ## With dscacheutil multiple IPs can be returned for IPv4 just pick the first one
31
+ %Q{dscacheutil -q host -a name #{escape(name)} | awk '/^ip_/{ print $2; exit }'}
32
+ end
33
+ def get_ipv6_address(name)
34
+ ## With dscacheutil multiple IPs can be returned. For IPv6 the link-local is displayed first
35
+ ## hence the last entry is picked.
36
+ %Q{dscacheutil -q host -a name #{escape(name)} | awk '/^ipv6_/{ ip = $2 } END{ print ip }'}
37
+ end
10
38
  end
11
39
  end
@@ -1,5 +1,13 @@
1
1
  class Specinfra::Command::Openbsd::Base::Service < Specinfra::Command::Base::Service
2
2
  class << self
3
+ def create
4
+ if os[:release].to_f < 5.7
5
+ self
6
+ else
7
+ Specinfra::Command::Openbsd::V57::Service
8
+ end
9
+ end
10
+
3
11
  def check_is_enabled(service, level=nil)
4
12
  "/etc/rc.d/#{escape(service)} status"
5
13
  end
@@ -0,0 +1,35 @@
1
+ class Specinfra::Command::Openbsd::V57::Service < Specinfra::Command::Openbsd::Base::Service
2
+ class << self
3
+ def check_is_enabled(service, level=nil)
4
+ "rcctl get #{escape(service)} status"
5
+ end
6
+
7
+ def check_is_running(service)
8
+ "rcctl check #{escape(service)}"
9
+ end
10
+
11
+ def enable(service)
12
+ "rcctl set #{escape(service)} status on"
13
+ end
14
+
15
+ def disable(service)
16
+ "rcctl set #{escape(service)} status off"
17
+ end
18
+
19
+ def start(service)
20
+ "rcctl start #{escape(service)}"
21
+ end
22
+
23
+ def stop(service)
24
+ "rcctl stop #{escape(service)}"
25
+ end
26
+
27
+ def restart(service)
28
+ "rcctl restart #{escape(service)}"
29
+ end
30
+
31
+ def reload(service)
32
+ "rcctl reload #{escape(service)}"
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,2 @@
1
+ class Specinfra::Command::Openbsd::V57 < Specinfra::Command::Openbsd::Base
2
+ end
@@ -1,11 +1,11 @@
1
1
  class Specinfra::Command::Ubuntu::Base::Ppa < Specinfra::Command::Debian::Base::Ppa
2
2
  class << self
3
3
  def check_exists(package)
4
- %Q{find /etc/apt/ -name \*.list | xargs grep -o -E "deb +http://ppa.launchpad.net/#{to_apt_line_uri(package)}"}
4
+ %Q{find /etc/apt/ -name \*.list | xargs grep -o -E "deb +[\"']?http://ppa.launchpad.net/#{to_apt_line_uri(package)}"}
5
5
  end
6
6
 
7
7
  def check_is_enabled(package)
8
- %Q{find /etc/apt/ -name \*.list | xargs grep -o -E "^deb +http://ppa.launchpad.net/#{to_apt_line_uri(package)}"}
8
+ %Q{find /etc/apt/ -name \*.list | xargs grep -o -E "^deb +[\"']?http://ppa.launchpad.net/#{to_apt_line_uri(package)}"}
9
9
  end
10
10
 
11
11
  private
@@ -244,6 +244,10 @@ require 'specinfra/command/openbsd/base/routing_table'
244
244
  require 'specinfra/command/openbsd/base/service'
245
245
  require 'specinfra/command/openbsd/base/user'
246
246
 
247
+ # OpenBSD >= V5.7 (inherit OpenBSD)
248
+ require 'specinfra/command/openbsd/v57'
249
+ require 'specinfra/command/openbsd/v57/service'
250
+
247
251
  # Solaris (inherit Base)
248
252
  require 'specinfra/command/solaris'
249
253
  require 'specinfra/command/solaris/base'
@@ -1,3 +1,3 @@
1
1
  module Specinfra
2
- VERSION = "2.42.0"
2
+ VERSION = "2.42.1"
3
3
  end
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
3
+ property[:os] = nil
4
+ set :os, :family => 'darwin'
5
+
6
+ describe get_command(:check_host_is_resolvable, 'pink.unicorn.com', 'dns') do
7
+ it { should eq "dig +short +time=1 -q pink.unicorn.com a pink.unicorn.com aaaa | grep -qie '^[0-9a-f:.]*$'" }
8
+ end
9
+
10
+ describe get_command(:check_host_is_resolvable, 'pink.unicorn.com', 'hosts') do
11
+ it { should eq "sed 's/#.*$//' /etc/hosts | grep -w -- pink.unicorn.com" }
12
+ end
13
+
14
+ describe get_command(:check_host_is_resolvable, 'pink.unicorn.com', nil) do
15
+ it { should eq "dscacheutil -q host -a name pink.unicorn.com | grep -q '_address:'" }
16
+ end
17
+
18
+ describe get_command(:check_host_is_reachable, 'pink.unicorn.com', nil, 'tcp', 10) do
19
+ it { should eq "ping -t 10 -c 2 -n pink.unicorn.com"}
20
+ end
21
+
22
+ describe get_command(:check_host_is_reachable, 'pink.unicorn.com', 53, 'udp', 66) do
23
+ it { should eq "nc -vvvvzu pink.unicorn.com 53 -w 66" }
24
+ end
25
+
26
+ describe get_command(:get_host_ipaddress, 'pink.unicorn.com') do
27
+ it do should eq "dscacheutil -q host -a name pink.unicorn.com | " +
28
+ "awk '/^ipv6_/{ ip = $2 }; /^$/{ exit }; /^ip_/{ ip = $2; exit}; END{ print ip }'"
29
+ end
30
+ end
31
+
32
+ describe get_command(:get_host_ipv4_address, 'pink.unicorn.com') do
33
+ it { should eq "dscacheutil -q host -a name pink.unicorn.com | awk '/^ip_/{ print $2; exit }'" }
34
+ end
35
+
36
+ describe get_command(:get_host_ipv6_address, 'pink.unicorn.com') do
37
+ it { should eq "dscacheutil -q host -a name pink.unicorn.com | awk '/^ipv6_/{ ip = $2 } END{ print ip }'" }
38
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ property[:os] = nil
4
+ set :os, :family => 'openbsd'
5
+
6
+ describe get_command(:check_service_is_enabled, 'httpd') do
7
+ it { should eq '/etc/rc.d/httpd status' }
8
+ end
9
+
10
+ describe get_command(:check_service_is_running, 'httpd') do
11
+ it { should eq '/etc/rc.d/httpd check' }
12
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ property[:os] = nil
4
+ set :os, :family => 'openbsd', :release => '5.7'
5
+
6
+ describe get_command(:check_service_is_enabled, 'httpd') do
7
+ it { should eq 'rcctl get httpd status' }
8
+ end
9
+
10
+ describe get_command(:check_service_is_running, 'httpd') do
11
+ it { should eq 'rcctl check httpd' }
12
+ end
13
+
14
+ describe get_command(:enable_service, 'httpd') do
15
+ it { should eq 'rcctl set httpd status on' }
16
+ end
17
+
18
+ describe get_command(:disable_service, 'httpd') do
19
+ it { should eq 'rcctl set httpd status off' }
20
+ end
21
+
22
+ describe get_command(:start_service, 'httpd') do
23
+ it { should eq 'rcctl start httpd' }
24
+ end
25
+
26
+ describe get_command(:stop_service, 'httpd') do
27
+ it { should eq 'rcctl stop httpd' }
28
+ end
29
+
30
+ describe get_command(:restart_service, 'httpd') do
31
+ it { should eq 'rcctl restart httpd' }
32
+ end
33
+
34
+ describe get_command(:reload_service, 'httpd') do
35
+ it { should eq 'rcctl reload httpd' }
36
+ end
@@ -4,9 +4,9 @@ property[:os] = nil
4
4
  set :os, :family => 'ubuntu'
5
5
 
6
6
  describe get_command(:check_ppa_exists, 'nginx/stable') do
7
- it { should eq 'find /etc/apt/ -name *.list | xargs grep -o -E "deb +http://ppa.launchpad.net/nginx/stable"' }
7
+ it { should eq %(find /etc/apt/ -name *.list | xargs grep -o -E "deb +["']?http://ppa.launchpad.net/nginx/stable") }
8
8
  end
9
9
 
10
10
  describe get_command(:check_ppa_is_enabled, 'nginx/stable') do
11
- it { should eq 'find /etc/apt/ -name *.list | xargs grep -o -E "^deb +http://ppa.launchpad.net/nginx/stable"' }
11
+ it { should eq %(find /etc/apt/ -name *.list | xargs grep -o -E "^deb +["']?http://ppa.launchpad.net/nginx/stable") }
12
12
  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.42.0
4
+ version: 2.42.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gosuke Miyashita
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-24 00:00:00.000000000 Z
11
+ date: 2015-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-scp
@@ -319,6 +319,8 @@ files:
319
319
  - lib/specinfra/command/openbsd/base/routing_table.rb
320
320
  - lib/specinfra/command/openbsd/base/service.rb
321
321
  - lib/specinfra/command/openbsd/base/user.rb
322
+ - lib/specinfra/command/openbsd/v57.rb
323
+ - lib/specinfra/command/openbsd/v57/service.rb
322
324
  - lib/specinfra/command/opensuse.rb
323
325
  - lib/specinfra/command/opensuse/base.rb
324
326
  - lib/specinfra/command/opensuse/base/service.rb
@@ -464,6 +466,7 @@ files:
464
466
  - spec/command/base/package_spec.rb
465
467
  - spec/command/base/user_spec.rb
466
468
  - spec/command/darwin/file_spec.rb
469
+ - spec/command/darwin/host_spec.rb
467
470
  - spec/command/darwin/user_spec.rb
468
471
  - spec/command/debian/service_spec.rb
469
472
  - spec/command/esxi/package_spec.rb
@@ -488,6 +491,8 @@ files:
488
491
  - spec/command/openbsd/file_spec.rb
489
492
  - spec/command/openbsd/host_spec.rb
490
493
  - spec/command/openbsd/interface_spec.rb
494
+ - spec/command/openbsd/service_spec.rb
495
+ - spec/command/openbsd57/service_spec.rb
491
496
  - spec/command/redhat/package_spec.rb
492
497
  - spec/command/redhat/service_spec.rb
493
498
  - spec/command/redhat7/host_spec.rb
@@ -559,6 +564,7 @@ test_files:
559
564
  - spec/command/base/package_spec.rb
560
565
  - spec/command/base/user_spec.rb
561
566
  - spec/command/darwin/file_spec.rb
567
+ - spec/command/darwin/host_spec.rb
562
568
  - spec/command/darwin/user_spec.rb
563
569
  - spec/command/debian/service_spec.rb
564
570
  - spec/command/esxi/package_spec.rb
@@ -583,6 +589,8 @@ test_files:
583
589
  - spec/command/openbsd/file_spec.rb
584
590
  - spec/command/openbsd/host_spec.rb
585
591
  - spec/command/openbsd/interface_spec.rb
592
+ - spec/command/openbsd/service_spec.rb
593
+ - spec/command/openbsd57/service_spec.rb
586
594
  - spec/command/redhat/package_spec.rb
587
595
  - spec/command/redhat/service_spec.rb
588
596
  - spec/command/redhat7/host_spec.rb
@@ -612,3 +620,4 @@ test_files:
612
620
  - spec/host_inventory/openbsd/filesystem_spec.rb
613
621
  - spec/host_inventory/solaris/filesystem_spec.rb
614
622
  - spec/spec_helper.rb
623
+ has_rdoc: