## Contents
- [Requirements](#requirements)
- - [Platforms](#platforms)
- - [Packages](#packages)
- - [Cookbooks](#cookbooks)
+ - [Platforms](#platforms)
+ - [Packages](#packages)
+ - [Cookbooks](#cookbooks)
- [Attributes](#attributes)
- [Usage](#usage)
- - [Recipes](#recipes)
- - [platform_utils::default](#platform_utilsdefault)
- - [platform_utils::crond (ver. 0.4.0 or later)](#platform_utilscrond-ver-040-or-later)
- - [platform_utils::kernel_modules (ver. 0.4.2 or later)](#platform_utilskernel_modules-ver-042-or-later)
- - [platform_utils::kernel_user_namespace (ver. 0.4.2 or later)](#platform_utilskernel_user_namespace-ver-042-or-later)
- - [platform_utils::ntpd (ver. 0.4.0 or later)](#platform_utilsntpd-ver-040-or-later)
- - [platform_utils::platform_update](#platform_utilsplatform_update)
- - [platform_utils::subid](#platform_utilssubid)
- - [platform_utils::sudo](#platform_utilssudo)
- - [platform_utils::tcp_wrappers (ver. 0.4.0 or later)](#platform_utilstcp_wrappers-ver-040-or-later)
+ - [Recipes](#recipes)
+ - [platform_utils::default](#platform_utilsdefault)
+ - [platform_utils::crond (ver. 0.4.0 or later)](#platform_utilscrond-ver-040-or-later)
+ - [platform_utils::kernel_modules (ver. 0.4.2 or later)](#platform_utilskernel_modules-ver-042-or-later)
+ - [platform_utils::kernel_user_namespace (ver. 0.4.2 or later)](#platform_utilskernel_user_namespace-ver-042-or-later)
+ - [platform_utils::ntpd (ver. 0.4.0 or later)](#platform_utilsntpd-ver-040-or-later)
+ - [platform_utils::platform_update](#platform_utilsplatform_update)
+ - [platform_utils::subid](#platform_utilssubid)
+ - [platform_utils::sudo](#platform_utilssudo)
+ - [platform_utils::sysctl (ver. 0.4.3 or later)](#platform_utilssysctl-ver-043-or-later)
+ - [platform_utils::tcp_wrappers (ver. 0.4.0 or later)](#platform_utilstcp_wrappers-ver-040-or-later)
- [License and Authors](#license-and-authors)
## Requirements
|`['platform_utils']['subid']['notifies']`|Array, Hash|Notifies by the subordinate user/group file update.|`[]`, See `attributes/default.rb`|
|`['platform_utils']['sudo']['sudoers.d']`|Hash|sudoers file configurations.|`{}` See `attributes/default.rb`|
|`['platform_utils']['sudo']['group']['members']`|Array|Members appended to the `sudo` group.|`[]`|
+|`['platform_utils']['sysctl']['configs']`|Hash|sysctl configurations. (ver. 0.4.3 or later)|`{}`, See `attributes/default.rb`|
|`['platform_utils']['tcp_wrappers']['host_allow']`|Array|Entries in `/etc/hosts.allow` (ver. 0.4.0 or later)|`[]`|
|`['platform_utils']['tcp_wrappers']['host_deny']`|Array|Entries in `/etc/hosts.deny` (ver. 0.4.0 or later)|`[]`|
This recipe sets up sudo.
+#### platform_utils::sysctl (ver. 0.4.3 or later)
+
+This recipe sets up sysctl (Kernel parameters).
+
#### platform_utils::tcp_wrappers (ver. 0.4.0 or later)
This recipe sets up hosts.allow and hosts.deny.
--- /dev/null
+#
+# Cookbook Name:: platform_utils
+# Recipe:: sysctl
+#
+# Copyright 2017, whitestar
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+::Chef::Recipe.send(:include, PlatformUtils::VirtUtils)
+
+unless container_guest_node?
+ node['platform_utils']['sysctl']['configs'].each {|file_name, conf|
+ file_path = "/etc/sysctl.d/#{file_name}.conf"
+ exec_name = "sysctl_-p_#{file_path}"
+
+ resources(execute: exec_name) rescue execute exec_name do
+ command "sysctl -p #{file_path}"
+ action :nothing
+ end
+
+ resources(template: file_path) rescue template file_path do
+ source 'etc/sysctl.d/template.conf'
+ owner 'root'
+ group 'root'
+ mode '0644'
+ variables(
+ params: conf['params']
+ )
+ action conf['action'].to_sym
+ notifies :run, "execute[#{exec_name}]", :immediately if conf['action'].to_sym == :create
+ end
+ }
+end