summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Doherty <tom.doherty@fixnetix.com>2017-09-13 21:10:06 +0100
committerTom Doherty <tom.doherty@fixnetix.com>2017-09-13 21:10:06 +0100
commite2ea0b66b0801c0f83f84def14fdf8b09d30fa48 (patch)
tree5b44386d51362199b2cf54ba9bbccb7153ee808c
parent4aaee228cec3df85018094350d95a90f62e774e4 (diff)
downloadchef-e2ea0b66b0801c0f83f84def14fdf8b09d30fa48.tar.gz
Allow specifying VLAN on RHEL/Centos
Signed-off-by: Tom Doherty <tom.doherty@fixnetix.com>
-rw-r--r--lib/chef/provider/ifconfig/redhat.rb1
-rw-r--r--lib/chef/resource/ifconfig.rb9
-rw-r--r--spec/unit/provider/ifconfig/redhat_spec.rb2
3 files changed, 12 insertions, 0 deletions
diff --git a/lib/chef/provider/ifconfig/redhat.rb b/lib/chef/provider/ifconfig/redhat.rb
index bf3d979e86..24cea17b1a 100644
--- a/lib/chef/provider/ifconfig/redhat.rb
+++ b/lib/chef/provider/ifconfig/redhat.rb
@@ -42,6 +42,7 @@ class Chef
<% if new_resource.bonding_opts %>BONDING_OPTS="<%= new_resource.bonding_opts %>"<% end %>
<% if new_resource.master %>MASTER=<%= new_resource.master %><% end %>
<% if new_resource.slave %>SLAVE=<%= new_resource.slave %><% end %>
+<% if new_resource.vlan %>VLAN=<%= new_resource.vlan %><% end %>
}
@config_path = "/etc/sysconfig/network-scripts/ifcfg-#{new_resource.device}"
end
diff --git a/lib/chef/resource/ifconfig.rb b/lib/chef/resource/ifconfig.rb
index 3673311348..e61d329a1e 100644
--- a/lib/chef/resource/ifconfig.rb
+++ b/lib/chef/resource/ifconfig.rb
@@ -48,6 +48,7 @@ class Chef
@bonding_opts = nil
@master = nil
@slave = nil
+ @vlan = nil
end
def target(arg = nil)
@@ -177,6 +178,14 @@ class Chef
:kind_of => String
)
end
+
+ def vlan(arg = nil)
+ set_or_return(
+ :vlan,
+ arg,
+ :kind_of => String
+ )
+ end
end
end
diff --git a/spec/unit/provider/ifconfig/redhat_spec.rb b/spec/unit/provider/ifconfig/redhat_spec.rb
index d81f963450..75291d3bf9 100644
--- a/spec/unit/provider/ifconfig/redhat_spec.rb
+++ b/spec/unit/provider/ifconfig/redhat_spec.rb
@@ -35,6 +35,7 @@ describe Chef::Provider::Ifconfig::Redhat do
@new_resource.bonding_opts "mode=active-backup miimon=100"
@new_resource.master "bond0"
@new_resource.slave "yes"
+ @new_resource.vlan "yes"
@provider = Chef::Provider::Ifconfig::Redhat.new(@new_resource, @run_context)
@current_resource = Chef::Resource::Ifconfig.new("10.0.0.1", @run_context)
@@ -60,6 +61,7 @@ describe Chef::Provider::Ifconfig::Redhat do
expect(arg).to match(/^\s*BONDING_OPTS="mode=active-backup miimon=100"\s*$/)
expect(arg).to match(/^\s*MASTER=bond0\s*$/)
expect(arg).to match(/^\s*SLAVE=yes\s*$/)
+ expect(arg).to match(/^\s*VLAN=yes\s*$/)
end
expect(@config).to receive(:run_action).with(:create)
expect(@config).to receive(:updated?).and_return(true)