OSDN Git Service

adds the `platform_utils::sysctl` recipe. platform_utils-0.4.3
authorwhitestar <whitestar@gaea.test>
Sun, 29 Jan 2017 08:31:46 +0000 (17:31 +0900)
committerwhitestar <whitestar@gaea.test>
Sun, 29 Jan 2017 08:31:46 +0000 (17:31 +0900)
cookbooks/platform_utils/CHANGELOG.md
cookbooks/platform_utils/README.md
cookbooks/platform_utils/attributes/default.rb
cookbooks/platform_utils/metadata.rb
cookbooks/platform_utils/recipes/sysctl.rb [new file with mode: 0644]
cookbooks/platform_utils/templates/default/etc/sysctl.d/template.conf [new file with mode: 0644]

index 18efc14..07e9cce 100644 (file)
@@ -1,10 +1,14 @@
 platform_utils CHANGELOG
 ========================
 
+0.4.3
+-----
+- adds the `platform_utils::sysctl` recipe.
+
 0.4.2
 -----
-- adds the `PlatformUtils::kernel_modules` recipe.
-- adds the `PlatformUtils::kernel_user_namespace` recipe.
+- adds the `platform_utils::kernel_modules` recipe.
+- adds the `platform_utils::kernel_user_namespace` recipe.
 
 0.4.1
 -----
index d7662ae..87a07ba 100644 (file)
@@ -6,21 +6,22 @@ This cookbook provides platform utility recipes.
 ## 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
@@ -48,6 +49,7 @@ This cookbook provides platform utility recipes.
 |`['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)|`[]`|
 
@@ -87,6 +89,10 @@ This recipe sets up the `/etc/subuid` and the `/etc/subgid`.
 
 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.
index e1b58c1..081fd5a 100644 (file)
@@ -64,5 +64,19 @@ default['platform_utils']['sudo']['sudoers.d'] = {
 }
 default['platform_utils']['sudo']['group']['members'] = []
 
+default['platform_utils']['sysctl']['configs'] = {
+=begin
+  '80-by_chef' => {
+    'action' => :create,
+    'params' => {
+      'key' => 'value',
+    },
+  },
+  '88-unwanted' => {
+    'action' => :delete,
+  },
+=end
+}
+
 default['platform_utils']['tcp_wrappers']['hosts_allow'] = []
 default['platform_utils']['tcp_wrappers']['hosts_deny'] = []
index 0e1c5fe..0da5937 100644 (file)
@@ -5,7 +5,7 @@ maintainer_email ''
 license          'Apache 2.0'
 description      'Platform Utilities'
 long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
-version          '0.4.2'
+version          '0.4.3'
 source_url       'http://scm.osdn.jp/gitroot/metasearch/grid-chef-repo.git'
 issues_url       'https://osdn.jp/projects/metasearch/ticket'
 
diff --git a/cookbooks/platform_utils/recipes/sysctl.rb b/cookbooks/platform_utils/recipes/sysctl.rb
new file mode 100644 (file)
index 0000000..6058f9b
--- /dev/null
@@ -0,0 +1,44 @@
+#
+# 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
diff --git a/cookbooks/platform_utils/templates/default/etc/sysctl.d/template.conf b/cookbooks/platform_utils/templates/default/etc/sysctl.d/template.conf
new file mode 100644 (file)
index 0000000..e513efd
--- /dev/null
@@ -0,0 +1,3 @@
+<% @params.each {|key, value| %>
+<%= key %>=<%= value %>
+<% } -%>