summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKapil Chouhan <kapil.chouhan@msystechnologies.com>2019-01-18 17:11:13 +0530
committerTim Smith <tsmith@chef.io>2019-01-21 09:30:52 -0800
commit50cda82a9be3a4c08f82dcb074cc7edf87037c2d (patch)
tree749629bba199a2acdafa40c4b61122fce6c093a6
parent676cc0cfd7705a61269c6845d054b84fa8ba50f8 (diff)
downloadchef-50cda82a9be3a4c08f82dcb074cc7edf87037c2d.tar.gz
Fix for Sysctl doesn't work when key has a dot(.) in the namesysctl_14
Signed-off-by: Kapil Chouhan <kapil.chouhan@msystechnologies.com>
-rw-r--r--kitchen-tests/cookbooks/end_to_end/recipes/tests.rb8
-rw-r--r--kitchen-tests/kitchen.yml1
-rw-r--r--lib/chef/resource/sysctl.rb12
3 files changed, 15 insertions, 6 deletions
diff --git a/kitchen-tests/cookbooks/end_to_end/recipes/tests.rb b/kitchen-tests/cookbooks/end_to_end/recipes/tests.rb
index 1c9171b9f3..b53fc39e17 100644
--- a/kitchen-tests/cookbooks/end_to_end/recipes/tests.rb
+++ b/kitchen-tests/cookbooks/end_to_end/recipes/tests.rb
@@ -19,3 +19,11 @@ end
file "/tmp/chef-test-\xFDmlaut" do
content "testing illegal UTF-8 char in the filename"
end
+
+node["network"]["interfaces"].each do |interface_data|
+ interface = interface_data[0]
+ sysctl_param "net/ipv4/conf/#{interface}/rp_filter" do
+ value 0
+ ignore_failure true
+ end
+end
diff --git a/kitchen-tests/kitchen.yml b/kitchen-tests/kitchen.yml
index 7e654f1491..fd8e5383ea 100644
--- a/kitchen-tests/kitchen.yml
+++ b/kitchen-tests/kitchen.yml
@@ -37,3 +37,4 @@ suites:
- name: end-to-end
run_list:
- recipe[end_to_end::default]
+ - recipe[end_to_end::tests]
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