diff options
author | Scott Hain <shain@chef.io> | 2017-11-16 12:38:24 -0800 |
---|---|---|
committer | Scott Hain <shain@chef.io> | 2017-11-16 14:17:22 -0800 |
commit | ef54ad304c62e4e456a412f95c5acf55ffed2874 (patch) | |
tree | f21f984e3cdb3145fb04a1a9d183bbb19f1f1fc6 | |
parent | 4ea68802a17735e8938339fd03f7fe41b1fa1ca2 (diff) | |
download | chef-ef54ad304c62e4e456a412f95c5acf55ffed2874.tar.gz |
Don't run ifconfig tests on RHEL7, as it is not part of the base OS
Signed-off-by: Scott Hain <shain@chef.io>
-rw-r--r-- | lib/chef/provider/ifconfig.rb | 11 | ||||
-rw-r--r-- | spec/functional/resource/ifconfig_spec.rb | 2 |
2 files changed, 7 insertions, 6 deletions
diff --git a/lib/chef/provider/ifconfig.rb b/lib/chef/provider/ifconfig.rb index 514049266f..65a65b276f 100644 --- a/lib/chef/provider/ifconfig.rb +++ b/lib/chef/provider/ifconfig.rb @@ -66,8 +66,9 @@ class Chef end end - case @ifconfig_version - when "1.60" + if @ifconfig_version.nil? + raise "net-tools not found - this is required for ifconfig" + elsif @ifconfig_version.to_f < 2.0 @status = shell_out("ifconfig") @status.stdout.each_line do |line| if !line[0..9].strip.empty? @@ -80,10 +81,10 @@ class Chef @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"]) @@ -93,7 +94,7 @@ class Chef current_resource.mtu(@interface["mtu"]) current_resource.metric(@interface["metric"]) end - when "2.10" + elsif @ifconfig_version.to_f >= 2.0 @status = shell_out("ifconfig") @status.stdout.each_line do |line| addr_regex = /^(\w+):?(\d*):?\ .+$/ diff --git a/spec/functional/resource/ifconfig_spec.rb b/spec/functional/resource/ifconfig_spec.rb index acd922e75c..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{rhel amazon debian aix}.include?(ohai[:platform_family])) +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 |