OSDN Git Service

ac69c0016b63a9a3d33207ab74767524dd72dd67
[metasearch/grid-chef-repo.git] / cookbooks / screwdriver / attributes / default.rb
1 #
2 # Cookbook Name:: screwdriver
3 # Attributes:: default
4 #
5 # Copyright 2017-2018, 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     'plugin' => 'docker',
162     'docker' => {
163       'options' => {
164         'docker' => {
165           'socketPath' => '/var/run/docker.sock',
166         },
167         'launchVersion' => 'latest',
168       },
169     },
170 =begin
171     # TODO: implement default settings
172     'queue' => {
173       'enabled' => 'false',  # EXECUTOR_QUEUE_ENABLED
174       'options' => {
175         # Configuration of the redis instance containing resque
176         'redisConnection' => {
177           'host' => 'QUEUE_REDIS_HOST',
178           'port' => 'QUEUE_REDIS_PORT',
179           'options' => {
180             'password' => 'QUEUE_REDIS_PASSWORD',
181             'tls' => 'QUEUE_REDIS_TLS_ENABLED',
182           },
183           'database' => 'QUEUE_REDIS_DATABASE',
184         },
185       },
186     },
187 =end
188   },
189   'scms' => {
190 =begin
191     'scm_a' => {  # id and display name
192       'plugin' => 'github',
193       # access https://github.com/settings/developers to get an OAuth key.
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       # access https://bitbucket.org/account/user/<name>/api to get an OAuth key.
208       'config' => {
209         'oauthClientId' => 'YOUR-APP-KEY',
210         'oauthClientSecret' => 'YOUR-APP-SECRET',
211       },
212     },
213 =end
214   },
215 }
216 default['screwdriver']['api']['scms_vault_items'] = {
217 =begin
218   'scm_a' => {
219     'oauthClientId' => {
220       'vault' => 'screwdriver',
221       'name' => 'scm_a',
222       # single oauthClientId or nested hash oauthClientId path delimited by slash
223       'env_context' => false,
224       'key' => 'oauthClientId',  # real hash path: "/oauthClientId", Note: do not use `id`, which is preserved by Chef Vault.
225       # or nested hash id path delimited by slash
226       #'env_context' => true,
227       #'key' => 'hash/path/to/oauthClientId',  # real hash path: "/#{node.chef_environment}/hash/path/to/oauthClientId"
228     },
229     'oauthClientSecret' => {
230       'vault' => 'screwdriver',
231       'name' => 'scm_a',
232       # single oauthClientSecret or nested hash oauthClientSecret path delimited by slash
233       'env_context' => false,
234       'key' => 'oauthClientSecret',  # real hash path: "/oauthClientSecret"
235       # or nested hash secret path delimited by slash
236       #'env_context' => true,
237       #'key' => 'hash/path/to/oauthClientSecret',  # real hash path: "/#{node.chef_environment}/hash/path/to/oauthClientSecret"
238     },
239     # GitHub only.
240     'secret' => {
241       'vault' => 'screwdriver',
242       'name' => 'scm_a',
243       # single secret or nested hash secret path delimited by slash
244       'env_context' => false,
245       'key' => 'secret',  # real hash path: "/secret"
246       # or nested hash password path delimited by slash
247       #'env_context' => true,
248       #'key' => 'hash/path/to/secret',  # real hash path: "/#{node.chef_environment}/hash/path/to/secret"
249     },
250   },
251   'scm_b' => {
252     # ...
253   },
254   # ...
255 =end
256 }
257
258 default['screwdriver']['store']['backend'] = nil  # or 'minio'
259 default['screwdriver']['store']['config'] = {
260   'auth' => {},
261   'httpd' => {
262     'tls' => false,
263   },
264 =begin
265   # for Minio
266   'strategy' => {
267     'plugin' => 's3',
268     's3' => {
269       'accessKeyId' => '',
270       'secretAccessKey' => '****************************************',
271       'region' => 'us-east-1',
272       'bucket' => 'screwdriver',
273       'endpoint' => 'http://s3:9000/screwdriver',
274       'signatureVersion' => 'v4',
275     },
276   },
277 =end
278 }
279
280 # Useless?!
281 force_override['screwdriver']['docker-compose']['import_ca'] = false
282 default['screwdriver']['docker-compose']['app_dir'] = "#{node['docker-grid']['compose']['app_dir']}/screwdriver"
283 default['screwdriver']['docker-compose']['bin_dir'] = "#{node['screwdriver']['docker-compose']['app_dir']}/bin"
284 default['screwdriver']['docker-compose']['config_dir'] = "#{node['screwdriver']['docker-compose']['app_dir']}/config"
285 default['screwdriver']['docker-compose']['data_dir'] = "#{node['screwdriver']['docker-compose']['app_dir']}/data"
286 default['screwdriver']['docker-compose']['etc_dir'] = "#{node['screwdriver']['docker-compose']['app_dir']}/etc"
287 default['screwdriver']['docker-compose']['network_mode_bridge'] = false
288 default['screwdriver']['docker-compose']['jwt_private_key_reset'] = false
289
290 # **DEPRECATED**: use ['screwdriver']['(jwt|cookie|password)_*_vault_item'] attributes.
291 default['screwdriver']['docker-compose']['jwt_private_key_vault_item'] = {}
292 default['screwdriver']['docker-compose']['jwt_public_key_vault_item'] = {}
293 default['screwdriver']['docker-compose']['cookie_password_vault_item'] = {}
294 default['screwdriver']['docker-compose']['password_vault_item'] = {}
295
296 # **DEPRECATED**: use the above `['screwdriver']['api']['scms_vault_items']` attribute.
297 default['screwdriver']['docker-compose']['oauth_client_id_vault_item'] = {
298 =begin
299   'vault' => 'screwdriver',
300   'name' => 'oauth_client_id',
301   # single cid or nested hash cid path delimited by slash
302   'env_context' => false,
303   'key' => 'cid',  # real hash path: "/cid", Note: do not use `id`, which is preserved by Chef Vault.
304   # or nested hash id path delimited by slash
305   #'env_context' => true,
306   #'key' => 'hash/path/to/cid',  # real hash path: "/#{node.chef_environment}/hash/path/to/cid"
307 =end
308 }
309 # **DEPRECATED**: use the above `['screwdriver']['api']['scms_vault_items']` attribute.
310 default['screwdriver']['docker-compose']['oauth_client_secret_vault_item'] = {
311 =begin
312   'vault' => 'screwdriver',
313   'name' => 'oauth_client_secret',
314   # single secret or nested hash secret path delimited by slash
315   'env_context' => false,
316   'key' => 'secret',  # real hash path: "/secret"
317   # or nested hash secret path delimited by slash
318   #'env_context' => true,
319   #'key' => 'hash/path/to/secret',  # real hash path: "/#{node.chef_environment}/hash/path/to/secret"
320 =end
321 }
322 # **DEPRECATED**: use the above `['screwdriver']['api']['scms_vault_items']` attribute.
323 default['screwdriver']['docker-compose']['webhook_github_secret_vault_item'] = {
324 =begin
325   'vault' => 'screwdriver',
326   'name' => 'webhook_github_secret',
327   # single password or nested hash password path delimited by slash
328   'env_context' => false,
329   'key' => 'secret',  # real hash path: "/secret"
330   # or nested hash password path delimited by slash
331   #'env_context' => true,
332   #'key' => 'hash/path/to/secret',  # real hash path: "/#{node.chef_environment}/hash/path/to/secret"
333 =end
334 }
335
336 # ref: https://github.com/screwdriver-cd/screwdriver/blob/master/in-a-box.py
337 force_override['screwdriver']['docker-compose']['config_format_version'] = '2'
338 version_2_config = {
339   # Version 2 docker-compose format
340   'version' => '2',
341   'services' => {
342     # this service will be active if the `['screwdriver']['with_ssl_cert_cookbook']` attribute is true.
343     'reverseproxy' => {
344       'depends_on' => [
345         'ui',
346       ],
347       'restart' => 'always',
348       'image' => 'nginx:alpine',
349       'expose' => [
350         '9000',
351       ],
352       'ports' => [
353         #'9000:9000',  # default
354       ],
355       'volumes' => [
356         # This volume will be set by the screwdriver::docker-compose recipe automatically.
357         #"#{node['screwdriver']['docker-compose']['etc_dir']}/nginx/nginx.conf:/etc/nginx/nginx.conf:ro",
358       ],
359     },
360     'api' => {
361       'image' => 'screwdrivercd/screwdriver:latest',
362       'command' => 'npm start',  # the original command in the Dockerfile.
363       'ports' => [
364         #'9001:80',  # default
365       ],
366       'volumes' => [
367         '/var/run/docker.sock:/var/run/docker.sock:rw',
368         # This volume will be set by the screwdriver::docker-compose recipe automatically.
369         #"#{node['screwdriver']['docker-compose']['data_dir']}:/sd-data:rw",  # for sqlite
370       ],
371       'environment' => {
372         # See:
373         # http://docs.screwdriver.cd/cluster-management/configure-api
374         # https://github.com/screwdriver-cd/screwdriver/blob/master/config/custom-environment-variables.yaml
375         'PORT' => '80',
376         'URI' => "http://#{cn}:9001",
377         #'URI' => "http://#{node['ipaddress']}:9001",  # unrecommended
378         # These vriables will be set by the screwdriver::docker-compose recipe automatically.
379         #'ECOSYSTEM_UI' => "http://#{cn}:9000",                 # Better
380         #'ECOSYSTEM_UI' => "http://#{node['ipaddress']}:9000",  # unrecommended
381         #'ECOSYSTEM_UI' => 'http://ui',                         # NG: for an access from a client.
382         #'ECOSYSTEM_STORE' => "http://#{cn}:9002",                 # Better
383         #'ECOSYSTEM_STORE' => "http://#{node['ipaddress']}:9002",  # unrecommended
384         #'ECOSYSTEM_STORE' => 'http://store',
385         'SECRET_WHITELIST' => '[]',
386         'SECRET_ADMINS' => '[]',
387         'DATASTORE_PLUGIN' => 'sequelize',
388         'DATASTORE_SEQUELIZE_DATABASE' => 'screwdriver',
389         'DATASTORE_SEQUELIZE_DIALECT' => 'sqlite',
390         # This variable will be set by the screwdriver::docker-compose recipe automatically.
391         #'DATASTORE_SEQUELIZE_STORAGE' => '/sd-data/storage.db',
392         # for MySQL
393         #'DATASTORE_SEQUELIZE_DIALECT' => 'mysql',
394         # These variables will be set by the screwdriver::docker-compose recipe automatically.
395         #'DATASTORE_SEQUELIZE_USERNAME' => '${DB_USERNAME}',
396         #'DATASTORE_SEQUELIZE_PASSWORD' => '${DB_PASSWORD}',
397         #'DATASTORE_SEQUELIZE_HOST' => 'db',
398         # This variable will be set by the screwdriver::docker-compose recipe automatically.
399         #'IS_HTTPS' => 'false',
400         #'NODE_TLS_REJECT_UNAUTHORIZED' => '0',  # workaround for self-signed cetificates
401 =begin
402         # **DEPRECATED**: use the `['screwdriver']['api']['config']['executor']` attribute.
403         'EXECUTOR_PLUGIN' => 'docker',
404         'EXECUTOR_DOCKER_DOCKER' => <<-'EOS',
405 {
406   "socketPath": "/var/run/docker.sock"
407 }
408 EOS
409 =end
410         'EXECUTOR_QUEUE_ENABLED' => 'false',
411         #'QUEUE_REDIS_HOST' => 'queue',
412         # TODO:
413         #'QUEUE_REDIS_PORT' => '',
414         #'QUEUE_REDIS_PASSWORD' => '${REDIS_PASSWORD}'
415         #'QUEUE_REDIS_TLS_ENABLED' => '',
416         #'QUEUE_REDIS_DATABASE' => '',
417 =begin
418         # SCM settings
419         # **DEPRECATED**: Please use the above `['screwdriver']['api']['config']['scms']` attribute
420         # instead of `SCM_SETTINGS` env. variable.
421         # 'SCM_SETTINGS' => '{}',
422         #
423         # **DEPRECATED**: Non-Multiple SCMs setting format.
424         #   - Note: Multiple SCMs not supported yet.
425         #     https://github.com/screwdriver-cd/screwdriver/issues/365
426         #   - OAuth Callback URL: "http://#{cn}:9001/v4/auth/login"
427         'SCM_PLUGIN' => 'github',  # or 'gitlab' or 'bitbucket'
428         # * Commons
429         'SCM_USERNAME' => 'sd-buildbot',
430         'SCM_EMAIL' => 'dev-null@screwdriver.cd',
431         # The following variables will be set by the screwdriver::docker-compose recipe automatically.
432         'SECRET_OAUTH_CLIENT_ID' => '${SECRET_OAUTH_CLIENT_ID}',
433         'SECRET_OAUTH_CLIENT_SECRET' => '${SECRET_OAUTH_CLIENT_SECRET}',
434         # * GitHub only
435         # access https://github.com/settings/developers to get an OAuth account.
436         'WEBHOOK_GITHUB_SECRET' => '${WEBHOOK_GITHUB_SECRET}',  #'SUPER-SECRET-SIGNING-THING'
437         'SCM_GITHUB_GHE_HOST' => 'gitlab.io.example.com',  # for GHE
438         'SCM_PRIVATE_REPO_SUPPORT' => 'false',
439         # * GitLab only
440         #'SCM_GITLAB_HOST' => 'gitlab.io.example.com',
441         #'SCM_GITLAB_PROTOCOL' => 'https',
442         # * Bitbucket only
443         #   None.
444 =end
445       },
446     },
447     'ui' => {
448       'image' => 'screwdrivercd/ui:latest',
449       'ports' => [
450         #'9000:80',  # default
451       ],
452       'environment' => {
453         # These variables will be set by the screwdriver::docker-compose recipe automatically.
454         #'ECOSYSTEM_API' => 'http://api',                        # NG: for an access from a client.
455         #'ECOSYSTEM_API' => "http://#{cn}:9001",                 # Better
456         #'ECOSYSTEM_API' => "http://#{node['ipaddress']}:9001",  # unrecommended
457         #'ECOSYSTEM_STORE' => 'http://store',
458         #'ECOSYSTEM_STORE' => "http://#{cn}:9002",                 # Better
459         #'ECOSYSTEM_STORE' => "http://#{node['ipaddress']}:9002",  # unrecommended
460       },
461     },
462     'store' => {
463       'image' => 'screwdrivercd/store:latest',
464       'ports' => [
465         #'9002:80',  # default
466       ],
467       'environment' => {
468         # See https://github.com/screwdriver-cd/store/blob/master/config/custom-environment-variables.yaml
469         'PORT' => '80',
470         'URI' => "http://#{cn}:9002",
471         #'URI' => "http://#{node['ipaddress']}:9002",  # unrecommended
472         # These variables will be set by the screwdriver::docker-compose recipe automatically.
473         #'ECOSYSTEM_UI' => "http://#{cn}:9000",  # Better
474         #'ECOSYSTEM_UI' => "http://#{node['ipaddress']}:9000",
475         #'ECOSYSTEM_UI' => 'http://ui',          # NG for an access from a client.
476         #'STRATEGY' => 'memory',  # default
477         # * AWS S3
478         #'STRATEGY' => 's3',
479         # If node['screwdriver']['s3_access_key_{id,secret}_vault_item'] is set,
480         # these 2 variables will be set by the screwdriver::docker-compose recipe automatically.
481         #'S3_ACCESS_KEY_ID' => '${S3_ACCESS_KEY_ID}',
482         #'S3_ACCESS_KEY_SECRET' => '${S3_ACCESS_KEY_SECRET}',
483         #'S3_REGION' => 'us-east-1',
484         #'S3_BUCKET' => 'screwdriver',
485         # * Minio
486         # If node['screwdriver']['store']['backend'] is 'minio',
487         # these variables will be set by the screwdriver::docker-compose recipe automatically.
488         #'STRATEGY' => 's3',
489         #'S3_ACCESS_KEY_ID' => '${S3_ACCESS_KEY_ID}',
490         #'S3_ACCESS_KEY_SECRET' => '${S3_ACCESS_KEY_SECRET}',
491         #'S3_REGION' => 'us-east-1',
492         #'S3_BUCKET' => 'screwdriver',
493         #'S3_ENDPOINT' => 'http://s3:9000/screwdriver',  # tricky!! setting for the S3 virtual hosting style.
494         #'S3_SIG_VER' => 'v4',
495       },
496       # for S3 compatible server
497       #'links' => [
498       #  'screwdriver.s3',
499       #],
500     },
501   },
502 }
503
504 config_srvs = node['screwdriver']['docker-compose']['config']['services']
505 case config_srvs['api']['environment']['DATASTORE_SEQUELIZE_DIALECT']
506 when 'mysql'
507   version_2_config['services']['db'] = {
508     'image' => 'mysql:5',
509     'volumes' => [
510       # This variable will be set by the screwdriver::docker-compose recipe automatically.
511       #"#{node['screwdriver']['docker-compose']['data_dir']}/mysql:/var/lib/mysql:rw",
512     ],
513     'environment' => {
514       # These variables will be set by the screwdriver::docker-compose recipe automatically.
515       #'MYSQL_ROOT_PASSWORD' => '${DB_ROOT_PASSWORD}',
516       #'MYSQL_USER' => '${DB_USERNAME}',
517       #'MYSQL_PASSWORD' => '${DB_PASSWORD}',
518       #'MYSQL_DATABASE' => 'screwdriver',
519     },
520   }
521 when 'postgres'
522   version_2_config['services']['db'] = {
523     'image' => 'postgres:9',
524     'volumes' => [
525       # This variable will be set by the screwdriver::docker-compose recipe automatically.
526       #"#{node['screwdriver']['docker-compose']['data_dir']}/postgres:/database:rw",
527     ],
528     'environment' => {
529       # These variables will be set by the screwdriver::docker-compose recipe automatically.
530       #'POSTGRES_USER' => '${DB_USERNAME}',
531       #'POSTGRES_PASSWORD' => '${DB_PASSWORD}',
532       #'POSTGRES_DB' => 'screwdriver',
533       #'PGDATA' => '/database',
534     },
535   }
536 end
537
538 executor_queue_enabled = config_srvs['api']['environment']['EXECUTOR_QUEUE_ENABLED'] == 'true' ? true : false
539 if executor_queue_enabled
540   version_2_config['services']['queue'] = {
541     'image' => 'redis:4',
542     'volumes' => [
543       # This variable will be set by the screwdriver::docker-compose recipe automatically.
544       # TODO:
545     ],
546     'environment' => {
547       # These variables will be set by the screwdriver::docker-compose recipe automatically.
548       # TODO:
549     },
550   }
551 end
552
553 # S3 compatible server
554 case node['screwdriver']['store']['backend']
555 when 'minio'
556   version_2_config['services']['screwdriver.s3'] = {
557     'image' => 'minio/minio',
558     'ports' => [
559       #'9010:9000',  # default
560     ],
561     'command' => 'server /export',
562     'volumes' => [
563       # This variable will be set by the screwdriver::docker-compose recipe automatically.
564       #"#{node['screwdriver']['docker-compose']['data_dir']}//minio:/export:rw",
565     ],
566     'environment' => {
567       # These variables will be set by the screwdriver::docker-compose recipe automatically.
568       #'MINIO_ACCESS_KEY' => '${S3_ACCESS_KEY_ID}',
569       #'MINIO_SECRET_KEY' => '${S3_ACCESS_KEY_SECRET}',
570     },
571   }
572 end
573
574 if node['screwdriver']['docker-compose']['network_mode_bridge']
575   version_2_config['services'].each_value {|srv_config|
576     srv_config['network_mode'] = 'bridge'
577   }
578 end
579
580 default['screwdriver']['docker-compose']['config'] = version_2_config