summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Doherty <tom@Thomass-MacBook-Pro-2.local>2018-03-01 18:35:09 +0000
committerThomas Doherty <tom@Thomass-MacBook-Pro-2.local>2018-03-01 18:35:09 +0000
commit12a02d2206061b0a2baebad96a0e105fd242932d (patch)
tree18d0c4b70810e403cc22ca06fc023b4645fe11d0
parent349786463576380e12bd58478449f1d977a53e00 (diff)
downloadchef-12a02d2206061b0a2baebad96a0e105fd242932d.tar.gz
Allow specifying a comment for routes
Signed-off-by: Tom Doherty <tom.doherty@fixnetix.com>
-rw-r--r--lib/chef/provider/route.rb3
-rw-r--r--lib/chef/resource/route.rb1
2 files changed, 3 insertions, 1 deletions
diff --git a/lib/chef/provider/route.rb b/lib/chef/provider/route.rb
index 2784ae43bc..16e06f470b 100644
--- a/lib/chef/provider/route.rb
+++ b/lib/chef/provider/route.rb
@@ -174,7 +174,7 @@ class Chef
conf[dev] = "" if conf[dev].nil?
case @action
when :add
- conf[dev] << config_file_contents(:add, target: resource.target, netmask: resource.netmask, gateway: resource.gateway) if resource.action == [:add]
+ conf[dev] << config_file_contents(:add, comment: resource.comment, target: resource.target, netmask: resource.netmask, gateway: resource.gateway) if resource.action == [:add]
when :delete
# need to do this for the case when the last route on an int
# is removed
@@ -231,6 +231,7 @@ class Chef
content = ""
case action
when :add
+ content << "# #{options[:comment]}\n" if options[:comment]
content << (options[:target]).to_s
content << "/#{MASK[options[:netmask].to_s]}" if options[:netmask]
content << " via #{options[:gateway]}" if options[:gateway]
diff --git a/lib/chef/resource/route.rb b/lib/chef/resource/route.rb
index 63079f997a..ecec56f69a 100644
--- a/lib/chef/resource/route.rb
+++ b/lib/chef/resource/route.rb
@@ -28,6 +28,7 @@ class Chef
description "Use the route resource to manage the system routing table in a Linux environment."
property :target, String, identity: true, name_property: true
+ property :comment, [String, nil]
property :netmask, [String, nil]
property :gateway, [String, nil]
property :device, [String, nil], desired_state: false # Has a partial default in the provider of eth0.