summaryrefslogtreecommitdiff
path: root/lib/chef
diff options
context:
space:
mode:
authorKapil Chouhan <kapil.chouhan@msystechnologies.com>2019-01-18 17:11:13 +0530
committerKapil Chouhan <kapil.chouhan@msystechnologies.com>2019-01-18 18:42:41 +0530
commit7c00ecf30ea22d67d10e5c848a8c36c50ab31a05 (patch)
tree53d102f3fcf9eecde1220f79eacbea9d14dc13fe /lib/chef
parent2f7ad6baf98f1999faa49f5218552911105e0380 (diff)
downloadchef-7c00ecf30ea22d67d10e5c848a8c36c50ab31a05.tar.gz
Fix for Sysctl doesn't work when key has a dot(.) in the name
Signed-off-by: Kapil Chouhan <kapil.chouhan@msystechnologies.com>
Diffstat (limited to 'lib/chef')
-rw-r--r--lib/chef/resource/sysctl.rb12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/chef/resource/sysctl.rb b/lib/chef/resource/sysctl.rb
index a5568904ba..53dfb0663e 100644
--- a/lib/chef/resource/sysctl.rb
+++ b/lib/chef/resource/sysctl.rb
@@ -80,7 +80,7 @@ class Chef
directory new_resource.conf_dir
- file "#{new_resource.conf_dir}/99-chef-#{new_resource.key}.conf" do
+ file "#{new_resource.conf_dir}/99-chef-#{new_resource.key.tr('/', '.')}.conf" do
content "#{new_resource.key} = #{new_resource.value}"
end
@@ -96,9 +96,9 @@ class Chef
description "Remove a sysctl value."
# 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 sysctl 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
+ if ::File.exist?("#{new_resource.conf_dir}/99-chef-#{new_resource.key.tr('/', '.')}.conf")
+ converge_by "removing sysctl config at #{new_resource.conf_dir}/99-chef-#{new_resource.key.tr('/', '.')}.conf" do
+ file "#{new_resource.conf_dir}/99-chef-#{new_resource.key.tr('/', '.')}.conf" do
action :delete
end
@@ -140,8 +140,8 @@ class Chef
# return the value. Raise in case this conf file needs to be created
# or updated
def get_sysctld_value(key)
- raise unless ::File.exist?("/etc/sysctl.d/99-chef-#{key}.conf")
- k, v = ::File.read("/etc/sysctl.d/99-chef-#{key}.conf").match(/(.*) = (.*)/).captures
+ raise unless ::File.exist?("/etc/sysctl.d/99-chef-#{key.tr('/', '.')}.conf")
+ k, v = ::File.read("/etc/sysctl.d/99-chef-#{key.tr('/', '.')}.conf").match(/(.*) = (.*)/).captures
raise "Unknown sysctl key!" if k.nil?
raise "Unknown sysctl value!" if v.nil?
v