summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Hain <shain@chef.io>2017-12-12 15:39:49 -0800
committerGitHub <noreply@github.com>2017-12-12 15:39:49 -0800
commit7504d1d47f30ca78bcdfb8d75fcd6eabb5780277 (patch)
tree15dd9bbf6bb7cc65268c6b7a96544f066f631b09
parent7938b1d6fc634ab7daafe017853aca299ebe936b (diff)
parent1f886e1bb908587bdd7176cb5e9fe2c90120cb9b (diff)
downloadchef-7504d1d47f30ca78bcdfb8d75fcd6eabb5780277.tar.gz
Merge pull request #6659 from chef/shain/backport_test_fixes
Backport RHEL and ifconfig test fixes
-rw-r--r--.travis.yml8
-rw-r--r--Gemfile.lock200
-rw-r--r--appveyor.yml3
-rw-r--r--chef-config/spec/unit/fips_spec.rb6
-rw-r--r--lib/chef/provider/ifconfig.rb112
-rw-r--r--spec/functional/resource/ifconfig_spec.rb2
-rw-r--r--spec/functional/resource/mount_spec.rb10
-rw-r--r--spec/unit/provider/ifconfig_spec.rb11
-rw-r--r--tasks/bundle_util.rb2
9 files changed, 215 insertions, 139 deletions
diff --git a/.travis.yml b/.travis.yml
index 179d0e9d46..9bfc173a77 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -62,10 +62,6 @@ matrix:
script: tasks/bin/run_external_test $TEST_GEM rake spec
rvm: 2.3.5
- env:
- TEST_GEM: chef-sugar
- script: tasks/bin/run_external_test $TEST_GEM rake
- rvm: 2.3.5
- - env:
TEST_GEM: cheffish
script: tasks/bin/run_external_test $TEST_GEM rake spec
rvm: 2.3.5
@@ -80,10 +76,6 @@ matrix:
script: tasks/bin/run_external_test $TEST_GEM rake
rvm: 2.3.5
- env:
- TEST_GEM: foodcritic
- script: tasks/bin/run_external_test $TEST_GEM rake test
- rvm: 2.3.5
- - env:
TEST_GEM: knife-windows
script: tasks/bin/run_external_test $TEST_GEM rake unit_spec
rvm: 2.3.5
diff --git a/Gemfile.lock b/Gemfile.lock
index 8146c2eda3..7daba8ebd6 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,6 +1,6 @@
GIT
remote: https://github.com/chef/chef-server
- revision: 53b28425d56005a92b0e3bb153f95b505168354a
+ revision: e9de61e1d55e4a7fc0bc1a1628d38691c2bec387
specs:
oc-chef-pedant (2.2.0)
activesupport (>= 4.2.7.1, < 6.0)
@@ -29,9 +29,9 @@ GIT
GIT
remote: https://github.com/rubysec/bundler-audit.git
- revision: 6eb5a81e9b184fbb8db03f3e57dc758c65dd7383
+ revision: 06e6077aaaed3744915b1dda71effeea2ea41751
specs:
- bundler-audit (0.5.0)
+ bundler-audit (0.6.0)
bundler (~> 1.2)
thor (~> 0.18)
@@ -120,7 +120,7 @@ PATH
GEM
remote: https://rubygems.org/
specs:
- activesupport (5.1.1)
+ activesupport (5.1.4)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
minitest (~> 5.1)
@@ -128,36 +128,35 @@ GEM
addressable (2.4.0)
appbundler (0.10.0)
mixlib-cli (~> 1.4)
- artifactory (2.8.2)
ast (2.3.0)
awesome_print (1.8.0)
- aws-sdk (2.9.43)
- aws-sdk-resources (= 2.9.43)
- aws-sdk-core (2.9.43)
+ aws-sdk (2.10.101)
+ aws-sdk-resources (= 2.10.101)
+ aws-sdk-core (2.10.101)
aws-sigv4 (~> 1.0)
jmespath (~> 1.0)
- aws-sdk-resources (2.9.43)
- aws-sdk-core (= 2.9.43)
- aws-sigv4 (1.0.0)
- backports (3.8.0)
- binding_of_caller (0.7.2)
+ aws-sdk-resources (2.10.101)
+ aws-sdk-core (= 2.10.101)
+ aws-sigv4 (1.0.2)
+ backports (3.10.3)
+ binding_of_caller (0.7.3)
debug_inspector (>= 0.0.1)
builder (3.2.3)
- byebug (9.0.6)
- chef-api (0.7.0)
+ byebug (9.1.0)
+ chef-api (0.7.1)
logify (~> 0.1)
mime-types
- chef-provisioning (2.3.2)
+ chef-provisioning (2.6.0)
cheffish (>= 4.0, < 14.0)
inifile (>= 2.0.2)
- mixlib-install (>= 1.0, < 3.0)
+ mixlib-install (>= 1.0)
net-scp (~> 1.0)
net-ssh (>= 2.9, < 5.0)
- net-ssh-gateway (~> 1.2)
+ net-ssh-gateway (> 1.2, < 3.0)
winrm (~> 2.0)
winrm-elevated (~> 1.0)
winrm-fs (~> 1.0)
- chef-sugar (3.4.0)
+ chef-sugar (3.6.0)
chef-zero (5.3.2)
ffi-yajl (~> 2.2)
hashie (>= 2.0, < 4.0)
@@ -167,7 +166,7 @@ GEM
cheffish (5.0.1)
chef-zero (~> 5.0)
net-ssh
- chefspec (7.1.0)
+ chefspec (7.1.1)
chef (>= 12.14.89)
fauxhai (>= 4, < 6)
rspec (~> 3.0)
@@ -179,18 +178,23 @@ GEM
json
simplecov
url
- coderay (1.1.1)
+ coderay (1.1.2)
concurrent-ruby (1.0.5)
- cucumber (2.4.0)
+ cucumber (3.1.0)
builder (>= 2.1.2)
- cucumber-core (~> 1.5.0)
+ cucumber-core (~> 3.1.0)
+ cucumber-expressions (~> 5.0.4)
cucumber-wire (~> 0.0.1)
- diff-lcs (>= 1.1.3)
- gherkin (~> 4.0)
+ diff-lcs (~> 1.3)
+ gherkin (~> 5.0)
multi_json (>= 1.7.5, < 2.0)
multi_test (>= 0.1.2)
- cucumber-core (1.5.0)
- gherkin (~> 4.0)
+ cucumber-core (3.1.0)
+ backports (>= 3.8.0)
+ cucumber-tag_expressions (~> 1.1.0)
+ gherkin (>= 5.0.0)
+ cucumber-expressions (5.0.7)
+ cucumber-tag_expressions (1.1.1)
cucumber-wire (0.0.1)
debug_inspector (0.0.3)
diff-lcs (1.3)
@@ -198,31 +202,32 @@ GEM
domain_name (0.5.20170404)
unf (>= 0.0.5, < 1.0.0)
erubis (2.7.0)
- ethon (0.10.1)
+ ethon (0.11.0)
ffi (>= 1.3.0)
- excon (0.57.0)
- faraday (0.12.1)
+ excon (0.59.0)
+ faraday (0.13.1)
multipart-post (>= 1.2, < 3)
faraday-http-cache (2.0.0)
faraday (~> 0.8)
- faraday_middleware (0.11.0.1)
+ faraday_middleware (0.12.2)
faraday (>= 0.7.4, < 1.0)
- fauxhai (5.0.0)
+ fauxhai (5.5.0)
net-ssh
ffi (1.9.18)
+ ffi (1.9.18-x64-mingw32)
ffi (1.9.18-x86-mingw32)
ffi-win32-extensions (1.0.3)
ffi
- ffi-yajl (2.3.0)
+ ffi-yajl (2.3.1)
libyajl2 (~> 1.2)
- foodcritic (11.2.0)
+ foodcritic (11.4.0)
cucumber-core (>= 1.3)
erubis
+ ffi-yajl (~> 2.0)
nokogiri (>= 1.5, < 2.0)
rake
rufus-lru (~> 1.0)
treetop (~> 1.4)
- yajl-ruby (~> 1.1)
fuubar (2.2.0)
rspec-core (~> 3.0)
ruby-progressbar (~> 1.4)
@@ -234,32 +239,33 @@ GEM
multi_json (~> 1.0)
net-http-persistent (~> 2.9)
net-http-pipeline
- gherkin (4.1.3)
+ gherkin (5.0.0)
git (1.3.0)
gssapi (1.2.0)
ffi (>= 1.0.1)
gyoku (1.3.1)
builder (>= 2.1.2)
- halite (1.7.0)
+ halite (1.8.0)
bundler
chef (>= 12.0, < 14.0)
stove (~> 5.0)
thor
- hashie (3.5.5)
- highline (1.7.8)
+ hashie (3.5.6)
+ highline (1.7.10)
hirb (0.7.3)
http-cookie (1.0.3)
domain_name (~> 0.5)
httpclient (2.8.3)
- i18n (0.8.4)
+ i18n (0.9.1)
+ concurrent-ruby (~> 1.0)
inifile (3.0.0)
- iniparse (1.4.3)
+ iniparse (1.4.4)
ipaddress (0.8.3)
jmespath (1.3.1)
json (2.1.0)
kitchen-docker (2.6.0)
test-kitchen (>= 1.0.0)
- kitchen-ec2 (1.3.2)
+ kitchen-ec2 (1.4.0)
aws-sdk (~> 2)
excon
multi_json
@@ -268,7 +274,7 @@ GEM
kitchen-sync (2.2.0)
net-sftp
test-kitchen (>= 1.0.0)
- kitchen-vagrant (1.1.0)
+ kitchen-vagrant (1.2.1)
test-kitchen (~> 1.4)
knife-windows (1.9.0)
winrm (~> 2.1)
@@ -281,30 +287,28 @@ GEM
little-plugger (~> 1.1)
multi_json (~> 1.10)
logify (0.2.0)
- method_source (0.8.2)
+ method_source (0.9.0)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_portile2 (2.1.0)
- minitest (5.10.2)
+ minitest (5.10.3)
mixlib-archive (0.4.1)
mixlib-log
- mixlib-authentication (1.4.1)
- mixlib-log
+ mixlib-authentication (1.4.2)
mixlib-cli (1.7.0)
mixlib-config (2.2.4)
- mixlib-install (2.1.12)
- artifactory
+ mixlib-install (3.8.0)
mixlib-shellout
mixlib-versioning
thor
mixlib-log (1.7.1)
- mixlib-shellout (2.2.7)
- mixlib-shellout (2.2.7-universal-mingw32)
+ mixlib-shellout (2.3.2)
+ mixlib-shellout (2.3.2-universal-mingw32)
win32-process (~> 0.8.2)
wmi-lite (~> 1.0)
- mixlib-versioning (1.1.0)
- multi_json (1.12.1)
+ mixlib-versioning (1.2.2)
+ multi_json (1.12.2)
multi_test (0.1.2)
multipart-post (2.0.0)
net-http-persistent (2.9.4)
@@ -314,7 +318,7 @@ GEM
net-ssh (>= 2.6.5)
net-sftp (2.1.2)
net-ssh (>= 2.6.5)
- net-ssh (4.1.0)
+ net-ssh (4.2.0)
net-ssh-gateway (1.3.0)
net-ssh (>= 2.6.5)
net-ssh-multi (1.2.1)
@@ -324,12 +328,14 @@ GEM
netrc (0.11.0)
nokogiri (1.7.2)
mini_portile2 (~> 2.1.0)
+ nokogiri (1.7.2-x64-mingw32)
+ mini_portile2 (~> 2.1.0)
nokogiri (1.7.2-x86-mingw32)
mini_portile2 (~> 2.1.0)
nori (2.6.0)
octokit (4.7.0)
sawyer (~> 0.8.0, >= 0.5.3)
- ohai (8.25.0)
+ ohai (8.25.1)
chef-config (>= 12.5.0.alpha.1, < 14)
ffi (~> 1.9)
ffi-yajl (~> 2.2)
@@ -341,14 +347,14 @@ GEM
plist (~> 3.1)
systemu (~> 2.6.4)
wmi-lite (~> 1.0)
- paint (2.0.0)
- parser (2.4.0.0)
- ast (~> 2.2)
- plist (3.3.0)
+ paint (2.0.1)
+ parser (2.4.0.2)
+ ast (~> 2.3)
+ plist (3.4.0)
poise (2.8.1)
chef (>= 12, < 14)
halite (~> 1.0)
- poise-boiler (1.16.0)
+ poise-boiler (1.18.0)
awesome_print
bundler
chefspec (>= 5, < 8)
@@ -384,12 +390,11 @@ GEM
polyglot (0.3.5)
powerpack (0.1.1)
proxifier (1.0.3)
- pry (0.10.4)
+ pry (0.11.3)
coderay (~> 1.1.0)
- method_source (~> 0.8.1)
- slop (~> 3.4)
- pry-byebug (3.4.2)
- byebug (~> 9.0)
+ method_source (~> 0.9.0)
+ pry-byebug (3.5.1)
+ byebug (~> 9.1)
pry (~> 0.10)
pry-remote (0.1.8)
pry (~> 0.9)
@@ -403,37 +408,42 @@ GEM
rack (2.0.3)
rainbow (2.2.2)
rake
- rake (12.0.0)
+ rake (12.3.0)
rb-readline (0.5.5)
rest-client (2.0.2)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
+ rest-client (2.0.2-x64-mingw32)
+ ffi (~> 1.9)
+ http-cookie (>= 1.0.2, < 2.0)
+ mime-types (>= 1.16, < 4.0)
+ netrc (~> 0.8)
rest-client (2.0.2-x86-mingw32)
ffi (~> 1.9)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
- retriable (3.0.2)
+ retriable (3.1.1)
retryable (2.0.4)
- rspec (3.6.0)
- rspec-core (~> 3.6.0)
- rspec-expectations (~> 3.6.0)
- rspec-mocks (~> 3.6.0)
- rspec-core (3.6.0)
- rspec-support (~> 3.6.0)
- rspec-expectations (3.6.0)
+ rspec (3.7.0)
+ rspec-core (~> 3.7.0)
+ rspec-expectations (~> 3.7.0)
+ rspec-mocks (~> 3.7.0)
+ rspec-core (3.7.0)
+ rspec-support (~> 3.7.0)
+ rspec-expectations (3.7.0)
diff-lcs (>= 1.2.0, < 2.0)
- rspec-support (~> 3.6.0)
+ rspec-support (~> 3.7.0)
rspec-its (1.2.0)
rspec-core (>= 3.0.0)
rspec-expectations (>= 3.0.0)
- rspec-mocks (3.6.0)
+ rspec-mocks (3.7.0)
diff-lcs (>= 1.2.0, < 2.0)
- rspec-support (~> 3.6.0)
+ rspec-support (~> 3.7.0)
rspec-rerun (1.1.0)
rspec (~> 3.0)
- rspec-support (3.6.0)
+ rspec-support (3.7.0)
rspec_junit_formatter (0.2.3)
builder (< 4)
rspec-core (>= 2, < 4, != 2.12.0)
@@ -444,7 +454,7 @@ GEM
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-prof (0.16.2)
- ruby-progressbar (1.8.1)
+ ruby-progressbar (1.9.0)
ruby-shadow (2.5.0)
rubyntlm (0.6.2)
rubyzip (1.2.1)
@@ -453,19 +463,19 @@ GEM
sawyer (0.8.1)
addressable (>= 2.3.5, < 2.6)
faraday (~> 0.8, < 1.0)
- serverspec (2.39.1)
+ serverspec (2.41.3)
multi_json
rspec (~> 3.0)
rspec-its
- specinfra (~> 2.68)
+ specinfra (~> 2.72)
sfl (2.3)
simplecov (0.13.0)
docile (~> 1.1.0)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
- simplecov-html (0.10.1)
+ simplecov-html (0.10.2)
slop (3.6.0)
- specinfra (2.68.0)
+ specinfra (2.72.1)
net-scp
net-ssh (>= 2.7, < 5.0)
net-telnet
@@ -475,17 +485,20 @@ GEM
logify (~> 0.2)
syslog-logger (1.6.8)
systemu (2.6.5)
- test-kitchen (1.16.0)
- mixlib-install (>= 1.2, < 3.0)
+ test-kitchen (1.19.2)
+ mixlib-install (~> 3.6)
mixlib-shellout (>= 1.2, < 3.0)
net-scp (~> 1.1)
net-ssh (>= 2.9, < 5.0)
net-ssh-gateway (~> 1.2)
safe_yaml (~> 1.0)
thor (~> 0.19, < 0.19.2)
+ winrm (~> 2.0)
+ winrm-elevated (~> 1.0)
+ winrm-fs (~> 1.1.0)
thor (0.19.1)
thread_safe (0.3.6)
- tomlrb (1.2.4)
+ tomlrb (1.2.6)
travis (1.8.8)
backports
faraday (~> 0.9)
@@ -495,21 +508,22 @@ GEM
launchy (~> 2.1)
pusher-client (~> 0.4)
typhoeus (~> 0.6, >= 0.6.8)
- treetop (1.6.8)
+ treetop (1.6.9)
polyglot (~> 0.3)
typhoeus (0.8.0)
ethon (>= 0.8.0)
- tzinfo (1.2.3)
+ tzinfo (1.2.4)
thread_safe (~> 0.1)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.4)
+ unf_ext (0.0.7.4-x64-mingw32)
unf_ext (0.0.7.4-x86-mingw32)
unicode-display_width (1.3.0)
url (0.3.2)
uuidtools (2.1.5)
vagrant-wrapper (2.0.3)
- websocket (1.2.4)
+ websocket (1.2.5)
win32-api (1.5.3-universal-mingw32)
win32-dir (0.5.1)
ffi (>= 1.0.0)
@@ -542,21 +556,21 @@ GEM
winrm-elevated (1.1.0)
winrm (~> 2.0)
winrm-fs (~> 1.0)
- winrm-fs (1.0.1)
+ winrm-fs (1.1.1)
erubis (~> 2.7)
logging (>= 1.6.1, < 3.0)
rubyzip (~> 1.1)
winrm (~> 2.0)
- wirb (2.1.1)
+ wirb (2.1.2)
paint (>= 0.9, < 3.0)
wmi-lite (1.0.0)
- yajl-ruby (1.3.0)
- yard (0.9.9)
+ yard (0.9.12)
yard-classmethods (1.0.0)
yard
PLATFORMS
ruby
+ x64-mingw32
x86-mingw32
DEPENDENCIES
diff --git a/appveyor.yml b/appveyor.yml
index 563dde4add..7517480679 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -28,10 +28,7 @@ install:
- echo %OMNIBUS_BUNDLER%
- ruby --version
- gem --version
- - bundler --version
- - gem uninstall bundler -a -x
- gem update --system %OMNIBUS_RUBYGEMS% || gem update --system %OMNIBUS_RUBYGEMS% || gem update --system %OMNIBUS_RUBYGEMS%
- - gem install bundler -v %OMNIBUS_BUNDLER% --quiet --no-ri --no-rdoc || gem install bundler -v %OMNIBUS_BUNDLER% --quiet --no-ri --no-rdoc || gem install bundler -v %OMNIBUS_BUNDLER% --quiet --no-ri --no-rdoc
- gem --version
- bundler --version
- SET BUNDLE_IGNORE_CONFIG=true
diff --git a/chef-config/spec/unit/fips_spec.rb b/chef-config/spec/unit/fips_spec.rb
index cf5af22ef1..b4e230e3d4 100644
--- a/chef-config/spec/unit/fips_spec.rb
+++ b/chef-config/spec/unit/fips_spec.rb
@@ -19,6 +19,12 @@
require "chef-config/fips"
require "spec_helper"
+begin
+ require "win32/registry"
+rescue LoadError
+ # not on unix
+end
+
RSpec.describe "ChefConfig.fips?" do
let(:enabled) { "0" }
diff --git a/lib/chef/provider/ifconfig.rb b/lib/chef/provider/ifconfig.rb
index 4f32baaadb..dc1d0c3e09 100644
--- a/lib/chef/provider/ifconfig.rb
+++ b/lib/chef/provider/ifconfig.rb
@@ -63,30 +63,98 @@ class Chef
@ifconfig_success = true
@interfaces = {}
- @status = shell_out("ifconfig")
- @status.stdout.each_line do |line|
- if !line[0..9].strip.empty?
- @int_name = line[0..9].strip
- @interfaces[@int_name] = { "hwaddr" => (line =~ /(HWaddr)/ ? ($') : "nil").strip.chomp }
- else
- @interfaces[@int_name]["inet_addr"] = (line =~ /inet addr:(\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /inet addr:/
- @interfaces[@int_name]["bcast"] = (line =~ /Bcast:(\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /Bcast:/
- @interfaces[@int_name]["mask"] = (line =~ /Mask:(\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /Mask:/
- @interfaces[@int_name]["mtu"] = (line =~ /MTU:(\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /MTU:/
- @interfaces[@int_name]["metric"] = (line =~ /Metric:(\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /Metric:/
+ @ifconfig_version = nil
+
+ @net_tools_version = shell_out("ifconfig --version")
+ @net_tools_version.stderr.each_line do |line|
+ if line =~ /^net-tools (\d+.\d+)/
+ @ifconfig_version = line.match(/^net-tools (\d+.\d+)/)[1]
+ end
+ end
+
+ if @ifconfig_version.nil?
+ raise "net-tools not found - this is required for ifconfig"
+ elsif @ifconfig_version.to_f < 2.0
+ # Example output for 1.60 is as follows: (sanitized but format intact)
+ # eth0 Link encap:Ethernet HWaddr 00:00:00:00:00:00
+ # inet addr:192.168.1.1 Bcast:192.168.0.1 Mask:255.255.248.0
+ # inet6 addr: 0000::00:0000:0000:0000/64 Scope:Link
+ # UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
+ # RX packets:65158911 errors:0 dropped:0 overruns:0 frame:0
+ # TX packets:41723949 errors:0 dropped:0 overruns:0 carrier:0
+ # collisions:0 txqueuelen:1000
+ # RX bytes:42664658792 (39.7 GiB) TX bytes:52722603938 (49.1 GiB)
+ # Interrupt:30
+ @status = shell_out("ifconfig")
+ @status.stdout.each_line do |line|
+ if !line[0..9].strip.empty?
+ @int_name = line[0..9].strip
+ @interfaces[@int_name] = { "hwaddr" => (line =~ /(HWaddr)/ ? ($') : "nil").strip.chomp }
+ else
+ @interfaces[@int_name]["inet_addr"] = (line =~ /inet addr:(\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /inet addr:/
+ @interfaces[@int_name]["bcast"] = (line =~ /Bcast:(\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /Bcast:/
+ @interfaces[@int_name]["mask"] = (line =~ /Mask:(\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /Mask:/
+ @interfaces[@int_name]["mtu"] = (line =~ /MTU:(\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /MTU:/
+ @interfaces[@int_name]["metric"] = (line =~ /Metric:(\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /Metric:/
+ end
+
+ next unless @interfaces.key?(new_resource.device)
+ @interface = @interfaces.fetch(new_resource.device)
+
+ current_resource.target(new_resource.target)
+ current_resource.device(new_resource.device)
+ current_resource.inet_addr(@interface["inet_addr"])
+ current_resource.hwaddr(@interface["hwaddr"])
+ current_resource.bcast(@interface["bcast"])
+ current_resource.mask(@interface["mask"])
+ current_resource.mtu(@interface["mtu"])
+ current_resource.metric(@interface["metric"])
end
+ elsif @ifconfig_version.to_f >= 2.0
+ # Example output for 2.10-alpha is as follows: (sanitized but format intact)
+ # eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
+ # inet 192.168.1.1 netmask 255.255.240.0 broadcast 192.168.0.1
+ # inet6 0000::0000:000:0000:0000 prefixlen 64 scopeid 0x20<link>
+ # ether 00:00:00:00:00:00 txqueuelen 1000 (Ethernet)
+ # RX packets 2383836 bytes 1642630840 (1.5 GiB)
+ # RX errors 0 dropped 0 overruns 0 frame 0
+ # TX packets 1244218 bytes 977339327 (932.0 MiB)
+ # TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
+ @status = shell_out("ifconfig")
+ @status.stdout.each_line do |line|
+ addr_regex = /^(\w+):?(\d*):?\ .+$/
+ if line =~ addr_regex
+ if line.match(addr_regex).nil?
+ @int_name = "nil"
+ elsif line.match(addr_regex)[2] == ""
+ @int_name = line.match(addr_regex)[1]
+ @interfaces[@int_name] = Hash.new
+ @interfaces[@int_name]["mtu"] = (line =~ /mtu (\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /mtu/ && @interfaces[@int_name]["mtu"].nil?
+ else
+ @int_name = "#{line.match(addr_regex)[1]}:#{line.match(addr_regex)[2]}"
+ @interfaces[@int_name] = Hash.new
+ @interfaces[@int_name]["mtu"] = (line =~ /mtu (\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /mtu/ && @interfaces[@int_name]["mtu"].nil?
+ end
+ else
+ @interfaces[@int_name]["inet_addr"] = (line =~ /inet (\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /inet/ && @interfaces[@int_name]["inet_addr"].nil?
+ @interfaces[@int_name]["bcast"] = (line =~ /broadcast (\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /broadcast/ && @interfaces[@int_name]["bcast"].nil?
+ @interfaces[@int_name]["mask"] = (line =~ /netmask (\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /netmask/ && @interfaces[@int_name]["mask"].nil?
+ @interfaces[@int_name]["hwaddr"] = (line =~ /ether (\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /ether/ && @interfaces[@int_name]["hwaddr"].nil?
+ @interfaces[@int_name]["metric"] = (line =~ /Metric:(\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /Metric:/ && @interfaces[@int_name]["metric"].nil?
+ end
- next unless @interfaces.key?(new_resource.device)
- @interface = @interfaces.fetch(new_resource.device)
-
- current_resource.target(new_resource.target)
- current_resource.device(new_resource.device)
- current_resource.inet_addr(@interface["inet_addr"])
- current_resource.hwaddr(@interface["hwaddr"])
- current_resource.bcast(@interface["bcast"])
- current_resource.mask(@interface["mask"])
- current_resource.mtu(@interface["mtu"])
- current_resource.metric(@interface["metric"])
+ next unless @interfaces.key?(new_resource.device)
+ @interface = @interfaces.fetch(new_resource.device)
+
+ current_resource.target(new_resource.target)
+ current_resource.device(new_resource.device)
+ current_resource.inet_addr(@interface["inet_addr"])
+ current_resource.hwaddr(@interface["hwaddr"])
+ current_resource.bcast(@interface["bcast"])
+ current_resource.mask(@interface["mask"])
+ current_resource.mtu(@interface["mtu"])
+ current_resource.metric(@interface["metric"])
+ end
end
current_resource
end
diff --git a/spec/functional/resource/ifconfig_spec.rb b/spec/functional/resource/ifconfig_spec.rb
index 0298dbcf45..fbb8995d52 100644
--- a/spec/functional/resource/ifconfig_spec.rb
+++ b/spec/functional/resource/ifconfig_spec.rb
@@ -20,7 +20,7 @@ require "functional/resource/base"
require "chef/mixin/shell_out"
# run this test only for following platforms.
-include_flag = !(%w{ubuntu centos aix}.include?(ohai[:platform]))
+include_flag = !(%w{amazon debian aix}.include?(ohai[:platform_family]) || (ohai[:platform_family] == "rhel" && ohai[:platform_version].to_i < 7))
describe Chef::Resource::Ifconfig, :requires_root, :skip_travis, :external => include_flag do
# This test does not work in travis because there is no eth0
diff --git a/spec/functional/resource/mount_spec.rb b/spec/functional/resource/mount_spec.rb
index c756b0d3d4..c98d6cec25 100644
--- a/spec/functional/resource/mount_spec.rb
+++ b/spec/functional/resource/mount_spec.rb
@@ -22,7 +22,7 @@ require "chef/mixin/shell_out"
require "tmpdir"
# run this test only for following platforms.
-include_flag = !(%w{ubuntu centos aix solaris2}.include?(ohai[:platform]))
+include_flag = !(%w{debian rhel amazon aix solaris2}.include?(ohai[:platform_family]))
describe Chef::Resource::Mount, :requires_root, :skip_travis, :external => include_flag do
# Disabled in travis because it refuses to let us mount a ramdisk. /dev/ramX does not
@@ -35,15 +35,19 @@ describe Chef::Resource::Mount, :requires_root, :skip_travis, :external => inclu
def setup_device_for_mount
# use ramdisk for creating a test device for mount.
# This can cleaner if we have chef resource/provider for ramdisk.
- case ohai[:platform]
+ case ohai[:platform_family]
when "aix"
# On AIX, we can't create a ramdisk inside a WPAR, so we use
# a "namefs" mount against / to test
# https://www-304.ibm.com/support/knowledgecenter/ssw_aix_71/com.ibm.aix.performance/namefs_file_sys.htm
device = "/"
fstype = "namefs"
- when "ubuntu", "centos"
+ when "debian", "rhel", "amazon"
device = "/dev/ram1"
+ unless File.exist?(device)
+ shell_out("mknod -m 660 #{device} b 1 0")
+ shell_out("chown root:disk #{device}")
+ end
shell_out("ls -1 /dev/ram*").stdout.each_line do |d|
if shell_out("mount | grep #{d}").exitstatus == "1"
# this device is not mounted, so use it.
diff --git a/spec/unit/provider/ifconfig_spec.rb b/spec/unit/provider/ifconfig_spec.rb
index da27d647ee..06dddf89d6 100644
--- a/spec/unit/provider/ifconfig_spec.rb
+++ b/spec/unit/provider/ifconfig_spec.rb
@@ -42,16 +42,11 @@ describe Chef::Provider::Ifconfig do
end
describe Chef::Provider::Ifconfig, "load_current_resource" do
before do
- @status = double(stdout: "", exitstatus: 1)
- allow(@provider).to receive(:shell_out).and_return(@status)
- @provider.load_current_resource
- end
- it "should track state of ifconfig failure" do
- expect(@provider.instance_variable_get("@status").exitstatus).not_to eq(0)
+ mixlib = Mixlib::ShellOut.new
+ allow(@provider).to receive(:shell_out).and_return(mixlib)
end
it "should thrown an exception when ifconfig fails" do
- @provider.define_resource_requirements
- expect { @provider.process_resource_requirements }.to raise_error Chef::Exceptions::Ifconfig
+ expect { @provider.load_current_resource }.to raise_error
end
end
describe Chef::Provider::Ifconfig, "action_add" do
diff --git a/tasks/bundle_util.rb b/tasks/bundle_util.rb
index 67647dd4f0..5cb90a7196 100644
--- a/tasks/bundle_util.rb
+++ b/tasks/bundle_util.rb
@@ -2,7 +2,7 @@ require "bundler"
require "shellwords"
module BundleUtil
- PLATFORMS = { "windows" => %w{ruby x86-mingw32} }
+ PLATFORMS = { "windows" => %w{ruby x64-mingw32 x86-mingw32} }
def project_root
File.expand_path("../..", __FILE__)