• R/O
  • HTTP
  • SSH
  • HTTPS

grid-chef-repo: Commit

Grid環境構築用のChefリポジトリです。


Commit MetaInfo

Revision132814da4214020c2b5f8c15aeee6dd258937692 (tree)
Time2018-09-20 22:54:52
Authorwhitestar <whitestar@user...>
Commiterwhitestar

Log Message

adds autopilot features.

Change Summary

Incremental Difference

--- a/cookbooks/platform_utils/CHANGELOG.md
+++ b/cookbooks/platform_utils/CHANGELOG.md
@@ -1,6 +1,10 @@
11 platform_utils CHANGELOG
22 ========================
33
4+0.7.0
5+-----
6+- adds autopilot features.
7+
48 0.6.0
59 -----
610 - adds the `platform_utils::rc_local` recipe.
--- a/cookbooks/platform_utils/README.md
+++ b/cookbooks/platform_utils/README.md
@@ -43,11 +43,14 @@ This cookbook provides platform utility recipes.
4343 |Key|Type|Description, example|Default|
4444 |:--|:--|:--|:--|
4545 |`['platform_utils']['kernel_modules']['loaded_modules']`|Array|Loaded extra kernel module names.|`[]`|
46+|`['platform_utils']['mount']['autopilot']`|Hash|mount autopilot configurations.|See `attributes/default.rb`|
47+|`['platform_utils']['networking']['autopilot']`|Hash|networking autopilot configurations.|See `attributes/default.rb`|
4648 |`['platform_utils']['platform_update']['auto_update']`|Boolean|whether update automatically or not.|`true`|
4749 |`['platform_utils']['platform_update']['timer']`|Symbol|update execution timing.|`:delayed`|
4850 |`['platform_utils']['platform_update']['apt-get']['command']`|String|apt-get upgrade/dist-upgrade command string.|`'apt-get upgrade -y'`|
4951 |`['platform_utils']['platform_update']['yum']['command']`|String|yum update command string.|`'yum update -y'`|
5052 |`['platform_utils']['rc_local']`|Array|`/etc/rc.local` lines.|`[]`|
53+|`['platform_utils']['resolver']['autopilot']`|Hash|systemd-resolved autopilot configurations.|See `attributes/default.rb`|
5154 |`['platform_utils']['subid']['users']`|Array|Subordinate user (=group) names.|`[]`|
5255 |`['platform_utils']['subid']['notifies']`|Array, Hash|Notifies by the subordinate user/group file update.|`[]`, See `attributes/default.rb`|
5356 |`['platform_utils']['sudo']['sudoers.d']`|Hash|sudoers file configurations.|`{}` See `attributes/default.rb`|
--- a/cookbooks/platform_utils/attributes/default.rb
+++ b/cookbooks/platform_utils/attributes/default.rb
@@ -19,6 +19,21 @@
1919
2020 default['platform_utils']['kernel_modules']['loaded_modules'] = []
2121
22+default['platform_utils']['mount']['autopilot'] = {
23+ # for delayed hotplug devices (e.g. usb)
24+ 'enabled' => false,
25+ 'log_dir' => '/var/log',
26+ 'wait_time' => '60s',
27+ 'mount_points' => [],
28+}
29+default['platform_utils']['networking']['autopilot'] = {
30+ # for delayed unstable networking
31+ 'enabled' => false,
32+ 'log_dir' => '/var/log',
33+ 'wait_time' => '60s',
34+ 'init_type' => nil, # 'init', 'systemd', 'netplan'
35+}
36+
2237 default['platform_utils']['platform_update']['auto_update'] = true
2338 default['platform_utils']['platform_update']['timer'] = :delayed
2439 default['platform_utils']['platform_update']['apt-get']['command'] = 'apt-get upgrade -y'
@@ -26,6 +41,13 @@ default['platform_utils']['platform_update']['yum']['command'] = 'yum update -y'
2641
2742 default['platform_utils']['rc_local'] = []
2843
44+default['platform_utils']['resolved']['autopilot'] = {
45+ # for local dns server used by the systemd-resolved
46+ 'enabled' => false,
47+ 'log_dir' => '/var/log',
48+ 'wait_time' => '120s',
49+}
50+
2951 default['platform_utils']['subid']['users'] = []
3052 default['platform_utils']['subid']['notifies'] = [
3153 =begin
--- /dev/null
+++ b/cookbooks/platform_utils/recipes/mount.rb
@@ -0,0 +1,36 @@
1+#
2+# Cookbook Name:: platform_utils
3+# Recipe:: mount
4+#
5+# Copyright 2018, whitestar
6+#
7+# Licensed under the Apache License, Version 2.0 (the "License");
8+# you may not use this file except in compliance with the License.
9+# You may obtain a copy of the License at
10+#
11+# http://www.apache.org/licenses/LICENSE-2.0
12+#
13+# Unless required by applicable law or agreed to in writing, software
14+# distributed under the License is distributed on an "AS IS" BASIS,
15+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+# See the License for the specific language governing permissions and
17+# limitations under the License.
18+#
19+
20+# autopilot
21+srv = 'mount'
22+template "/etc/cron.d/#{srv}-local" do
23+ source "etc/cron.d/#{srv}-local"
24+ owner 'root'
25+ group 'root'
26+ mode '0644'
27+ action :delete unless node['platform_utils']['mount']['autopilot']['enabled']
28+end
29+
30+template "/usr/local/bin/#{srv}-local" do
31+ source "usr/local/bin/#{srv}-local"
32+ owner 'root'
33+ group 'root'
34+ mode '0755'
35+ action :delete unless node['platform_utils']['mount']['autopilot']['enabled']
36+end
--- /dev/null
+++ b/cookbooks/platform_utils/recipes/networking.rb
@@ -0,0 +1,28 @@
1+#
2+# Cookbook Name:: platform_utils
3+# Recipe:: networking
4+#
5+# Copyright 2018, whitestar
6+#
7+# Licensed under the Apache License, Version 2.0 (the "License");
8+# you may not use this file except in compliance with the License.
9+# You may obtain a copy of the License at
10+#
11+# http://www.apache.org/licenses/LICENSE-2.0
12+#
13+# Unless required by applicable law or agreed to in writing, software
14+# distributed under the License is distributed on an "AS IS" BASIS,
15+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+# See the License for the specific language governing permissions and
17+# limitations under the License.
18+#
19+
20+# autopilot
21+srv = 'networking'
22+template "/etc/cron.d/#{srv}-local" do
23+ source "etc/cron.d/#{srv}-local"
24+ owner 'root'
25+ group 'root'
26+ mode '0644'
27+ action :delete unless node['platform_utils']['networking']['autopilot']['enabled']
28+end
--- /dev/null
+++ b/cookbooks/platform_utils/recipes/resolver.rb
@@ -0,0 +1,28 @@
1+#
2+# Cookbook Name:: platform_utils
3+# Recipe:: resolver
4+#
5+# Copyright 2018, whitestar
6+#
7+# Licensed under the Apache License, Version 2.0 (the "License");
8+# you may not use this file except in compliance with the License.
9+# You may obtain a copy of the License at
10+#
11+# http://www.apache.org/licenses/LICENSE-2.0
12+#
13+# Unless required by applicable law or agreed to in writing, software
14+# distributed under the License is distributed on an "AS IS" BASIS,
15+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+# See the License for the specific language governing permissions and
17+# limitations under the License.
18+#
19+
20+# autopilot
21+srv = 'resolved'
22+template "/etc/cron.d/#{srv}-local" do
23+ source "etc/cron.d/#{srv}-local"
24+ owner 'root'
25+ group 'root'
26+ mode '0644'
27+ action :delete unless node['platform_utils']['resolver']['autopilot']['enabled']
28+end
--- /dev/null
+++ b/cookbooks/platform_utils/templates/default/etc/cron.d/mount-local
@@ -0,0 +1,9 @@
1+<%
2+name = 'mount'
3+
4+conf = node['platform_utils']['mount']['autopilot']
5+wait_time = conf['wait_time']
6+-%>
7+PATH=/usr/bin:/bin:/usr/local/bin
8+
9+@reboot root sleep <%= wait_time %> && mount-local
--- /dev/null
+++ b/cookbooks/platform_utils/templates/default/etc/cron.d/networking-local
@@ -0,0 +1,30 @@
1+<%
2+name = 'networking'
3+
4+conf = node['platform_utils']['networking']['autopilot']
5+log = "#{conf['log_dir']}/#{name}-local.log"
6+wait_time = conf['wait_time']
7+
8+cmd = nil
9+if File.exist?('/etc/init.d/networking')
10+ cmd = '/etc/init.d/networking restart'
11+else
12+ cmd = 'systemctl restart systemd-networkd'
13+end
14+
15+unless conf['init_type'].nil?
16+ case conf['init_type']
17+ when 'init'
18+ cmd = '/etc/init.d/networking restart'
19+ when 'systemd'
20+ cmd = 'systemctl restart systemd-networkd'
21+ when 'netplan'
22+ cmd = 'netplan apply'
23+ end
24+end
25+-%>
26+PATH=/usr/sbin:/usr/bin:/bin:/usr/local/bin
27+DATE_F='+%Y-%m-%d %H:%M:%S %z'
28+LOG=<%= log %>
29+
30+@reboot root sleep <%= wait_time %> && date "$DATE_F" > $LOG && <%= cmd %> >> $LOG 2>&1 && sleep 10s && ip addr show scope global >> $LOG 2>&1
--- /dev/null
+++ b/cookbooks/platform_utils/templates/default/etc/cron.d/resolved-local
@@ -0,0 +1,13 @@
1+<%
2+name = 'resolved'
3+
4+conf = node['platform_utils']['resolver']['autopilot']
5+log = "#{conf['log_dir']}/#{name}-local.log"
6+wait_time = conf['wait_time']
7+-%>
8+PATH=/usr/bin:/bin:/usr/local/bin
9+DATE_F='+%Y-%m-%d %H:%M:%S %z'
10+LOG=<%= log %>
11+NAME=systemd-resolved
12+
13+@reboot root sleep <%= wait_time %> && date "$DATE_F" > $LOG && systemctl restart $NAME >> $LOG 2>&1 && systemctl status $NAME >> $LOG 2>&1
--- /dev/null
+++ b/cookbooks/platform_utils/templates/default/usr/local/bin/mount-local
@@ -0,0 +1,24 @@
1+#!/bin/sh
2+<%
3+name = 'mount'
4+
5+conf = node['platform_utils']['mount']['autopilot']
6+log = "#{conf['log_dir']}/#{name}-local.log"
7+
8+mount_points = conf['mount_points']
9+-%>
10+PATH=/usr/bin:/bin:/usr/local/bin
11+DATE_F='+%Y-%m-%d %H:%M:%S %z'
12+LOG=<%= log %>
13+mount_points='<%= mount_points.join(' ') %>'
14+
15+date "$DATE_F" > $LOG
16+for m in $mount_points; do
17+ if mount | grep -sq $m; then
18+ echo "$m is already mounted." >> $LOG
19+ else
20+ echo "$m is not mounted yet." >> $LOG
21+ echo "mount $m ..." >> $LOG
22+ mount -v $m >> $LOG 2>&1
23+ fi
24+done
--- a/cookbooks/platform_utils/version
+++ b/cookbooks/platform_utils/version
@@ -1 +1 @@
1-0.6.0
1+0.7.0
Show on old repository browser