specinfra 2.42.1 → 2.42.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/specinfra/command.rb +2 -0
- data/lib/specinfra/command/darwin/base/host.rb +1 -1
- data/lib/specinfra/command/darwin/base/interface.rb +42 -0
- data/lib/specinfra/command/darwin/base/process.rb +7 -0
- data/lib/specinfra/command/ubuntu/base/ppa.rb +2 -2
- data/lib/specinfra/version.rb +1 -1
- data/spec/backend/exec/build_command_spec.rb +4 -0
- data/spec/command/darwin/host_spec.rb +1 -1
- data/spec/command/darwin/interface_spec.rb +38 -0
- data/spec/command/darwin/process_spec.rb +7 -0
- data/spec/command/ubuntu/ppa_spec.rb +2 -2
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ea31c3d4e34d354e605356de9b60c1775c637e9
|
4
|
+
data.tar.gz: c3f7cd796806023a44a23d1deb6ab105aecb2377
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68ebe02f33132a5862ec46f503ab75748415ec423f7261e234e7901ad6481c77496ff550634cf0eedcd19fe68153d5727a3adafa7c0ea8cac582470682051259
|
7
|
+
data.tar.gz: 2c5c00f86f0020a6c69241aaa79cd5e37ce6d91887ad8eed33e8eda45f120f0cbba7ac0f3f81bb3122940cdef0370fab68b3f87e15ab32e6c9d1f22f3ccaa5c6
|
data/lib/specinfra/command.rb
CHANGED
@@ -144,10 +144,12 @@ require 'specinfra/command/darwin'
|
|
144
144
|
require 'specinfra/command/darwin/base'
|
145
145
|
require 'specinfra/command/darwin/base/file'
|
146
146
|
require 'specinfra/command/darwin/base/host'
|
147
|
+
require 'specinfra/command/darwin/base/interface'
|
147
148
|
require 'specinfra/command/darwin/base/inventory'
|
148
149
|
require 'specinfra/command/darwin/base/service'
|
149
150
|
require 'specinfra/command/darwin/base/package'
|
150
151
|
require 'specinfra/command/darwin/base/port'
|
152
|
+
require 'specinfra/command/darwin/base/process'
|
151
153
|
require 'specinfra/command/darwin/base/user'
|
152
154
|
|
153
155
|
# Debian (inherit Linux)
|
@@ -3,7 +3,7 @@ class Specinfra::Command::Darwin::Base::Host < Specinfra::Command::Base::Host
|
|
3
3
|
def check_is_resolvable(name, type)
|
4
4
|
if type == "dns"
|
5
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:.]*$'}
|
6
|
+
%Q{dig +search +short +time=1 -q #{escape(name)} a #{escape(name)} aaaa | grep -qie '^[0-9a-f:.]*$'}
|
7
7
|
elsif type == "hosts"
|
8
8
|
"sed 's/#.*$//' /etc/hosts | grep -w -- #{escape(name)}"
|
9
9
|
else
|
@@ -0,0 +1,42 @@
|
|
1
|
+
class Specinfra::Command::Darwin::Base::Interface < Specinfra::Command::Base::Interface
|
2
|
+
class << self
|
3
|
+
def check_exists(name)
|
4
|
+
"ifconfig #{name}"
|
5
|
+
end
|
6
|
+
|
7
|
+
def check_has_ipv4_address(interface, ip_address)
|
8
|
+
ip_address = ip_address.dup
|
9
|
+
if ip_address =~ /\/\d+$/
|
10
|
+
# remove the prefix - better would be to calculate the netmask
|
11
|
+
ip_address.gsub!(/\/\d+$/, "")
|
12
|
+
end
|
13
|
+
ip_address << " "
|
14
|
+
ip_address.gsub!(".", "\\.")
|
15
|
+
"ifconfig #{interface} inet | grep 'inet #{ip_address}'"
|
16
|
+
end
|
17
|
+
|
18
|
+
def check_has_ipv6_address(interface, ip_address)
|
19
|
+
ip_address = ip_address.dup
|
20
|
+
(ip_address, prefixlen) = ip_address.split(/\//)
|
21
|
+
ip_address.downcase!
|
22
|
+
if ip_address =~ /^fe80::/i
|
23
|
+
# link local needs the scope (interface) appended
|
24
|
+
ip_address << "%#{interface}"
|
25
|
+
end
|
26
|
+
unless prefixlen.to_s.empty?
|
27
|
+
# append prefixlen
|
28
|
+
ip_address << " prefixlen #{prefixlen}"
|
29
|
+
else
|
30
|
+
ip_address << " "
|
31
|
+
end
|
32
|
+
"ifconfig #{interface} inet6 | grep 'inet6 #{ip_address}'"
|
33
|
+
end
|
34
|
+
|
35
|
+
def get_link_state(interface)
|
36
|
+
# Checks if interfaces is administratively up with the -u arg.
|
37
|
+
# L1 check via status. Virtual interfaces like tapX missing the status will report up.
|
38
|
+
# Emulates operstate in linux with exception of the unknown status.
|
39
|
+
%Q{ifconfig -u #{interface} 2>&1 | awk -v s=up '/status:/ && $2 != "active" { s="down" }; END {print s}'}
|
40
|
+
end
|
41
|
+
end
|
42
|
+
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 +[
|
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 +[
|
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
|
data/lib/specinfra/version.rb
CHANGED
@@ -12,6 +12,10 @@ describe Specinfra::Backend::Exec do
|
|
12
12
|
it 'should escape special chars' do
|
13
13
|
expect(Specinfra.backend.build_command('test ! -f /etc/selinux/config || (getenforce | grep -i -- disabled && grep -i -- ^SELINUX=disabled$ /etc/selinux/config)')).to eq '/bin/sh -c test\ \!\ -f\ /etc/selinux/config\ \|\|\ \(getenforce\ \|\ grep\ -i\ --\ disabled\ \&\&\ grep\ -i\ --\ \^SELINUX\=disabled\$\ /etc/selinux/config\)'
|
14
14
|
end
|
15
|
+
|
16
|
+
it 'should escape quotes' do
|
17
|
+
expect(Specinfra.backend.build_command(%Q{find /etc/apt/ -name \*.list | xargs grep -o -E "^deb +[\\"']?http://ppa.launchpad.net/gluster/glusterfs-3.7"})).to eq('/bin/sh -c find\ /etc/apt/\ -name\ \*.list\ \|\ xargs\ grep\ -o\ -E\ \"\^deb\ \+\[\\\\\"\\\'\]\?http://ppa.launchpad.net/gluster/glusterfs-3.7\"')
|
18
|
+
end
|
15
19
|
end
|
16
20
|
|
17
21
|
context 'with custom shell' do
|
@@ -4,7 +4,7 @@ property[:os] = nil
|
|
4
4
|
set :os, :family => 'darwin'
|
5
5
|
|
6
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:.]*$'" }
|
7
|
+
it { should eq "dig +search +short +time=1 -q pink.unicorn.com a pink.unicorn.com aaaa | grep -qie '^[0-9a-f:.]*$'" }
|
8
8
|
end
|
9
9
|
|
10
10
|
describe get_command(:check_host_is_resolvable, 'pink.unicorn.com', 'hosts') do
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
property[:os] = nil
|
4
|
+
set :os, :family => 'darwin'
|
5
|
+
|
6
|
+
|
7
|
+
describe get_command(:check_interface_exists, 'en0') do
|
8
|
+
it { should eq "ifconfig en0" }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe get_command(:check_interface_has_ipv6_address, 'en0', '2001:0db8:bd05:01d2:288a:1fc0:0001:10ee') do
|
12
|
+
it { should eq "ifconfig en0 inet6 | grep 'inet6 2001:0db8:bd05:01d2:288a:1fc0:0001:10ee '" }
|
13
|
+
end
|
14
|
+
|
15
|
+
describe get_command(:check_interface_has_ipv6_address, 'en0', '2001:0db8:bd05:01d2:288a:1fc0:0001:10ee/64') do
|
16
|
+
it { should eq "ifconfig en0 inet6 | grep 'inet6 2001:0db8:bd05:01d2:288a:1fc0:0001:10ee prefixlen 64'" }
|
17
|
+
end
|
18
|
+
|
19
|
+
describe get_command(:check_interface_has_ipv6_address, 'en0', 'fe80::5054:ff:fe01:10ee/64') do
|
20
|
+
it { should eq "ifconfig en0 inet6 | grep 'inet6 fe80::5054:ff:fe01:10ee%en0 prefixlen 64'" }
|
21
|
+
end
|
22
|
+
|
23
|
+
describe get_command(:check_interface_has_ipv6_address, 'en0', 'fe80::5054:ff:fe01:10ee') do
|
24
|
+
it { should eq "ifconfig en0 inet6 | grep 'inet6 fe80::5054:ff:fe01:10ee%en0 '" }
|
25
|
+
end
|
26
|
+
|
27
|
+
describe get_command(:check_interface_has_ipv4_address, 'en0', '192.168.0.123') do
|
28
|
+
it { should eq "ifconfig en0 inet | grep 'inet 192\\.168\\.0\\.123 '" }
|
29
|
+
end
|
30
|
+
|
31
|
+
describe get_command(:check_interface_has_ipv4_address, 'en0', '192.168.0.123/24') do
|
32
|
+
it { should eq "ifconfig en0 inet | grep 'inet 192\\.168\\.0\\.123 '" }
|
33
|
+
end
|
34
|
+
|
35
|
+
describe get_command(:get_interface_link_state, 'en0') do
|
36
|
+
it { should eq %Q{ifconfig -u en0 2>&1 | awk -v s=up '/status:/ && $2 != "active" { s="down" }; END {print s}'} }
|
37
|
+
end
|
38
|
+
|
@@ -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.
|
4
|
+
version: 2.42.2
|
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-
|
11
|
+
date: 2015-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-scp
|
@@ -229,9 +229,11 @@ files:
|
|
229
229
|
- lib/specinfra/command/darwin/base.rb
|
230
230
|
- lib/specinfra/command/darwin/base/file.rb
|
231
231
|
- lib/specinfra/command/darwin/base/host.rb
|
232
|
+
- lib/specinfra/command/darwin/base/interface.rb
|
232
233
|
- lib/specinfra/command/darwin/base/inventory.rb
|
233
234
|
- lib/specinfra/command/darwin/base/package.rb
|
234
235
|
- lib/specinfra/command/darwin/base/port.rb
|
236
|
+
- lib/specinfra/command/darwin/base/process.rb
|
235
237
|
- lib/specinfra/command/darwin/base/service.rb
|
236
238
|
- lib/specinfra/command/darwin/base/user.rb
|
237
239
|
- lib/specinfra/command/debian.rb
|
@@ -467,6 +469,8 @@ files:
|
|
467
469
|
- spec/command/base/user_spec.rb
|
468
470
|
- spec/command/darwin/file_spec.rb
|
469
471
|
- spec/command/darwin/host_spec.rb
|
472
|
+
- spec/command/darwin/interface_spec.rb
|
473
|
+
- spec/command/darwin/process_spec.rb
|
470
474
|
- spec/command/darwin/user_spec.rb
|
471
475
|
- spec/command/debian/service_spec.rb
|
472
476
|
- spec/command/esxi/package_spec.rb
|
@@ -565,6 +569,8 @@ test_files:
|
|
565
569
|
- spec/command/base/user_spec.rb
|
566
570
|
- spec/command/darwin/file_spec.rb
|
567
571
|
- spec/command/darwin/host_spec.rb
|
572
|
+
- spec/command/darwin/interface_spec.rb
|
573
|
+
- spec/command/darwin/process_spec.rb
|
568
574
|
- spec/command/darwin/user_spec.rb
|
569
575
|
- spec/command/debian/service_spec.rb
|
570
576
|
- spec/command/esxi/package_spec.rb
|
@@ -620,4 +626,3 @@ test_files:
|
|
620
626
|
- spec/host_inventory/openbsd/filesystem_spec.rb
|
621
627
|
- spec/host_inventory/solaris/filesystem_spec.rb
|
622
628
|
- spec/spec_helper.rb
|
623
|
-
has_rdoc:
|