diff options
author | Tim Smith <tsmith@chef.io> | 2018-07-16 16:13:27 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-16 16:13:27 -0700 |
commit | ad6760303f10bef9e97aa3fe4b681e2dc78b9f2c (patch) | |
tree | 52906442201f4b400094b2db6f6f1f3c6094c7bf | |
parent | 4d229297e8323b5287916b80f93f44d83800dfb3 (diff) | |
parent | b0df53274ec810178d260fe91f55a2928c3cc0ce (diff) | |
download | chef-ad6760303f10bef9e97aa3fe4b681e2dc78b9f2c.tar.gz |
Merge pull request #7478 from chef/tomdoherty-vlan
ifconfig: Allow specifying VLAN on RHEL/Centos
-rw-r--r-- | lib/chef/provider/ifconfig/redhat.rb | 1 | ||||
-rw-r--r-- | lib/chef/resource/ifconfig.rb | 4 | ||||
-rw-r--r-- | spec/unit/provider/ifconfig/redhat_spec.rb | 2 | ||||
-rw-r--r-- | spec/unit/provider/route_spec.rb | 2 |
4 files changed, 8 insertions, 1 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 d43b8c2d58..2ea0381991 100644 --- a/lib/chef/resource/ifconfig.rb +++ b/lib/chef/resource/ifconfig.rb @@ -92,6 +92,10 @@ class Chef property :slave, String, introduced: "13.4", description: "When set to yes, this device is controlled by the channel bonding interface that is specified via the master property." + + property :vlan, String, + introduced: "14.4", + description: "The VLAN to assign the interface to." 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) diff --git a/spec/unit/provider/route_spec.rb b/spec/unit/provider/route_spec.rb index ea6ddffb81..977e5681bf 100644 --- a/spec/unit/provider/route_spec.rb +++ b/spec/unit/provider/route_spec.rb @@ -167,7 +167,7 @@ describe Chef::Provider::Route do expect(@provider.generate_command(:add).join(" ")).not_to match(/\svia\s#{Regexp.escape(@new_resource.gateway.to_s)}/) end - it "should use the gatway when target is default" do + it "should use the gateway when target is default" do @default_resource.gateway("10.0.0.10") expect(@default_provider.generate_command(:add).join(" ")).to match(/10.0.0.10/) end |