summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/chef/provider/ifconfig.rb2
-rw-r--r--spec/unit/provider/ifconfig_spec.rb11
2 files changed, 12 insertions, 1 deletions
diff --git a/lib/chef/provider/ifconfig.rb b/lib/chef/provider/ifconfig.rb
index 1575127c25..607f1fa47b 100644
--- a/lib/chef/provider/ifconfig.rb
+++ b/lib/chef/provider/ifconfig.rb
@@ -112,7 +112,7 @@ class Chef
# Permalink for addr_regex : https://rubular.com/r/JrykUpfjRnYeQD
@status = shell_out("ifconfig")
@status.stdout.each_line do |line|
- addr_regex = /^((\w|-)+):?(\d*):?\ .+$/
+ addr_regex = /^(\w+)(-?):?(\d*):?\ .+$/
if line =~ addr_regex
if line.match(addr_regex).nil?
@int_name = "nil"
diff --git a/spec/unit/provider/ifconfig_spec.rb b/spec/unit/provider/ifconfig_spec.rb
index 8c63a3e46e..b25c8f70ca 100644
--- a/spec/unit/provider/ifconfig_spec.rb
+++ b/spec/unit/provider/ifconfig_spec.rb
@@ -94,6 +94,17 @@ EOS
expect(@new_resource).not_to be_updated
end
+ it "should add a bridge interface" do
+ allow(@provider).to receive(:load_current_resource)
+ @new_resource.device "br-1234"
+ command = "ifconfig br-1234 10.0.0.1 netmask 255.255.254.0 metric 1 mtu 1500"
+ expect(@provider).to receive(:shell_out_compacted!).with(*command.split(" "))
+ expect(@provider).to receive(:generate_config)
+
+ @provider.run_action(:add)
+ expect(@new_resource).to be_updated
+ end
+
# We are not testing this case with the assumption that anyone writing the cookbook would not make a typo == lo
# it "should add a blank command if the #{@new_resource.device} == lo" do
# end