OSDN Git Service

6ae3a9bbdcf4162e4c0651bc11f16110ee236c9a
[metasearch/grid-chef-repo.git] / cookbooks / screwdriver / attributes / default.rb
1 #
2 # Cookbook Name:: screwdriver
3 # Attributes:: default
4 #
5 # Copyright 2017, whitestar
6 #
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
10 #
11 #     http://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 #
19
20 default['screwdriver']['with_ssl_cert_cookbook'] = false
21 # If ['screwdriver']['with_ssl_cert_cookbook'] is true,
22 # node['screwdriver']['docker-compose']['config']
23 # are overridden by the following 'common_name' attributes.
24 default['screwdriver']['ssl_cert']['ca_names'] = []
25 default['screwdriver']['ssl_cert']['common_name'] = node['fqdn']
26 cn = node['screwdriver']['ssl_cert']['common_name']
27 cn = node['ipaddress'] if cn.nil? || cn.empty?
28
29 default['screwdriver']['jwt_private_key_vault_item'] = {
30 =begin
31   'vault' => 'screwdriver',
32   'name' => 'jwt_private_key',
33   # single secret or nested hash secret path delimited by slash
34   'env_context' => false,
35   'key' => 'private',  # real hash path: "/private"
36   # or nested hash secret path delimited by slash
37   #'env_context' => true,
38   #'key' => 'hash/path/to/private',  # real hash path: "/#{node.chef_environment}/hash/path/to/private"
39 =end
40 }
41 default['screwdriver']['jwt_public_key_vault_item'] = {
42 =begin
43   'vault' => 'screwdriver',
44   'name' => 'jwt_public_key',
45   # single secret or nested hash secret path delimited by slash
46   'env_context' => false,
47   'key' => 'public',  # real hash path: "/public"
48   # or nested hash secret path delimited by slash
49   #'env_context' => true,
50   #'key' => 'hash/path/to/public',  # real hash path: "/#{node.chef_environment}/hash/path/to/public"
51 =end
52 }
53 # A password used for encrypting session data. Needs to be minimum 32 characters
54 default['screwdriver']['cookie_password_vault_item'] = {
55 =begin
56   'vault' => 'screwdriver',
57   'name' => 'cookie_password',
58   # single password or nested hash password path delimited by slash
59   'env_context' => false,
60   'key' => 'password',  # real hash path: "/password"
61   # or nested hash password path delimited by slash
62   #'env_context' => true,
63   #'key' => 'hash/path/to/password',  # real hash path: "/#{node.chef_environment}/hash/path/to/password"
64 =end
65 }
66 # A password used for encrypting stored secrets. Needs to be minimum 32 characters
67 default['screwdriver']['password_vault_item'] = {
68 =begin
69   'vault' => 'screwdriver',
70   'name' => 'password',
71   # single password or nested hash password path delimited by slash
72   'env_context' => false,
73   'key' => 'password',  # real hash path: "/password"
74   # or nested hash password path delimited by slash
75   #'env_context' => true,
76   #'key' => 'hash/path/to/password',  # real hash path: "/#{node.chef_environment}/hash/path/to/password"
77 =end
78 }
79 # A password used for hashing user/pipeline access tokens. Needs to be minimum 32 characters
80 default['screwdriver']['hashing_password_vault_item'] = {
81 =begin
82   'vault' => 'screwdriver',
83   'name' => 'hashing_password',
84   # single password or nested hash password path delimited by slash
85   'env_context' => false,
86   'key' => 'password',  # real hash path: "/password"
87   # or nested hash password path delimited by slash
88   #'env_context' => true,
89   #'key' => 'hash/path/to/password',  # real hash path: "/#{node.chef_environment}/hash/path/to/password"
90 =end
91 }
92 default['screwdriver']['db_username_vault_item'] = {
93 =begin
94   'vault' => 'screwdriver',
95   'name' => 'db_username',
96   # single usernaem or nested hash username path delimited by slash
97   'env_context' => false,
98   'key' => 'username',  # real hash path: "/username"
99   # or nested hash username path delimited by slash
100   #'env_context' => true,
101   #'key' => 'hash/path/to/username',  # real hash path: "/#{node.chef_environment}/hash/path/to/username"
102 =end
103 }
104 default['screwdriver']['db_password_vault_item'] = {
105 =begin
106   'vault' => 'screwdriver',
107   'name' => 'db_password',
108   # single password or nested hash password path delimited by slash
109   'env_context' => false,
110   'key' => 'password',  # real hash path: "/password"
111   # or nested hash password path delimited by slash
112   #'env_context' => true,
113   #'key' => 'hash/path/to/password',  # real hash path: "/#{node.chef_environment}/hash/path/to/password"
114 =end
115 }
116 default['screwdriver']['db_root_password_vault_item'] = {
117 =begin
118   'vault' => 'screwdriver',
119   'name' => 'db_root_password',
120   # single password or nested hash password path delimited by slash
121   'env_context' => false,
122   'key' => 'password',  # real hash path: "/password"
123   # or nested hash password path delimited by slash
124   #'env_context' => true,
125   #'key' => 'hash/path/to/password',  # real hash path: "/#{node.chef_environment}/hash/path/to/password"
126 =end
127 }
128 default['screwdriver']['s3_access_key_id_vault_item'] = {
129 =begin
130   'vault' => 'screwdriver',
131   'name' => 's3_access_key',
132   # single key id or nested hash key id path delimited by slash
133   'env_context' => false,
134   'key' => 'kid',  # real hash path: "/kid"
135   # or nested hash key id path delimited by slash
136   #'env_context' => true,
137   #'key' => 'hash/path/to/kid',  # real hash path: "/#{node.chef_environment}/hash/path/to/kid"
138 =end
139 }
140 default['screwdriver']['s3_access_key_secret_vault_item'] = {
141 =begin
142   'vault' => 'screwdriver',
143   'name' => 's3_access_key',
144   # single secret or nested hash secret path delimited by slash
145   'env_context' => false,
146   'key' => 'secret',  # real hash path: "/secret"
147   # or nested hash secret path delimited by slash
148   #'env_context' => true,
149   #'key' => 'hash/path/to/secret',  # real hash path: "/#{node.chef_environment}/hash/path/to/secret"
150 =end
151 }
152
153 force_override['screwdriver']['ui']['tls_setup_mode'] = 'reverseproxy'
154 # These hash objects are expanded to a `/config/local.yaml` file in each Docker container.
155 default['screwdriver']['api']['config'] = {
156   'auth' => {},
157   'httpd' => {
158     'tls' => false,
159   },
160   'executor' => {
161 =begin
162     # default
163     'plugin' => 'docker',
164     'docker' => {
165       'options' => {
166         'docker' => {
167           'socketPath' => '/var/run/docker.sock',
168         },
169         'launchVersion' => 'stable',
170       },
171     },
172     # TODO: implement default settings
173     'queue' => {
174       'enabled' => 'false',  # EXECUTOR_QUEUE_ENABLED
175       'options' => {
176         # Configuration of the redis instance containing resque
177         'redisConnection' => {
178           'host' => 'QUEUE_REDIS_HOST',
179           'port' => 'QUEUE_REDIS_PORT',
180           'options' => {
181             'password' => 'QUEUE_REDIS_PASSWORD',
182             'tls' => 'QUEUE_REDIS_TLS_ENABLED',
183           },
184           'database' => 'QUEUE_REDIS_DATABASE',
185         },
186       },
187     },
188 =end
189   },
190   'scms' => {
191 =begin
192     'scm_a' => {  # id and display name
193       'plugin' => 'github',
194       'config' => {
195         # These 3 secrets should be set by the following `['screwdriver']['api']['scms_vault_items']` attribute.
196         'oauthClientId' => 'YOU-PROBABLY-WANT-SOMETHING-HERE',  # The client id used for OAuth with github. GitHub OAuth (https://developer.github.com/v3/oauth/)
197         'oauthClientSecret' => 'AGAIN-SOMETHING-HERE-IS-USEFUL',  # The client secret used for OAuth with github
198         'secret' => 'SUPER-SECRET-SIGNING-THING',  # Secret to add to GitHub webhooks so that we can validate them
199         'gheHost' => 'github.screwdriver.cd',  # [Optional] GitHub enterprise host
200         'username' => 'sd-buildbot',  # [Optional] Username for code checkout
201         'email' => 'dev-null@screwdriver.cd',  # [Optional] Email for code checkout
202         'privateRepo' => false,  # [Optional] Set to true to support private repo; will need read and write access to public and private repos (https://developer.github.com/v3/oauth/#scopes)
203       },
204     },
205     'scm_b' => {  # id and display name
206       'plugin' => 'bitbucket',
207       'config' => {
208         'oauthClientId' => 'YOUR-APP-KEY',
209         'oauthClientSecret' => 'YOUR-APP-SECRET',
210       },
211     },
212 =end
213   },
214 }
215 default['screwdriver']['api']['scms_vault_items'] = {
216 =begin
217   'scm_a' => {
218     'oauthClientId' => {
219       'vault' => 'screwdriver',
220       'name' => 'scm_a',
221       # single oauthClientId or nested hash oauthClientId path delimited by slash
222       'env_context' => false,
223       'key' => 'oauthClientId',  # real hash path: "/oauthClientId", Note: do not use `id`, which is preserved by Chef Vault.
224       # or nested hash id path delimited by slash
225       #'env_context' => true,
226       #'key' => 'hash/path/to/oauthClientId',  # real hash path: "/#{node.chef_environment}/hash/path/to/oauthClientId"
227     },
228     'oauthClientSecret' => {
229       'vault' => 'screwdriver',
230       'name' => 'scm_a',
231       # single oauthClientSecret or nested hash oauthClientSecret path delimited by slash
232       'env_context' => false,
233       'key' => 'oauthClientSecret',  # real hash path: "/oauthClientSecret"
234       # or nested hash secret path delimited by slash
235       #'env_context' => true,
236       #'key' => 'hash/path/to/oauthClientSecret',  # real hash path: "/#{node.chef_environment}/hash/path/to/oauthClientSecret"
237     },
238     # GitHub only.
239     'secret' => {
240       'vault' => 'screwdriver',
241       'name' => 'scm_a',
242       # single secret or nested hash secret path delimited by slash
243       'env_context' => false,
244       'key' => 'secret',  # real hash path: "/secret"
245       # or nested hash password path delimited by slash
246       #'env_context' => true,
247       #'key' => 'hash/path/to/secret',  # real hash path: "/#{node.chef_environment}/hash/path/to/secret"
248     },
249   },
250   'scm_b' => {
251     # ...
252   },
253   # ...
254 =end
255 }
256
257 default['screwdriver']['store']['backend'] = nil  # or 'minio'
258 default['screwdriver']['store']['config'] = {
259   'auth' => {},
260   'httpd' => {
261     'tls' => false,
262   },
263 =begin
264   # for Minio
265   'strategy' => {
266     'plugin' => 's3',
267     's3' => {
268       'accessKeyId' => '',
269       'secretAccessKey' => '****************************************',
270       'region' => 'us-east-1',
271       'bucket' => 'screwdriver',
272       'endpoint' => 'http://s3:9000/screwdriver',
273       'signatureVersion' => 'v4',
274     },
275   },
276 =end
277 }
278
279 # Useless?!
280 force_override['screwdriver']['docker-compose']['import_ca'] = false
281 default['screwdriver']['docker-compose']['app_dir'] = "#{node['docker-grid']['compose']['app_dir']}/screwdriver"
282 default['screwdriver']['docker-compose']['bin_dir'] = "#{node['screwdriver']['docker-compose']['app_dir']}/bin"
283 default['screwdriver']['docker-compose']['config_dir'] = "#{node['screwdriver']['docker-compose']['app_dir']}/config"
284 default['screwdriver']['docker-compose']['data_dir'] = "#{node['screwdriver']['docker-compose']['app_dir']}/data"
285 default['screwdriver']['docker-compose']['etc_dir'] = "#{node['screwdriver']['docker-compose']['app_dir']}/etc"
286 default['screwdriver']['docker-compose']['network_mode_bridge'] = false
287 default['screwdriver']['docker-compose']['jwt_private_key_reset'] = false
288
289 # **DEPRECATED**: use ['screwdriver']['(jwt|cookie|password)_*_vault_item'] attributes.
290 default['screwdriver']['docker-compose']['jwt_private_key_vault_item'] = {}
291 default['screwdriver']['docker-compose']['jwt_public_key_vault_item'] = {}
292 default['screwdriver']['docker-compose']['cookie_password_vault_item'] = {}
293 default['screwdriver']['docker-compose']['password_vault_item'] = {}
294
295 # **DEPRECATED**: use the above `['screwdriver']['api']['scms_vault_items']` attribute.
296 default['screwdriver']['docker-compose']['oauth_client_id_vault_item'] = {
297 =begin
298   'vault' => 'screwdriver',
299   'name' => 'oauth_client_id',
300   # single cid or nested hash cid path delimited by slash
301   'env_context' => false,
302   'key' => 'cid',  # real hash path: "/cid", Note: do not use `id`, which is preserved by Chef Vault.
303   # or nested hash id path delimited by slash
304   #'env_context' => true,
305   #'key' => 'hash/path/to/cid',  # real hash path: "/#{node.chef_environment}/hash/path/to/cid"
306 =end
307 }
308 # **DEPRECATED**: use the above `['screwdriver']['api']['scms_vault_items']` attribute.
309 default['screwdriver']['docker-compose']['oauth_client_secret_vault_item'] = {
310 =begin
311   'vault' => 'screwdriver',
312   'name' => 'oauth_client_secret',
313   # single secret or nested hash secret path delimited by slash
314   'env_context' => false,
315   'key' => 'secret',  # real hash path: "/secret"
316   # or nested hash secret path delimited by slash
317   #'env_context' => true,
318   #'key' => 'hash/path/to/secret',  # real hash path: "/#{node.chef_environment}/hash/path/to/secret"
319 =end
320 }
321 # **DEPRECATED**: use the above `['screwdriver']['api']['scms_vault_items']` attribute.
322 default['screwdriver']['docker-compose']['webhook_github_secret_vault_item'] = {
323 =begin
324   'vault' => 'screwdriver',
325   'name' => 'webhook_github_secret',
326   # single password or nested hash password path delimited by slash
327   'env_context' => false,
328   'key' => 'secret',  # real hash path: "/secret"
329   # or nested hash password path delimited by slash
330   #'env_context' => true,
331   #'key' => 'hash/path/to/secret',  # real hash path: "/#{node.chef_environment}/hash/path/to/secret"
332 =end
333 }
334
335 # ref: https://github.com/screwdriver-cd/screwdriver/blob/master/in-a-box.py
336 force_override['screwdriver']['docker-compose']['config_format_version'] = '2'
337 version_2_config = {
338   # Version 2 docker-compose format
339   'version' => '2',
340   'services' => {
341     # this service will be active if the `['screwdriver']['with_ssl_cert_cookbook']` attribute is true.
342     'reverseproxy' => {
343       'depends_on' => [
344         'ui',
345       ],
346       'restart' => 'always',
347       'image' => 'nginx:alpine',
348       'expose' => [
349         '9000',
350       ],
351       'ports' => [
352         #'9000:9000',  # default
353       ],
354       'volumes' => [
355         # This volume will be set by the screwdriver::docker-compose recipe automatically.
356         #"#{node['screwdriver']['docker-compose']['etc_dir']}/nginx/nginx.conf:/etc/nginx/nginx.conf:ro",
357       ],
358     },
359     'api' => {
360       'image' => 'screwdrivercd/screwdriver:latest',
361       'command' => 'npm start',  # the original command in the Dockerfile.
362       'ports' => [
363         #'9001:80',  # default
364       ],
365       'volumes' => [
366         '/var/run/docker.sock:/var/run/docker.sock:rw',
367         # This volume will be set by the screwdriver::docker-compose recipe automatically.
368         #"#{node['screwdriver']['docker-compose']['data_dir']}:/sd-data:rw",  # for sqlite
369       ],
370       'environment' => {
371         # See:
372         # http://docs.screwdriver.cd/cluster-management/configure-api
373         # https://github.com/screwdriver-cd/screwdriver/blob/master/config/custom-environment-variables.yaml
374         'PORT' => '80',
375         'URI' => "http://#{cn}:9001",
376         #'URI' => "http://#{node['ipaddress']}:9001",  # unrecommended
377         # These vriables will be set by the screwdriver::docker-compose recipe automatically.
378         #'ECOSYSTEM_UI' => "http://#{cn}:9000",                 # Better
379         #'ECOSYSTEM_UI' => "http://#{node['ipaddress']}:9000",  # unrecommended
380         #'ECOSYSTEM_UI' => 'http://ui',                         # NG: for an access from a client.
381         #'ECOSYSTEM_STORE' => "http://#{cn}:9002",                 # Better
382         #'ECOSYSTEM_STORE' => "http://#{node['ipaddress']}:9002",  # unrecommended
383         #'ECOSYSTEM_STORE' => 'http://store',
384         'SECRET_WHITELIST' => '[]',
385         'SECRET_ADMINS' => '[]',
386         'DATASTORE_PLUGIN' => 'sequelize',
387         'DATASTORE_SEQUELIZE_DATABASE' => 'screwdriver',
388         'DATASTORE_SEQUELIZE_DIALECT' => 'sqlite',
389         # This variable will be set by the screwdriver::docker-compose recipe automatically.
390         #'DATASTORE_SEQUELIZE_STORAGE' => '/sd-data/storage.db',
391         # for MySQL
392         #'DATASTORE_SEQUELIZE_DIALECT' => 'mysql',
393         # These variables will be set by the screwdriver::docker-compose recipe automatically.
394         #'DATASTORE_SEQUELIZE_USERNAME' => '${DB_USERNAME}',
395         #'DATASTORE_SEQUELIZE_PASSWORD' => '${DB_PASSWORD}',
396         #'DATASTORE_SEQUELIZE_HOST' => 'db',
397         # This variable will be set by the screwdriver::docker-compose recipe automatically.
398         #'IS_HTTPS' => 'false',
399         #'NODE_TLS_REJECT_UNAUTHORIZED' => '0',  # workaround for self-signed cetificates
400 =begin
401         # **DEPRECATED**: use the `['screwdriver']['api']['config']['executor']` attribute.
402         'EXECUTOR_PLUGIN' => 'docker',
403         'EXECUTOR_DOCKER_DOCKER' => <<-'EOS',
404 {
405   "socketPath": "/var/run/docker.sock"
406 }
407 EOS
408 =end
409         'EXECUTOR_QUEUE_ENABLED' => 'false',
410         #'QUEUE_REDIS_HOST' => 'queue',
411         # TODO:
412         #'QUEUE_REDIS_PORT' => '',
413         #'QUEUE_REDIS_PASSWORD' => '${REDIS_PASSWORD}'
414         #'QUEUE_REDIS_TLS_ENABLED' => '',
415         #'QUEUE_REDIS_DATABASE' => '',
416 =begin
417         # SCM settings
418         # **DEPRECATED**: Please use the above `['screwdriver']['api']['config']['scms']` attribute
419         # instead of `SCM_SETTINGS` env. variable.
420         # 'SCM_SETTINGS' => '{}',
421         #
422         # **DEPRECATED**: Non-Multiple SCMs setting format.
423         #   - Note: Multiple SCMs not supported yet.
424         #     https://github.com/screwdriver-cd/screwdriver/issues/365
425         #   - OAuth Callback URL: "http://#{cn}:9001/v4/auth/login/web"
426         'SCM_PLUGIN' => 'github',  # or 'gitlab' or 'bitbucket'
427         # * Commons
428         'SCM_USERNAME' => 'sd-buildbot',
429         'SCM_EMAIL' => 'dev-null@screwdriver.cd',
430         # The following variables will be set by the screwdriver::docker-compose recipe automatically.
431         'SECRET_OAUTH_CLIENT_ID' => '${SECRET_OAUTH_CLIENT_ID}',
432         'SECRET_OAUTH_CLIENT_SECRET' => '${SECRET_OAUTH_CLIENT_SECRET}',
433         # * GitHub only
434         'WEBHOOK_GITHUB_SECRET' => '${WEBHOOK_GITHUB_SECRET}',  #'SUPER-SECRET-SIGNING-THING'
435         'SCM_GITHUB_GHE_HOST' => 'gitlab.io.example.com',  # for GHE
436         'SCM_PRIVATE_REPO_SUPPORT' => 'false',
437         # * GitLab only
438         #'SCM_GITLAB_HOST' => 'gitlab.io.example.com',
439         #'SCM_GITLAB_PROTOCOL' => 'https',
440         # * Bitbucket only
441         #   None.
442 =end
443       },
444     },
445     'ui' => {
446       'image' => 'screwdrivercd/ui:latest',
447       'ports' => [
448         #'9000:80',  # default
449       ],
450       'environment' => {
451         # These variables will be set by the screwdriver::docker-compose recipe automatically.
452         #'ECOSYSTEM_API' => 'http://api',                        # NG: for an access from a client.
453         #'ECOSYSTEM_API' => "http://#{cn}:9001",                 # Better
454         #'ECOSYSTEM_API' => "http://#{node['ipaddress']}:9001",  # unrecommended
455         #'ECOSYSTEM_STORE' => 'http://store',
456         #'ECOSYSTEM_STORE' => "http://#{cn}:9002",                 # Better
457         #'ECOSYSTEM_STORE' => "http://#{node['ipaddress']}:9002",  # unrecommended
458       },
459     },
460     'store' => {
461       'image' => 'screwdrivercd/store:latest',
462       'ports' => [
463         #'9002:80',  # default
464       ],
465       'environment' => {
466         # See https://github.com/screwdriver-cd/store/blob/master/config/custom-environment-variables.yaml
467         'PORT' => '80',
468         'URI' => "http://#{cn}:9002",
469         #'URI' => "http://#{node['ipaddress']}:9002",  # unrecommended
470         # These variables will be set by the screwdriver::docker-compose recipe automatically.
471         #'ECOSYSTEM_UI' => "http://#{cn}:9000",  # Better
472         #'ECOSYSTEM_UI' => "http://#{node['ipaddress']}:9000",
473         #'ECOSYSTEM_UI' => 'http://ui',          # NG for an access from a client.
474         #'STRATEGY' => 'memory',  # default
475         # * AWS S3
476         #'STRATEGY' => 's3',
477         # If node['screwdriver']['s3_access_key_{id,secret}_vault_item'] is set,
478         # these 2 variables will be set by the screwdriver::docker-compose recipe automatically.
479         #'S3_ACCESS_KEY_ID' => '${S3_ACCESS_KEY_ID}',
480         #'S3_ACCESS_KEY_SECRET' => '${S3_ACCESS_KEY_SECRET}',
481         #'S3_REGION' => 'us-east-1',
482         #'S3_BUCKET' => 'screwdriver',
483         # * Minio
484         # If node['screwdriver']['store']['backend'] is 'minio',
485         # these variables will be set by the screwdriver::docker-compose recipe automatically.
486         #'STRATEGY' => 's3',
487         #'S3_ACCESS_KEY_ID' => '${S3_ACCESS_KEY_ID}',
488         #'S3_ACCESS_KEY_SECRET' => '${S3_ACCESS_KEY_SECRET}',
489         #'S3_REGION' => 'us-east-1',
490         #'S3_BUCKET' => 'screwdriver',
491         #'S3_ENDPOINT' => 'http://s3:9000/screwdriver',  # tricky!! setting for the S3 virtual hosting style.
492         #'S3_SIG_VER' => 'v4',
493       },
494       # for S3 compatible server
495       #'links' => [
496       #  'screwdriver.s3',
497       #],
498     },
499   },
500 }
501
502 config_srvs = node['screwdriver']['docker-compose']['config']['services']
503 case config_srvs['api']['environment']['DATASTORE_SEQUELIZE_DIALECT']
504 when 'mysql'
505   version_2_config['services']['db'] = {
506     'image' => 'mysql:5',
507     'volumes' => [
508       # This variable will be set by the screwdriver::docker-compose recipe automatically.
509       #"#{node['screwdriver']['docker-compose']['data_dir']}/mysql:/var/lib/mysql:rw",
510     ],
511     'environment' => {
512       # These variables will be set by the screwdriver::docker-compose recipe automatically.
513       #'MYSQL_ROOT_PASSWORD' => '${DB_ROOT_PASSWORD}',
514       #'MYSQL_USER' => '${DB_USERNAME}',
515       #'MYSQL_PASSWORD' => '${DB_PASSWORD}',
516       #'MYSQL_DATABASE' => 'screwdriver',
517     },
518   }
519 when 'postgres'
520   version_2_config['services']['db'] = {
521     'image' => 'postgres:9',
522     'volumes' => [
523       # This variable will be set by the screwdriver::docker-compose recipe automatically.
524       #"#{node['screwdriver']['docker-compose']['data_dir']}/postgres:/database:rw",
525     ],
526     'environment' => {
527       # These variables will be set by the screwdriver::docker-compose recipe automatically.
528       #'POSTGRES_USER' => '${DB_USERNAME}',
529       #'POSTGRES_PASSWORD' => '${DB_PASSWORD}',
530       #'POSTGRES_DB' => 'screwdriver',
531       #'PGDATA' => '/database',
532     },
533   }
534 end
535
536 executor_queue_enabled = config_srvs['api']['environment']['EXECUTOR_QUEUE_ENABLED'] == 'true' ? true : false
537 if executor_queue_enabled
538   version_2_config['services']['queue'] = {
539     'image' => 'redis:4',
540     'volumes' => [
541       # This variable will be set by the screwdriver::docker-compose recipe automatically.
542       # TODO:
543     ],
544     'environment' => {
545       # These variables will be set by the screwdriver::docker-compose recipe automatically.
546       # TODO:
547     },
548   }
549 end
550
551 # S3 compatible server
552 case node['screwdriver']['store']['backend']
553 when 'minio'
554   version_2_config['services']['screwdriver.s3'] = {
555     'image' => 'minio/minio',
556     'ports' => [
557       #'9010:9000',  # default
558     ],
559     'command' => 'server /export',
560     'volumes' => [
561       # This variable will be set by the screwdriver::docker-compose recipe automatically.
562       #"#{node['screwdriver']['docker-compose']['data_dir']}//minio:/export:rw",
563     ],
564     'environment' => {
565       # These variables will be set by the screwdriver::docker-compose recipe automatically.
566       #'MINIO_ACCESS_KEY' => '${S3_ACCESS_KEY_ID}',
567       #'MINIO_SECRET_KEY' => '${S3_ACCESS_KEY_SECRET}',
568     },
569   }
570 end
571
572 if node['screwdriver']['docker-compose']['network_mode_bridge']
573   version_2_config['services'].each_value {|srv_config|
574     srv_config['network_mode'] = 'bridge'
575   }
576 end
577
578 default['screwdriver']['docker-compose']['config'] = version_2_config