• R/O
  • HTTP
  • SSH
  • HTTPS

grid-chef-repo: Commit

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


Commit MetaInfo

Revision5337d155fe9840857803948577e625c99c813830 (tree)
Time2018-09-18 22:33:39
Authorwhitestar <whitestar@user...>
Commiterwhitestar

Log Message

adds autopilot features.

Change Summary

Incremental Difference

--- a/cookbooks/squid-proxy/CHANGELOG.md
+++ b/cookbooks/squid-proxy/CHANGELOG.md
@@ -1,5 +1,9 @@
11 # squid-proxy CHANGELOG
22
3+0.2.0
4+-----
5+- adds autopilot features.
6+
37 0.1.1
48 -----
59 - adds cache directories creation.
--- a/cookbooks/squid-proxy/README.md
+++ b/cookbooks/squid-proxy/README.md
@@ -28,6 +28,7 @@ This cookbook sets up a Squid server.
2828
2929 |Key|Type|Description, example|Default|
3030 |:--|:--|:--|:--|
31+|`['squid-proxy']['autopilot']`|Hash|Autopilot configurations.|See `attribute/default.rb`|
3132 |`['squid-proxy']['with_cgi']`|Boolean|with Cache Manager CGI.|`'false'`|
3233 |`['squid-proxy']['conf']['http_port']`|String|e.g. `'192.168.1.10:3128'`|`'0.0.0.0:3128'`|
3334 |`['squid-proxy']['conf']['extra_http_ports']`|Array|Extra service bind addresses. e.g. `['127.0.0.1:3128']`|`[]`|
--- a/cookbooks/squid-proxy/attributes/default.rb
+++ b/cookbooks/squid-proxy/attributes/default.rb
@@ -2,7 +2,7 @@
22 # Cookbook Name:: squid-proxy
33 # Attributes:: default
44 #
5-# Copyright 2017, whitestar
5+# Copyright 2017-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.
@@ -17,6 +17,11 @@
1717 # limitations under the License.
1818 #
1919
20+default['squid-proxy']['autopilot'] = {
21+ 'enabled' => false,
22+ 'log_dir' => '/var/log',
23+ 'wait_time' => '120s',
24+}
2025 default['squid-proxy']['with_cgi'] = false
2126 default['squid-proxy']['conf'] = {
2227 'http_port' => '0.0.0.0:3128', # e.g. '127.0.0.1:3128'
--- a/cookbooks/squid-proxy/recipes/server.rb
+++ b/cookbooks/squid-proxy/recipes/server.rb
@@ -52,3 +52,13 @@ template '/etc/squid/squid.conf' do
5252 action :create
5353 notifies :reload, 'service[squid]'
5454 end
55+
56+# autopilot
57+srv = 'squid'
58+template "/etc/cron.d/#{srv}-local" do
59+ source "etc/cron.d/#{srv}-local"
60+ owner 'root'
61+ group 'root'
62+ mode '0644'
63+ action :delete unless node['squid-proxy']['autopilot']['enabled']
64+end
--- /dev/null
+++ b/cookbooks/squid-proxy/templates/default/etc/cron.d/squid-local
@@ -0,0 +1,13 @@
1+<%
2+name = 'squid'
3+
4+conf = node['squid-proxy']['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=<%= name %>
12+
13+@reboot root sleep <%= wait_time %> && date "$DATE_F" > $LOG && systemctl restart $NAME >> $LOG 2>&1 && systemctl status $NAME >> $LOG 2>&1
--- a/cookbooks/squid-proxy/version
+++ b/cookbooks/squid-proxy/version
@@ -1 +1 @@
1-0.1.1
1+0.2.0
Show on old repository browser