summaryrefslogtreecommitdiff
path: root/lib/chef/resource/sysctl.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/resource/sysctl.rb')
-rw-r--r--lib/chef/resource/sysctl.rb12
1 files changed, 5 insertions, 7 deletions
diff --git a/lib/chef/resource/sysctl.rb b/lib/chef/resource/sysctl.rb
index 75d2ef3262..faa9d59e95 100644
--- a/lib/chef/resource/sysctl.rb
+++ b/lib/chef/resource/sysctl.rb
@@ -63,14 +63,12 @@ class Chef
end
end
- def get_sysctl_value(key)
- o = shell_out("sysctl -n -e #{key}")
- raise "Unknown sysctl key #{key}!" if o.error?
- o.stdout.to_s.tr("\t", " ").strip
- end
-
+ # shellout to systctl to get the current value
+ # ignore missing keys by using '-e'
+ # convert tabs to spaces since systctl tab deliminates multivalue parameters
+ # strip the newline off the end of the output as well
load_current_value do
- value get_sysctl_value(key)
+ value shell_out!("sysctl -n -e #{key}").stdout.tr("\t", " ").strip
end
action :apply do