From 75dcbefc8b10059d2d123593723c3b366877e262 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Mon, 16 Jul 2018 11:35:58 -0700 Subject: ifconfig: Add gateway property on RHEL/Debian based systems 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 --- lib/chef/provider/ifconfig/debian.rb | 1 + lib/chef/provider/ifconfig/redhat.rb | 1 + lib/chef/resource/ifconfig.rb | 8 ++++++-- 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 -- cgit v1.2.1