• R/O
  • HTTP
  • SSH
  • HTTPS

grid-chef-repo: Commit

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


Commit MetaInfo

Revision00a05ae07850ee0f2601a3aca8d4258cda5394dd (tree)
Time2018-09-17 19:55:42
Authorwhitestar <whitestar@user...>
Commiterwhitestar

Log Message

adds autopilot features.

Change Summary

Incremental Difference

--- a/cookbooks/samba-grid/CHANGELOG.md
+++ b/cookbooks/samba-grid/CHANGELOG.md
@@ -1,5 +1,9 @@
11 # samba-grid CHANGELOG
22
3+0.2.0
4+-----
5+- adds autopilot features.
6+
37 0.1.3
48 -----
59 - fix service control.
--- a/cookbooks/samba-grid/README.md
+++ b/cookbooks/samba-grid/README.md
@@ -32,6 +32,7 @@ This cookbook sets up a Samba server.
3232 |:--|:--|:--|:--|
3333 |`['samba-grid']['group']['sambashare']['gid']`|String|`sambashare` group gid.|`nil`|
3434 |`['samba-grid']['group']['sambashare']['members']`|Array|`sambashare` group members|`[]`|
35+|`['samba-grid']['autopilot']`|Hash|Samba services's autopilot configurations.|See `attributes/default.rb`|
3536 |`['samba-grid']['smb.conf']`|Hash|Samba configurations.|See `attributes/default.rb`|
3637 |`['samba-grid']['smb.conf']['global']`|Hash|`[global]` section configurations in the `smb.conf`.|`{}`|
3738 |`['samba-grid']['smb.conf']['homes']`|Hash|`[homes]` section configurations in the `smb.conf`.|`{}`|
@@ -179,7 +180,7 @@ override_attributes(
179180 - Author:: whitestar at osdn.jp
180181
181182 ```text
182-Copyright 2016-2017, whitestar
183+Copyright 2016-2018, whitestar
183184
184185 Licensed under the Apache License, Version 2.0 (the "License");
185186 you may not use this file except in compliance with the License.
--- a/cookbooks/samba-grid/attributes/default.rb
+++ b/cookbooks/samba-grid/attributes/default.rb
@@ -2,7 +2,7 @@
22 # Cookbook Name:: samba-grid
33 # Attributes:: default
44 #
5-# Copyright 2016, whitestar
5+# Copyright 2016-2018, whitestar
66 #
77 # Licensed under the Apache License, Version 2.0 (the "License");
88 # you may not use this file except in compliance with the License.
@@ -21,6 +21,11 @@ default['samba-grid']['group']['sambashare'] = {
2121 'gid' => nil,
2222 'members' => [],
2323 }
24+default['samba-grid']['autopilot'] = {
25+ 'enabled' => false,
26+ 'log_dir' => '/var/log',
27+ 'wait_time' => '180s',
28+}
2429 default['samba-grid']['smb.conf'] = {
2530 'global' => {
2631 #'workgroup' => 'WORKGROUP',
--- a/cookbooks/samba-grid/recipes/server.rb
+++ b/cookbooks/samba-grid/recipes/server.rb
@@ -67,3 +67,13 @@ template '/etc/samba/smb.conf' do
6767 notifies :restart, 'service[samba-ad-dc]' if platform == 'debian' && platform_version < '9.0'
6868 #notifies :reload, 'service[samba]'
6969 end
70+
71+# autopilot
72+srv = 'samba'
73+template "/etc/cron.d/#{srv}-local" do
74+ source "etc/cron.d/#{srv}-local"
75+ owner 'root'
76+ group 'root'
77+ mode '0644'
78+ action :delete unless node['samba-grid']['autopilot']['enabled']
79+end
--- /dev/null
+++ b/cookbooks/samba-grid/templates/default/etc/cron.d/samba-local
@@ -0,0 +1,22 @@
1+<%
2+name = 'samba'
3+
4+conf = node['samba-grid']['autopilot']
5+log = "#{conf['log_dir']}/#{name}-local.log"
6+wait_time = conf['wait_time']
7+
8+cmd = nil
9+st_cmd = nil
10+if File.exist?('/etc/init.d/samba')
11+ cmd = '/etc/init.d/samba restart'
12+ st_cmd = '/etc/init.d/samba status'
13+else
14+ cmd = 'systemctl restart nmbd smbd'
15+ st_cmd = 'systemctl status nmbd smbd'
16+end
17+-%>
18+PATH=/usr/bin:/bin:/usr/local/bin
19+DATE_F='+%Y-%m-%d %H:%M:%S %z'
20+LOG=<%= log %>
21+
22+@reboot root sleep <%= wait_time %> && date "$DATE_F" > $LOG && <%= cmd %> >> $LOG 2>&1 && <%= st_cmd %> >> $LOG 2>&1
--- a/cookbooks/samba-grid/version
+++ b/cookbooks/samba-grid/version
@@ -1 +1 @@
1-0.1.3
1+0.2.0
Show on old repository browser