• R/O
  • HTTP
  • SSH
  • HTTPS

grid-chef-repo: Commit

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


Commit MetaInfo

Revisionc8d9a05d7ba415afd4b136c264e2b1839b4e5271 (tree)
Time2018-09-17 15:26:17
Authorwhitestar <whitestar@user...>
Commiterwhitestar

Log Message

adds autopilot features.

Change Summary

Incremental Difference

--- a/cookbooks/minim-server/CHANGELOG.md
+++ b/cookbooks/minim-server/CHANGELOG.md
@@ -1,5 +1,9 @@
11 # minim-server CHANGELOG
22
3+0.2.0
4+-----
5+- adds autopilot features.
6+
37 0.1.1
48 -----
59 - update documents.
--- /dev/null
+++ b/cookbooks/minim-server/Gemfile.lock
@@ -0,0 +1,22 @@
1+GEM
2+ remote: https://rubygems.org/
3+ specs:
4+ chef-api (0.8.0)
5+ logify (~> 0.1)
6+ mime-types
7+ logify (0.2.0)
8+ mime-types (3.2.2)
9+ mime-types-data (~> 3.2015)
10+ mime-types-data (3.2018.0812)
11+ stove (6.0.0)
12+ chef-api (~> 0.5)
13+ logify (~> 0.2)
14+
15+PLATFORMS
16+ ruby
17+
18+DEPENDENCIES
19+ stove
20+
21+BUNDLED WITH
22+ 1.16.0
--- a/cookbooks/minim-server/README.md
+++ b/cookbooks/minim-server/README.md
@@ -35,6 +35,7 @@ Note: do not push a Docker image including MinimServer to any public registries,
3535 |Key|Type|Description, example|Default|
3636 |:--|:--|:--|:--|
3737 |`['minim-server']['Dockerfile']['FROM']`|String|Base image in the `Dockerfile`.|See `attributes/default.rb`|
38+|`['minim-server']['docker-compose']['autopilot']`|Hash|Autopilot configurations.|See `attributes/default.rb`|
3839 |`['minim-server']['docker-compose']['app_dir']`|String||`"#{node['docker-grid']['compose']['app_dir']}/minim-server"`|
3940 |`['minim-server']['docker-compose']['data_dir']`|String||`"#{node['minim-server']['docker-compose']['app_dir']}/data"`|
4041 |`['minim-server']['docker-compose']['dot_env']`|Hash|`.env` configurations.|See `attributes/default.rb`|
--- a/cookbooks/minim-server/Rakefile
+++ b/cookbooks/minim-server/Rakefile
@@ -3,6 +3,58 @@ require 'rubocop/rake_task'
33 require 'foodcritic'
44 require 'stove/rake_task'
55
6+tpl_cookbook = '00cookbook'
7+cookbook_name = File.basename(Dir.pwd)
8+
9+desc 'Initialize project'
10+task :init do
11+ next if cookbook_name == tpl_cookbook
12+
13+ [
14+ '.foodcritic',
15+ '.rubocop.yml',
16+ 'Berksfile',
17+ 'concourse.yml',
18+ 'fly-vars.yml',
19+ 'fly-vars.local.yml',
20+ 'Gemfile',
21+ 'Gemfile.lock',
22+ 'version',
23+ ].each {|conf|
24+ sh "cp ../#{tpl_cookbook}/#{conf} ./" unless File.exist?(conf)
25+ }
26+
27+ ruby [
28+ %(-pne '$_.gsub!(/^cookbook-name: .*$/, "cookbook-name: #{cookbook_name}")'),
29+ '-i fly-vars.local.yml',
30+ ].join(' ')
31+end
32+
33+desc 'Update project'
34+task :update do
35+ next if cookbook_name == tpl_cookbook
36+
37+ [
38+ 'Rakefile',
39+ 'concourse.yml',
40+ 'fly-vars.yml',
41+ 'Gemfile',
42+ 'Gemfile.lock',
43+ ].each {|conf|
44+ sh "cp ../#{tpl_cookbook}/#{conf} ./"
45+ }
46+end
47+
48+desc 'fly set-pipeline'
49+task :'set-pipeline' do
50+ sh [
51+ "fly -t $CC_TARGET sp -p #{cookbook_name}-cookbook -c concourse.yml",
52+ '-l fly-vars.yml -l fly-vars.local.yml -l ~/sec/credentials-prod.yml',
53+ ].join(' ')
54+end
55+desc 'rake set-pipeline alias'
56+task sp: 'set-pipeline'
57+
658 namespace :style do
759 desc 'Run Ruby style checks'
860 RuboCop::RakeTask.new(:ruby) do |t|
--- a/cookbooks/minim-server/attributes/default.rb
+++ b/cookbooks/minim-server/attributes/default.rb
@@ -37,6 +37,13 @@ default['minim-server']['Dockerfile'] = {
3737 'FROM' => base_image,
3838 }
3939
40+default['minim-server']['docker-compose']['autopilot'] = {
41+ 'enabled' => false,
42+ 'log_dir' => '/var/log',
43+ 'wait_time' => '180s',
44+ 'docker-compose_opts' => '--no-ansi',
45+ #'docker-compose_opts' => '', # for the old docker-compose
46+}
4047 default['minim-server']['docker-compose']['app_dir'] = "#{node['docker-grid']['compose']['app_dir']}/minim-server"
4148 default['minim-server']['docker-compose']['data_dir'] = "#{node['minim-server']['docker-compose']['app_dir']}/data"
4249
--- a/cookbooks/minim-server/concourse.yml
+++ b/cookbooks/minim-server/concourse.yml
@@ -1,5 +1,4 @@
11 ---
2-# $ fly -t $CC_TARGET sp -p minim-server-cookbook -c concourse.yml -l fly-vars.yml -l ~/sec/credentials-prod.yml
32 resources:
43 - name: src-git
54 type: git
@@ -59,6 +58,7 @@ jobs:
5958 - -c
6059 - |
6160 cd ./src-git/cookbooks/((cookbook-name))
61+ bundle config --local silence_root_warning 1
6262 bundle install
6363 rake
6464 - name: publish-cookbook
@@ -89,6 +89,7 @@ jobs:
8989 echo '{"username":"((chef-username))","key":"/root/chef-client-key.pem"}' > /root/.stove
9090 echo "$chef_client_key" > /root/chef-client-key.pem
9191 cd ./src-git/cookbooks/((cookbook-name))
92+ bundle config --local silence_root_warning 1
9293 bundle install
9394 rake publish
9495 - put: src-git
--- /dev/null
+++ b/cookbooks/minim-server/fly-vars.local.yml
@@ -0,0 +1,2 @@
1+---
2+cookbook-name: minim-server
--- a/cookbooks/minim-server/fly-vars.yml
+++ b/cookbooks/minim-server/fly-vars.yml
@@ -1,3 +1,2 @@
11 ---
2-cookbook-name: minim-server
32 chefdk-version: 1.6.11
--- a/cookbooks/minim-server/recipes/docker-compose.rb
+++ b/cookbooks/minim-server/recipes/docker-compose.rb
@@ -64,6 +64,16 @@ override_config_srvs['minim-server']['volumes'] = vols unless vols.empty?
6464 end
6565 }
6666
67+# autopilot
68+srv = 'minim-server'
69+template "/etc/cron.d/#{srv}-local" do
70+ source "etc/cron.d/#{srv}-local"
71+ owner 'root'
72+ group 'root'
73+ mode '0644'
74+ action :delete unless node['minim-server']['docker-compose']['autopilot']['enabled']
75+end
76+
6777 log 'minim-server docker-compose post install message' do
6878 message <<-"EOM"
6979 Note: You must execute the following command manually.
--- /dev/null
+++ b/cookbooks/minim-server/templates/default/etc/cron.d/minim-server-local
@@ -0,0 +1,16 @@
1+<%
2+name = 'minim-server'
3+
4+conf = node['minim-server']['docker-compose']['autopilot']
5+log = "#{conf['log_dir']}/#{name}-local.log"
6+wait_time = conf['wait_time']
7+
8+opts = conf['docker-compose_opts']
9+-%>
10+PATH=/usr/bin:/bin:/usr/local/bin
11+DATE_F='+%Y-%m-%d %H:%M:%S %z'
12+LOG=<%= log %>
13+APP_HOME=<%= node['minim-server']['docker-compose']['app_dir'] %>
14+OPTS='<%= opts %>'
15+
16+@reboot root sleep <%= wait_time %> && date "$DATE_F" > $LOG && cd $APP_HOME && docker-compose $OPTS down >> $LOG 2>&1 && docker-compose $OPTS up -d >> $LOG 2>&1 && docker-compose ps >> $LOG 2>&1
--- a/cookbooks/minim-server/version
+++ b/cookbooks/minim-server/version
@@ -1 +1 @@
1-0.1.1
1+0.2.0
Show on old repository browser