summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2018-03-21 21:52:51 -0700
committerTim Smith <tsmith@chef.io>2018-03-21 21:52:51 -0700
commit4d45dedc44b54001caf2e0e5eeada98dda449647 (patch)
treefb2dd6781ac561b2d87eeac667423c1bbea7f876
parentf8c56d6b759ce7944a3392bcd4d01eca2cd55d1e (diff)
downloadchef-sysctl.tar.gz
Just remove the config file and reload sysctlsysctl
Still needs a bit of testing to see if there's a better way to do the reload, but here goes nothing Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/chef/resource/sysctl.rb26
1 files changed, 7 insertions, 19 deletions
diff --git a/lib/chef/resource/sysctl.rb b/lib/chef/resource/sysctl.rb
index 96a4287a2b..29222b04d3 100644
--- a/lib/chef/resource/sysctl.rb
+++ b/lib/chef/resource/sysctl.rb
@@ -33,20 +33,20 @@ class Chef
introduced "14.0"
property :key, String,
- description: "",
+ description: "The kernel parameter key in dotted format.",
name_property: true
property :ignore_error, [TrueClass, FalseClass],
- description: "",
+ description: "Ignore any errors when setting the value on the command line.",
default: false
property :value, [Array, String, Integer, Float],
- description: "",
+ description: "The value to set.",
coerce: proc { |v| coerce_value(v) },
required: true
property :conf_dir, String,
- description: "",
+ description: "The configuration directory to write the config to.",
default: "/etc/sysctl.d"
def after_created
@@ -71,9 +71,6 @@ class Chef
load_current_value do
value get_sysctl_value(key)
- if node.normal["sysctl"]["backup"][key].empty?
- node.normal["sysctl"]["backup"][key] = value
- end
end
action :apply do
@@ -87,28 +84,19 @@ class Chef
content "#{new_resource.key} = #{new_resource.value}"
end
- execute "sysctl -p" do
- command "sysctl -p"
- action :run
- end
+ execute "sysctl -p"
end
end
action :remove do
# only converge the resource if the file actually exists to delete
if ::File.exist?("#{new_resource.conf_dir}/99-chef-#{new_resource.key}.conf")
- converge_by "removing systctl value #{new_resource.key}" do
+ converge_by "removing systctl config at #{new_resource.conf_dir}/99-chef-#{new_resource.key}.conf" do
file "#{new_resource.conf_dir}/99-chef-#{new_resource.key}.conf" do
action :delete
end
- backup_value = node["sysctl"]["backup"][new_resource.key]
- set_sysctl_param(new_resource.key, backup_value) unless backup_value.empty?
- node.rm("sysctl", "backup", new_resource.key)
-
- execute "sysctl -p" do
- action :run
- end
+ execute "sysctl -p"
end
end
end