• R/O
  • HTTP
  • SSH
  • HTTPS

grid-chef-repo: Commit

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


Commit MetaInfo

Revision42cc7bd84b8eaa605858fd93a1d017d033b00d00 (tree)
Time2018-09-17 13:42:57
Authorwhitestar <whitestar@user...>
Commiterwhitestar

Log Message

adds autopilot features.

Change Summary

Incremental Difference

--- a/cookbooks/concourse-ci/CHANGELOG.md
+++ b/cookbooks/concourse-ci/CHANGELOG.md
@@ -1,6 +1,10 @@
11 concourse-ci CHANGELOG
22 ======================
33
4+0.3.0
5+-----
6+- adds autopilot features.
7+
48 0.2.9
59 -----
610 - improves the utility scripts.
--- /dev/null
+++ b/cookbooks/concourse-ci/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/concourse-ci/README.md
+++ b/cookbooks/concourse-ci/README.md
@@ -46,6 +46,7 @@ This cookbook sets up a Concourse CI service by Docker Compose.
4646 |`['concourse-ci']['ssl_cert']['ca_names']`|Array|Internal CA names that are imported by the ssl_cert cookbook.|`[]`|
4747 |`['concourse-ci']['ssl_cert']['common_name']`|String|Server common name for TLS|`node['fqdn']`|
4848 |`['concourse-ci']['docker-image']['entrypoint']`|String|Concourse Docker image's entrypoint setting to import an internal CA certificate.|`'/usr/local/bin/dumb-init /usr/local/bin/concourse'`|
49+|`['concourse-ci']['docker-compose']['autopilot']`|Hash|Concourse autopilot configurations.|See `attributes/default.rb`|`false`|
4950 |`['concourse-ci']['docker-compose']['import_ca']`|Boolean|whether import internal CA certificates or not.|`false`|
5051 |`['concourse-ci']['docker-compose']['app_dir']`|String||`"#{node['docker-grid']['compose']['app_dir']}/concourse"`|
5152 |`['concourse-ci']['docker-compose']['pgdata_dir']`|String|Path string or nil (unset).|`"#{node['concourse-ci']['docker-compose']['app_dir']}/database"`|
@@ -88,6 +89,7 @@ name 'concourse'
8889 description 'Concourse'
8990
9091 run_list(
92+ # see https://osdn.net/projects/metasearch/scm/git/grid-chef-repo/blobs/master/roles/docker-new-repo.rb
9193 'role[docker]',
9294 'recipe[concourse-ci::docker-compose]',
9395 )
--- a/cookbooks/concourse-ci/Rakefile
+++ b/cookbooks/concourse-ci/Rakefile
@@ -3,12 +3,56 @@ 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'
649 task :'set-pipeline' do
750 sh [
8- "fly -t $CC_TARGET sp -p #{File.basename(Dir.pwd)}-cookbook -c concourse.yml",
9- '-l fly-vars.yml -l ~/sec/credentials-prod.yml',
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',
1053 ].join(' ')
1154 end
55+desc 'rake set-pipeline alias'
1256 task sp: 'set-pipeline'
1357
1458 namespace :style do
--- a/cookbooks/concourse-ci/attributes/default.rb
+++ b/cookbooks/concourse-ci/attributes/default.rb
@@ -30,6 +30,12 @@ default['concourse-ci']['with_ssl_cert_cookbook'] = false
3030 default['concourse-ci']['ssl_cert']['ca_names'] = []
3131 default['concourse-ci']['ssl_cert']['common_name'] = node['fqdn']
3232 default['concourse-ci']['docker-image']['entrypoint'] = '/usr/local/bin/dumb-init /usr/local/bin/concourse'
33+default['concourse-ci']['docker-compose']['autopilot'] = {
34+ 'enabled' => false,
35+ 'log_dir' => '/var/log',
36+ 'wait_time' => '180s',
37+ 'workers_prune_period' => '30 */4 * * *',
38+}
3339 default['concourse-ci']['docker-compose']['import_ca'] = false
3440 default['concourse-ci']['docker-compose']['app_dir'] = "#{node['docker-grid']['compose']['app_dir']}/concourse"
3541 default['concourse-ci']['docker-compose']['pgdata_dir'] = "#{node['concourse-ci']['docker-compose']['app_dir']}/database"
--- a/cookbooks/concourse-ci/concourse.yml
+++ b/cookbooks/concourse-ci/concourse.yml
@@ -1,5 +1,4 @@
11 ---
2-# $ fly -t $CC_TARGET sp -p concourse-ci-cookbook -c concourse.yml -l fly-vars.yml -l ~/sec/credentials-prod.yml
32 resources:
43 - name: src-git
54 type: git
--- /dev/null
+++ b/cookbooks/concourse-ci/fly-vars.local.yml
@@ -0,0 +1,2 @@
1+---
2+cookbook-name: concourse-ci
--- a/cookbooks/concourse-ci/fly-vars.yml
+++ b/cookbooks/concourse-ci/fly-vars.yml
@@ -1,3 +1,2 @@
11 ---
2-cookbook-name: concourse-ci
32 chefdk-version: 1.6.11
--- a/cookbooks/concourse-ci/recipes/docker-compose.rb
+++ b/cookbooks/concourse-ci/recipes/docker-compose.rb
@@ -323,6 +323,16 @@ template "#{bin_dir}/concourse_start" do
323323 action :create
324324 end
325325
326+# autopilot
327+srv = 'concourse'
328+template "/etc/cron.d/#{srv}-local" do
329+ source "etc/cron.d/#{srv}-local"
330+ owner 'root'
331+ group 'root'
332+ mode '0644'
333+ action :delete unless node['concourse-ci']['docker-compose']['autopilot']['enabled']
334+end
335+
326336 log <<-"EOM"
327337 Note: You must execute the following command manually.
328338 See #{doc_url}
--- /dev/null
+++ b/cookbooks/concourse-ci/templates/default/etc/cron.d/concourse-local
@@ -0,0 +1,13 @@
1+<%
2+name = 'concourse'
3+
4+conf = node['concourse-ci']['docker-compose']['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+LOG=<%= log %>
10+APP_HOME=<%= node['concourse-ci']['docker-compose']['app_dir'] %>
11+
12+@reboot root sleep <%= wait_time %> && ${APP_HOME}/bin/concourse_start > $LOG 2>&1
13+<%= conf['workers_prune_period'] %> root ${APP_HOME}/bin/fly_prune_workers_main >> $LOG 2>&1
--- a/cookbooks/concourse-ci/version
+++ b/cookbooks/concourse-ci/version
@@ -1 +1 @@
1-0.2.9
1+0.3.0
Show on old repository browser