summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2019-01-21 10:08:24 -0800
committerGitHub <noreply@github.com>2019-01-21 10:08:24 -0800
commitf6b4553c8dfd5ddd998f106be3786b95a9fe1ec9 (patch)
tree3796b4efce4b14012f497ff115635590096a66cb /lib
parent50fb680ed3abffdc3ce1152ebf758615d132e7f8 (diff)
parent50cda82a9be3a4c08f82dcb074cc7edf87037c2d (diff)
downloadchef-f6b4553c8dfd5ddd998f106be3786b95a9fe1ec9.tar.gz
Merge pull request #8142 from chef/sysctl_14
systctl: Allow slashes in key or block name
Diffstat (limited to 'lib')
-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