OSDN Git Service

adds the `platform_utils::grub_default` recipe. platform_utils-0.8.0
authorwhitestar <whitestar@users.osdn.me>
Sat, 29 Sep 2018 11:01:22 +0000 (20:01 +0900)
committerwhitestar <whitestar@users.osdn.me>
Sat, 29 Sep 2018 11:01:22 +0000 (20:01 +0900)
cookbooks/platform_utils/CHANGELOG.md
cookbooks/platform_utils/README.md
cookbooks/platform_utils/Rakefile
cookbooks/platform_utils/attributes/default.rb
cookbooks/platform_utils/chefignore [new file with mode: 0644]
cookbooks/platform_utils/recipes/grub_default.rb [new file with mode: 0644]
cookbooks/platform_utils/templates/default/etc/default/grub.d/override.cfg [new file with mode: 0644]
cookbooks/platform_utils/version

index cd9dd19..fd98870 100644 (file)
@@ -1,6 +1,10 @@
 platform_utils CHANGELOG
 ========================
 
+0.8.0
+-----
+- adds the `platform_utils::grub_default` recipe.
+
 0.7.0
 -----
 - adds autopilot features.
index 40c4e83..8ec908e 100644 (file)
@@ -13,6 +13,7 @@ This cookbook provides platform utility recipes.
 - [Usage](#usage)
     - [Recipes](#recipes)
         - [platform_utils::default](#platform_utilsdefault)
+        - [platform_utils::grub_default](#platform_utilsgrub_default)
         - [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)
@@ -42,6 +43,7 @@ This cookbook provides platform utility recipes.
 
 |Key|Type|Description, example|Default|
 |:--|:--|:--|:--|
+|`['platform_utils']['grub_default']`|Hash|GRUB2 configurations. This settings are expanded to the `/etc/default/grub.d/override.cfg`.|`{}`|
 |`['platform_utils']['kernel_modules']['loaded_modules']`|Array|Loaded extra kernel module names.|`[]`|
 |`['platform_utils']['mount']['autopilot']`|Hash|mount autopilot configurations.|See `attributes/default.rb`|
 |`['platform_utils']['networking']['autopilot']`|Hash|networking autopilot configurations.|See `attributes/default.rb`|
@@ -67,6 +69,10 @@ This cookbook provides platform utility recipes.
 
 This recipe does nothing.
 
+#### platform_utils::grub_default
+
+This recipe adds GRUB2 extra configurations.
+
 #### platform_utils::crond (ver. 0.4.0 or later)
 
 This recipe installs cron package and enables & starts the service.
index f1c82d7..1ba86c6 100644 (file)
@@ -14,6 +14,7 @@ task :init do
     '.foodcritic',
     '.rubocop.yml',
     'Berksfile',
+    'chefignore',
     'concourse.yml',
     'fly-vars.yml',
     'fly-vars.local.yml',
@@ -36,6 +37,7 @@ task :update do
 
   [
     'Rakefile',
+    'chefignore',
     'concourse.yml',
     'fly-vars.yml',
     'Gemfile',
index 570df39..c37353e 100644 (file)
@@ -2,7 +2,7 @@
 # Cookbook Name:: platform_utils
 # Attributes:: default
 #
-# Copyright 2016-2017, whitestar
+# Copyright 2016-2018, whitestar
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 
 default['platform_utils']['kernel_modules']['loaded_modules'] = []
 
+default['platform_utils']['grub_default'] = {
+  #'ENV_VAR_NAME' => 'value',
+  #'GRUB_TIMEOUT_STYLE' => 'menu',
+  #'GRUB_TIMEOUT' => '5',
+  #'GRUB_CMDLINE_LINUX_DEFAULT' => '""',
+}
+
 default['platform_utils']['mount']['autopilot'] = {
   # for delayed hotplug devices (e.g. usb)
   'enabled' => false,
diff --git a/cookbooks/platform_utils/chefignore b/cookbooks/platform_utils/chefignore
new file mode 100644 (file)
index 0000000..10e314a
--- /dev/null
@@ -0,0 +1,20 @@
+# Put files/directories that should be ignored in this file.
+# Lines that start with '# ' are comments.
+
+Berksfile.lock
+
+# concourse
+concourse.yml
+fly-vars.yml
+fly-vars.local.yml
+
+# emacs
+*~
+
+.rubocop_todo.yml
+
+# vim
+*.sw[a-z]
+
+# subversion
+*/.svn/*
diff --git a/cookbooks/platform_utils/recipes/grub_default.rb b/cookbooks/platform_utils/recipes/grub_default.rb
new file mode 100644 (file)
index 0000000..dace997
--- /dev/null
@@ -0,0 +1,45 @@
+#
+# Cookbook Name:: platform_utils
+# Recipe:: grub_default
+#
+# Copyright 2018, 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.
+#
+
+unless File.exist?('/boot/grub/grub.cfg')
+  Chef::Log.warn('recipe[platform_utils::grub_default] GRUB 2 is not installed yet.')
+  return
+end
+
+execute 'update-grub2' do
+  user 'root'
+  command 'update-grub2'
+  action :nothing
+  only_if 'update-grub2 --version'
+end
+
+dir = '/etc/default/grub.d'
+resources(directory: dir) rescue directory dir do
+  owner 'root'
+  group 'root'
+  mode '0755'
+end
+
+template '/etc/default/grub.d/override.cfg' do
+  source  'etc/default/grub.d/override.cfg'
+  owner 'root'
+  group 'root'
+  mode '0644'
+  notifies :run, 'execute[update-grub2]'
+end
diff --git a/cookbooks/platform_utils/templates/default/etc/default/grub.d/override.cfg b/cookbooks/platform_utils/templates/default/etc/default/grub.d/override.cfg
new file mode 100644 (file)
index 0000000..afe5c0f
--- /dev/null
@@ -0,0 +1,7 @@
+<%
+node['platform_utils']['grub_default'].each {|key, value|
+-%>
+<%= key %>=<%= value %>
+<%
+}
+-%>
\ No newline at end of file