specinfra 2.41.1 → 2.42.0

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: 7690b0b34b3029498e2a37c3fca96d59124f30ea
4
- data.tar.gz: 5f61ef5c50888e88ec4d746264688089ca80f238
3
+ metadata.gz: aa5a4e0dbe8336562680e6edd462840713fd926c
4
+ data.tar.gz: 10341d7185fc49e9e711e4921db8f8189b35c0b9
5
5
  SHA512:
6
- metadata.gz: 6b98a9801f5fcdb46f9fbe49cacd9c3fbc967ccdc5156e542678c0fd3334cd37dddfb118a1e10aca745329a3cbc5b2c9224412494e4324d3516bed5390bdd3b6
7
- data.tar.gz: b1e0b990a47a296b1e2d67639c58183837303cbc24ecd5f88ef63c048b936aa41ed2c1ace43af871539c667a6ab4fc9565beee3c8d112ed5315b4321c71ff0c0
6
+ metadata.gz: 916bd11416a36f4cdef5c0157f7dd22d97a019479243509368d386334edb49b5911102b6bd4cafee5a98eb293f53fa478e47427e715f42295140b09d789473d2
7
+ data.tar.gz: 821b8f9cf6c7b44dc5d1f73fcc85c9d9cc42dc03dd0e9a5da6da81a8007d82ca5327c82bb5a78bdac08c87550219056591c56a9e23fc6e9b4e23750f8051f8d4
@@ -234,6 +234,7 @@ require 'specinfra/command/openbsd/base/bond'
234
234
  require 'specinfra/command/openbsd/base/bridge'
235
235
  require 'specinfra/command/openbsd/base/file'
236
236
  require 'specinfra/command/openbsd/base/fstab'
237
+ require 'specinfra/command/openbsd/base/host'
237
238
  require 'specinfra/command/openbsd/base/interface'
238
239
  require 'specinfra/command/openbsd/base/inventory'
239
240
  require 'specinfra/command/openbsd/base/mail_alias'
@@ -14,12 +14,23 @@ class Specinfra::Command::Base::Host < Specinfra::Command::Base
14
14
  if port.nil?
15
15
  "ping -w #{escape(timeout)} -c 2 -n #{escape(host)}"
16
16
  else
17
- "nc -vvvvz#{escape(proto[0].chr)} #{escape(host)} #{escape(port)} -w #{escape(timeout)}"
17
+ "nc -w #{escape(timeout)} -vvvvz#{escape(proto[0].chr)} #{escape(host)} #{escape(port)}"
18
18
  end
19
19
  end
20
20
 
21
+ # getent hosts on a dualstack machine will most likely
22
+ # return the ipv6 address to ensure one can more cleary
23
+ # define the outcome the ipv{4,6}_address are used.
21
24
  def get_ipaddress(name)
22
25
  "getent hosts #{escape(name)} | awk '{print $1}'"
23
26
  end
27
+ def get_ipv4_address(name)
28
+ # Will return multiple values pick the first and exit
29
+ "getent ahostsv4 #{escape(name)} | awk '{print $1; exit}'"
30
+ end
31
+ def get_ipv6_address(name)
32
+ # Will return multiple values pick the first and exit
33
+ "getent ahostsv6 #{escape(name)} | awk '{print $1; exit}'"
34
+ end
24
35
  end
25
36
  end
@@ -7,5 +7,18 @@ class Specinfra::Command::Freebsd::Base::Host < Specinfra::Command::Base::Host
7
7
  "nc -vvvvz#{escape(proto[0].chr)} #{escape(host)} #{escape(port)} -w #{escape(timeout)}"
8
8
  end
9
9
  end
10
+ def get_ipaddress(name)
11
+ # getent hosts will return both the ipv6 and ipv4 record.
12
+ # this will only pick the first one. (Linux behavior)
13
+ "getent hosts #{escape(name)} | awk '{print $1; exit}'"
14
+ end
15
+ def get_ipv4_address(name)
16
+ # May return multiple values pick the one matching ipv4
17
+ "getent hosts #{escape(name)} | awk '$1 ~ /^[0-9.]+$/ {print $1}'"
18
+ end
19
+ def get_ipv6_address(name)
20
+ # May return multiple values pick the one matching ipv6
21
+ "getent hosts #{escape(name)} | awk 'tolower($1) ~ /^[0-9a-f:]+$/ {print $1}'"
22
+ end
10
23
  end
11
24
  end
@@ -0,0 +1,17 @@
1
+ class Specinfra::Command::Openbsd::Base::Host < Specinfra::Command::Base::Host
2
+ class << self
3
+ def get_ipaddress(name)
4
+ # getent hosts will return both the ipv6 and ipv4 record.
5
+ # this will only pick the first one. (Linux behavior)
6
+ "getent hosts #{escape(name)} | awk '{print $1; exit}'"
7
+ end
8
+ def get_ipv4_address(name)
9
+ # May return multiple values pick the one matching ipv4
10
+ "getent hosts #{escape(name)} | awk '$1 ~ /^[0-9.]+$/ {print $1}'"
11
+ end
12
+ def get_ipv6_address(name)
13
+ # May return multiple values pick the one matching ipv6
14
+ "getent hosts #{escape(name)} | awk 'tolower($1) ~ /^[0-9a-f:]+$/ {print $1}'"
15
+ end
16
+ end
17
+ end
@@ -1,3 +1,3 @@
1
1
  module Specinfra
2
- VERSION = "2.41.1"
2
+ VERSION = "2.42.0"
3
3
  end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ set :os, { :family => nil }
4
+
5
+ describe get_command(:check_host_is_reachable, 'pink.unicorn.com', nil, 'tcp', 10) do
6
+ it { should eq "ping -w 10 -c 2 -n pink.unicorn.com" }
7
+ end
8
+
9
+ describe get_command(:check_host_is_reachable, 'pink.unicorn.com', '53', 'udp', 2) do
10
+ it { should eq "nc -w 2 -vvvvzu pink.unicorn.com 53" }
11
+ end
12
+
13
+ describe get_command(:get_host_ipaddress, 'pink.unicorn.com') do
14
+ it { should eq "getent hosts pink.unicorn.com | awk '{print $1}'" }
15
+ end
16
+
17
+ describe get_command(:get_host_ipv4_address, 'pink.unicorn.com') do
18
+ it { should eq "getent ahostsv4 pink.unicorn.com | awk '{print $1; exit}'" }
19
+ end
20
+
21
+ describe get_command(:get_host_ipv6_address, 'pink.unicorn.com') do
22
+ it { should eq "getent ahostsv6 pink.unicorn.com | awk '{print $1; exit}'" }
23
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ property[:os] = nil
4
+ set :os, :family => 'freebsd'
5
+
6
+ describe get_command(:check_host_is_reachable, 'pink.unicorn.com', nil, 'tcp', 10) do
7
+ it { should eq "ping -t 10 -c 2 -n pink.unicorn.com"}
8
+ end
9
+
10
+ describe get_command(:check_host_is_reachable, 'pink.unicorn.com', 53, 'udp', 66) do
11
+ it { should eq "nc -vvvvzu pink.unicorn.com 53 -w 66" }
12
+ end
13
+
14
+ describe get_command(:get_host_ipaddress, 'pink.unicorn.com') do
15
+ it { should eq "getent hosts pink.unicorn.com | awk '{print $1; exit}'" }
16
+ end
17
+
18
+ describe get_command(:get_host_ipv4_address, 'pink.unicorn.com') do
19
+ it { should eq "getent hosts pink.unicorn.com | awk '$1 ~ /^[0-9.]+$/ {print $1}'" }
20
+ end
21
+
22
+ describe get_command(:get_host_ipv6_address, 'pink.unicorn.com') do
23
+ it { should eq "getent hosts pink.unicorn.com | awk 'tolower($1) ~ /^[0-9a-f:]+$/ {print $1}'" }
24
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ property[:os] = nil
4
+ set :os, :family => 'openbsd'
5
+
6
+ describe get_command(:check_host_is_reachable, 'pink.unicorn.com', nil, 'tcp', 10) do
7
+ it { should eq "ping -w 10 -c 2 -n pink.unicorn.com"}
8
+ end
9
+
10
+ describe get_command(:check_host_is_reachable, 'pink.unicorn.com', 53, 'udp', 66) do
11
+ it { should eq "nc -w 66 -vvvvzu pink.unicorn.com 53" }
12
+ end
13
+
14
+ describe get_command(:get_host_ipaddress, 'pink.unicorn.com') do
15
+ it { should eq "getent hosts pink.unicorn.com | awk '{print $1; exit}'" }
16
+ end
17
+
18
+ describe get_command(:get_host_ipv4_address, 'pink.unicorn.com') do
19
+ it { should eq "getent hosts pink.unicorn.com | awk '$1 ~ /^[0-9.]+$/ {print $1}'" }
20
+ end
21
+
22
+ describe get_command(:get_host_ipv6_address, 'pink.unicorn.com') do
23
+ it { should eq "getent hosts pink.unicorn.com | awk 'tolower($1) ~ /^[0-9a-f:]+$/ {print $1}'" }
24
+ end
@@ -11,3 +11,15 @@ end
11
11
  describe get_command(:check_host_is_reachable, 'example.jp', '80', 'tcp', 3) do
12
12
  it { should eq "ncat -vvvvt example.jp 80 -w 3 -i 3 2>&1 | grep -q SUCCESS" }
13
13
  end
14
+
15
+ describe get_command(:get_host_ipaddress, 'pink.unicorn.com') do
16
+ it { should eq "getent hosts pink.unicorn.com | awk '{print $1}'" }
17
+ end
18
+
19
+ describe get_command(:get_host_ipv4_address, 'pink.unicorn.com') do
20
+ it { should eq "getent ahostsv4 pink.unicorn.com | awk '{print $1; exit}'" }
21
+ end
22
+
23
+ describe get_command(:get_host_ipv6_address, 'pink.unicorn.com') do
24
+ it { should eq "getent ahostsv6 pink.unicorn.com | awk '{print $1; exit}'" }
25
+ 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.41.1
4
+ version: 2.42.0
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-17 00:00:00.000000000 Z
11
+ date: 2015-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-scp
@@ -310,6 +310,7 @@ files:
310
310
  - lib/specinfra/command/openbsd/base/bridge.rb
311
311
  - lib/specinfra/command/openbsd/base/file.rb
312
312
  - lib/specinfra/command/openbsd/base/fstab.rb
313
+ - lib/specinfra/command/openbsd/base/host.rb
313
314
  - lib/specinfra/command/openbsd/base/interface.rb
314
315
  - lib/specinfra/command/openbsd/base/inventory.rb
315
316
  - lib/specinfra/command/openbsd/base/mail_alias.rb
@@ -458,6 +459,7 @@ files:
458
459
  - spec/command/amazon/service_spec.rb
459
460
  - spec/command/base/file_spec.rb
460
461
  - spec/command/base/group_spec.rb
462
+ - spec/command/base/host_spec.rb
461
463
  - spec/command/base/localhost_spec.rb
462
464
  - spec/command/base/package_spec.rb
463
465
  - spec/command/base/user_spec.rb
@@ -467,6 +469,7 @@ files:
467
469
  - spec/command/esxi/package_spec.rb
468
470
  - spec/command/factory_spec.rb
469
471
  - spec/command/freebsd/file_spec.rb
472
+ - spec/command/freebsd/host_spec.rb
470
473
  - spec/command/freebsd/interface_spec.rb
471
474
  - spec/command/linux/bond_spec.rb
472
475
  - spec/command/linux/bridge_spec.rb
@@ -483,6 +486,7 @@ files:
483
486
  - spec/command/module/systemd_spec.rb
484
487
  - spec/command/module/zfs_spec.rb
485
488
  - spec/command/openbsd/file_spec.rb
489
+ - spec/command/openbsd/host_spec.rb
486
490
  - spec/command/openbsd/interface_spec.rb
487
491
  - spec/command/redhat/package_spec.rb
488
492
  - spec/command/redhat/service_spec.rb
@@ -550,6 +554,7 @@ test_files:
550
554
  - spec/command/amazon/service_spec.rb
551
555
  - spec/command/base/file_spec.rb
552
556
  - spec/command/base/group_spec.rb
557
+ - spec/command/base/host_spec.rb
553
558
  - spec/command/base/localhost_spec.rb
554
559
  - spec/command/base/package_spec.rb
555
560
  - spec/command/base/user_spec.rb
@@ -559,6 +564,7 @@ test_files:
559
564
  - spec/command/esxi/package_spec.rb
560
565
  - spec/command/factory_spec.rb
561
566
  - spec/command/freebsd/file_spec.rb
567
+ - spec/command/freebsd/host_spec.rb
562
568
  - spec/command/freebsd/interface_spec.rb
563
569
  - spec/command/linux/bond_spec.rb
564
570
  - spec/command/linux/bridge_spec.rb
@@ -575,6 +581,7 @@ test_files:
575
581
  - spec/command/module/systemd_spec.rb
576
582
  - spec/command/module/zfs_spec.rb
577
583
  - spec/command/openbsd/file_spec.rb
584
+ - spec/command/openbsd/host_spec.rb
578
585
  - spec/command/openbsd/interface_spec.rb
579
586
  - spec/command/redhat/package_spec.rb
580
587
  - spec/command/redhat/service_spec.rb
@@ -605,4 +612,3 @@ test_files:
605
612
  - spec/host_inventory/openbsd/filesystem_spec.rb
606
613
  - spec/host_inventory/solaris/filesystem_spec.rb
607
614
  - spec/spec_helper.rb
608
- has_rdoc: