Grid環境構築用のChefリポジトリです。
Revision | a400845b615741c77c0e696f8717950cfb0b5af2 (tree) |
---|---|
Time | 2018-09-17 16:30:43 |
Author | whitestar <whitestar@user...> |
Commiter | whitestar |
adds autopilot features.
@@ -1,5 +1,9 @@ | ||
1 | 1 | # screwdriver CHANGELOG |
2 | 2 | |
3 | +0.8.0 | |
4 | +----- | |
5 | +- adds autopilot feature. | |
6 | + | |
3 | 7 | 0.7.0 |
4 | 8 | ----- |
5 | 9 | - fix MySQL data directory's group owner. |
@@ -65,6 +65,7 @@ This cookbook sets up a Screwdriver CI/CD service by Docker Compose. | ||
65 | 65 | |`['screwdriver']['api']['scms_vault_items']`|Hash|This hash contains Chef Vault item definitions of SCM's secrets.|See `attributes/default.rb`| |
66 | 66 | |`['screwdriver']['store']['backend']`|String|`nil` (in memory) or `'minio'`.|`nil`| |
67 | 67 | |`['screwdriver']['store']['config']`|Hash|This hash object is expanded to a `/config/local.yaml` file in the Store Docker container.|See `attributes/default.rb`| |
68 | +|`['screwdriver']['docker-compose']['autopilot']`|Hash|Autopilot configurations.|See `attributes/default.rb`| | |
68 | 69 | |`['screwdriver']['docker-compose']['import_ca']`|Boolean|whether import internal CA certificates or not.|`false`| |
69 | 70 | |`['screwdriver']['docker-compose']['app_dir']`|String|Path string.|`"#{node['docker-grid']['compose']['app_dir']}/screwdriver"`| |
70 | 71 | |`['screwdriver']['docker-compose']['bin_dir']`|String|Path string.|`"#{node['screwdriver']['docker-compose']['app_dir']}/bin"`| |
@@ -3,6 +3,58 @@ require 'rubocop/rake_task' | ||
3 | 3 | require 'foodcritic' |
4 | 4 | require 'stove/rake_task' |
5 | 5 | |
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 | + | |
6 | 58 | namespace :style do |
7 | 59 | desc 'Run Ruby style checks' |
8 | 60 | RuboCop::RakeTask.new(:ruby) do |t| |
@@ -279,6 +279,13 @@ default['screwdriver']['store']['config'] = { | ||
279 | 279 | |
280 | 280 | # Useless?! |
281 | 281 | force_override['screwdriver']['docker-compose']['import_ca'] = false |
282 | +default['screwdriver']['docker-compose']['autopilot'] = { | |
283 | + 'enabled' => false, | |
284 | + 'log_dir' => '/var/log', | |
285 | + 'wait_time' => '180s', | |
286 | + 'docker-compose_opts' => '--no-ansi', | |
287 | + #'docker-compose_opts' => '', # for the old docker-compose | |
288 | +} | |
282 | 289 | default['screwdriver']['docker-compose']['app_dir'] = "#{node['docker-grid']['compose']['app_dir']}/screwdriver" |
283 | 290 | default['screwdriver']['docker-compose']['bin_dir'] = "#{node['screwdriver']['docker-compose']['app_dir']}/bin" |
284 | 291 | default['screwdriver']['docker-compose']['config_dir'] = "#{node['screwdriver']['docker-compose']['app_dir']}/config" |
@@ -1,5 +1,4 @@ | ||
1 | 1 | --- |
2 | -# $ fly -t $CC_TARGET sp -p screwdriver-cookbook -c concourse.yml -l fly-vars.yml -l ~/sec/credentials-prod.yml | |
3 | 2 | resources: |
4 | 3 | - name: src-git |
5 | 4 | type: git |
@@ -0,0 +1,2 @@ | ||
1 | +--- | |
2 | +cookbook-name: screwdriver |
@@ -1,3 +1,2 @@ | ||
1 | 1 | --- |
2 | -cookbook-name: screwdriver | |
3 | 2 | chefdk-version: 1.6.11 |
@@ -591,6 +591,16 @@ template config_file do | ||
591 | 591 | mode '0644' |
592 | 592 | end |
593 | 593 | |
594 | +# autopilot | |
595 | +srv = 'screwdriver' | |
596 | +template "/etc/cron.d/#{srv}-local" do | |
597 | + source "etc/cron.d/#{srv}-local" | |
598 | + owner 'root' | |
599 | + group 'root' | |
600 | + mode '0644' | |
601 | + action :delete unless node['screwdriver']['docker-compose']['autopilot']['enabled'] | |
602 | +end | |
603 | + | |
594 | 604 | log 'screwdriver docker-compose post install message' do |
595 | 605 | message <<-"EOM" |
596 | 606 | Note: You must execute the following command manually. |
@@ -0,0 +1,16 @@ | ||
1 | +<% | |
2 | +name = 'screwdriver' | |
3 | + | |
4 | +conf = node['screwdriver']['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['screwdriver']['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 |
@@ -1 +1 @@ | ||
1 | -0.7.0 | |
1 | +0.8.0 |