2 # Cookbook Name:: screwdriver
5 # Copyright 2017-2018, whitestar
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
11 # http://www.apache.org/licenses/LICENSE-2.0
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.
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?
29 default['screwdriver']['jwt_private_key_vault_item'] = {
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"
41 default['screwdriver']['jwt_public_key_vault_item'] = {
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"
53 # A password used for encrypting session data. Needs to be minimum 32 characters
54 default['screwdriver']['cookie_password_vault_item'] = {
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"
66 # A password used for encrypting stored secrets. Needs to be minimum 32 characters
67 default['screwdriver']['password_vault_item'] = {
69 'vault' => 'screwdriver',
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"
79 # A password used for hashing user/pipeline access tokens. Needs to be minimum 32 characters
80 default['screwdriver']['hashing_password_vault_item'] = {
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"
92 default['screwdriver']['db_username_vault_item'] = {
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"
104 default['screwdriver']['db_password_vault_item'] = {
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"
116 default['screwdriver']['db_root_password_vault_item'] = {
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"
128 default['screwdriver']['s3_access_key_id_vault_item'] = {
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"
140 default['screwdriver']['s3_access_key_secret_vault_item'] = {
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"
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'] = {
161 'plugin' => 'docker',
165 'socketPath' => '/var/run/docker.sock',
167 'launchVersion' => 'latest',
171 # TODO: implement default settings
173 'enabled' => 'false', # EXECUTOR_QUEUE_ENABLED
175 # Configuration of the redis instance containing resque
176 'redisConnection' => {
177 'host' => 'QUEUE_REDIS_HOST',
178 'port' => 'QUEUE_REDIS_PORT',
180 'password' => 'QUEUE_REDIS_PASSWORD',
181 'tls' => 'QUEUE_REDIS_TLS_ENABLED',
183 'database' => 'QUEUE_REDIS_DATABASE',
191 'scm_a' => { # id and display name
192 'plugin' => 'github',
193 # access https://github.com/settings/developers to get an OAuth key.
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)
205 'scm_b' => { # id and display name
206 'plugin' => 'bitbucket',
207 # access https://bitbucket.org/account/user/<name>/api to get an OAuth key.
209 'oauthClientId' => 'YOUR-APP-KEY',
210 'oauthClientSecret' => 'YOUR-APP-SECRET',
216 default['screwdriver']['api']['scms_vault_items'] = {
220 'vault' => 'screwdriver',
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"
229 'oauthClientSecret' => {
230 'vault' => 'screwdriver',
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"
241 'vault' => 'screwdriver',
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"
258 default['screwdriver']['store']['backend'] = nil # or 'minio'
259 default['screwdriver']['store']['config'] = {
270 'secretAccessKey' => '****************************************',
271 'region' => 'us-east-1',
272 'bucket' => 'screwdriver',
273 'endpoint' => 'http://s3:9000/screwdriver',
274 'signatureVersion' => 'v4',
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
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'] = {}
296 # **DEPRECATED**: use the above `['screwdriver']['api']['scms_vault_items']` attribute.
297 default['screwdriver']['docker-compose']['oauth_client_id_vault_item'] = {
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"
309 # **DEPRECATED**: use the above `['screwdriver']['api']['scms_vault_items']` attribute.
310 default['screwdriver']['docker-compose']['oauth_client_secret_vault_item'] = {
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"
322 # **DEPRECATED**: use the above `['screwdriver']['api']['scms_vault_items']` attribute.
323 default['screwdriver']['docker-compose']['webhook_github_secret_vault_item'] = {
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"
336 # ref: https://github.com/screwdriver-cd/screwdriver/blob/master/in-a-box.py
337 force_override['screwdriver']['docker-compose']['config_format_version'] = '2'
339 # Version 2 docker-compose format
342 # this service will be active if the `['screwdriver']['with_ssl_cert_cookbook']` attribute is true.
347 'restart' => 'always',
348 'image' => 'nginx:alpine',
353 #'9000:9000', # default
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",
361 'image' => 'screwdrivercd/screwdriver:latest',
362 'command' => 'npm start', # the original command in the Dockerfile.
364 #'9001:80', # default
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
373 # http://docs.screwdriver.cd/cluster-management/configure-api
374 # https://github.com/screwdriver-cd/screwdriver/blob/master/config/custom-environment-variables.yaml
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',
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
402 # **DEPRECATED**: use the `['screwdriver']['api']['config']['executor']` attribute.
403 'EXECUTOR_PLUGIN' => 'docker',
404 'EXECUTOR_DOCKER_DOCKER' => <<-'EOS',
406 "socketPath": "/var/run/docker.sock"
410 'EXECUTOR_QUEUE_ENABLED' => 'false',
411 #'QUEUE_REDIS_HOST' => 'queue',
413 #'QUEUE_REDIS_PORT' => '',
414 #'QUEUE_REDIS_PASSWORD' => '${REDIS_PASSWORD}'
415 #'QUEUE_REDIS_TLS_ENABLED' => '',
416 #'QUEUE_REDIS_DATABASE' => '',
419 # **DEPRECATED**: Please use the above `['screwdriver']['api']['config']['scms']` attribute
420 # instead of `SCM_SETTINGS` env. variable.
421 # 'SCM_SETTINGS' => '{}',
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'
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}',
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',
440 #'SCM_GITLAB_HOST' => 'gitlab.io.example.com',
441 #'SCM_GITLAB_PROTOCOL' => 'https',
448 'image' => 'screwdrivercd/ui:latest',
450 #'9000:80', # default
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
463 'image' => 'screwdrivercd/store:latest',
465 #'9002:80', # default
468 # See https://github.com/screwdriver-cd/store/blob/master/config/custom-environment-variables.yaml
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
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',
486 # If node['screwdriver']['store']['backend'] is 'minio',
487 # these variables will be set by the screwdriver::docker-compose recipe automatically.
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',
496 # for S3 compatible server
504 config_srvs = node['screwdriver']['docker-compose']['config']['services']
505 case config_srvs['api']['environment']['DATASTORE_SEQUELIZE_DIALECT']
507 version_2_config['services']['db'] = {
508 'image' => 'mysql:5',
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",
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',
522 version_2_config['services']['db'] = {
523 'image' => 'postgres:9',
525 # This variable will be set by the screwdriver::docker-compose recipe automatically.
526 #"#{node['screwdriver']['docker-compose']['data_dir']}/postgres:/database:rw",
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',
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',
543 # This variable will be set by the screwdriver::docker-compose recipe automatically.
547 # These variables will be set by the screwdriver::docker-compose recipe automatically.
553 # S3 compatible server
554 case node['screwdriver']['store']['backend']
556 version_2_config['services']['screwdriver.s3'] = {
557 'image' => 'minio/minio',
559 #'9010:9000', # default
561 'command' => 'server /export',
563 # This variable will be set by the screwdriver::docker-compose recipe automatically.
564 #"#{node['screwdriver']['docker-compose']['data_dir']}//minio:/export:rw",
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}',
574 if node['screwdriver']['docker-compose']['network_mode_bridge']
575 version_2_config['services'].each_value {|srv_config|
576 srv_config['network_mode'] = 'bridge'
580 default['screwdriver']['docker-compose']['config'] = version_2_config