summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2018-07-16 11:35:58 -0700
committerTim Smith <tsmith@chef.io>2018-07-16 16:17:18 -0700
commit75dcbefc8b10059d2d123593723c3b366877e262 (patch)
tree09abfa7c84a247b11b9a9ed4f918a86caaaf1ed6
parentad6760303f10bef9e97aa3fe4b681e2dc78b9f2c (diff)
downloadchef-ifconfig.tar.gz
ifconfig: Add gateway property on RHEL/Debian based systemsifconfig
This reimplements #6279 after our conversion of this resource to use properties. It also adds support for RHEL since that's documented here: https://www.centos.org/docs/5/html/Deployment_Guide-en-US/s1-networkscripts-interfaces.html Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/chef/provider/ifconfig/debian.rb1
-rw-r--r--lib/chef/provider/ifconfig/redhat.rb1
-rw-r--r--lib/chef/resource/ifconfig.rb8
3 files changed, 8 insertions, 2 deletions
diff --git a/lib/chef/provider/ifconfig/debian.rb b/lib/chef/provider/ifconfig/debian.rb
index aee3ca02dc..e610bab5df 100644
--- a/lib/chef/provider/ifconfig/debian.rb
+++ b/lib/chef/provider/ifconfig/debian.rb
@@ -48,6 +48,7 @@ iface <%= new_resource.device %> <%= new_resource.family %> static
<% if new_resource.metric %>metric <%= new_resource.metric %><% end %>
<% if new_resource.hwaddr %>hwaddress <%= new_resource.hwaddr %><% end %>
<% if new_resource.mtu %>mtu <%= new_resource.mtu %><% end %>
+ <% if new_resource.gateway %>gateway <%= new_resource.gateway %><% end %>
<% end %>
<% end %>
}
diff --git a/lib/chef/provider/ifconfig/redhat.rb b/lib/chef/provider/ifconfig/redhat.rb
index 24cea17b1a..70d78bcfe9 100644
--- a/lib/chef/provider/ifconfig/redhat.rb
+++ b/lib/chef/provider/ifconfig/redhat.rb
@@ -43,6 +43,7 @@ class Chef
<% 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 %>
+<% if new_resource.gateway %>GATEWAY=<%= new_resource.gateway %><% 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 2ea0381991..e2a35e6d43 100644
--- a/lib/chef/resource/ifconfig.rb
+++ b/lib/chef/resource/ifconfig.rb
@@ -45,8 +45,8 @@ class Chef
property :mask, String,
description: "The decimal representation of the network mask. For example: 255.255.255.0."
- property :family, String,
- default: "inet", introduced: "14.0",
+ property :family, String, default: "inet",
+ introduced: "14.0",
description: "Networking family option for Debian-based systems. For example: inet or inet6."
property :inet_addr, String,
@@ -96,6 +96,10 @@ class Chef
property :vlan, String,
introduced: "14.4",
description: "The VLAN to assign the interface to."
+
+ property :gateway, String,
+ introduced: "14.4",
+ description: "The gateway to use for the interface."
end
end
end