2 # Cookbook Name:: screwdriver
5 # Copyright 2017, 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'] = {
163 'plugin' => 'docker',
167 'socketPath' => '/var/run/docker.sock',
169 'launchVersion' => 'stable',
172 # TODO: implement default settings
174 'enabled' => 'false', # EXECUTOR_QUEUE_ENABLED
176 # Configuration of the redis instance containing resque
177 'redisConnection' => {
178 'host' => 'QUEUE_REDIS_HOST',
179 'port' => 'QUEUE_REDIS_PORT',
181 'password' => 'QUEUE_REDIS_PASSWORD',
182 'tls' => 'QUEUE_REDIS_TLS_ENABLED',
184 'database' => 'QUEUE_REDIS_DATABASE',
192 'scm_a' => { # id and display name
193 'plugin' => 'github',
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',
208 'oauthClientId' => 'YOUR-APP-KEY',
209 'oauthClientSecret' => 'YOUR-APP-SECRET',
215 default['screwdriver']['api']['scms_vault_items'] = {
219 'vault' => 'screwdriver',
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"
228 'oauthClientSecret' => {
229 'vault' => 'screwdriver',
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"
240 'vault' => 'screwdriver',
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"
257 default['screwdriver']['store']['backend'] = nil # or 'minio'
258 default['screwdriver']['store']['config'] = {
269 'secretAccessKey' => '****************************************',
270 'region' => 'us-east-1',
271 'bucket' => 'screwdriver',
272 'endpoint' => 'http://s3:9000/screwdriver',
273 'signatureVersion' => 'v4',
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
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'] = {}
295 # **DEPRECATED**: use the above `['screwdriver']['api']['scms_vault_items']` attribute.
296 default['screwdriver']['docker-compose']['oauth_client_id_vault_item'] = {
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"
308 # **DEPRECATED**: use the above `['screwdriver']['api']['scms_vault_items']` attribute.
309 default['screwdriver']['docker-compose']['oauth_client_secret_vault_item'] = {
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"
321 # **DEPRECATED**: use the above `['screwdriver']['api']['scms_vault_items']` attribute.
322 default['screwdriver']['docker-compose']['webhook_github_secret_vault_item'] = {
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"
335 # ref: https://github.com/screwdriver-cd/screwdriver/blob/master/in-a-box.py
336 force_override['screwdriver']['docker-compose']['config_format_version'] = '2'
338 # Version 2 docker-compose format
341 # this service will be active if the `['screwdriver']['with_ssl_cert_cookbook']` attribute is true.
346 'restart' => 'always',
347 'image' => 'nginx:alpine',
352 #'9000:9000', # default
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",
360 'image' => 'screwdrivercd/screwdriver:latest',
361 'command' => 'npm start', # the original command in the Dockerfile.
363 #'9001:80', # default
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
372 # http://docs.screwdriver.cd/cluster-management/configure-api
373 # https://github.com/screwdriver-cd/screwdriver/blob/master/config/custom-environment-variables.yaml
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',
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
401 # **DEPRECATED**: use the `['screwdriver']['api']['config']['executor']` attribute.
402 'EXECUTOR_PLUGIN' => 'docker',
403 'EXECUTOR_DOCKER_DOCKER' => <<-'EOS',
405 "socketPath": "/var/run/docker.sock"
409 'EXECUTOR_QUEUE_ENABLED' => 'false',
410 #'QUEUE_REDIS_HOST' => 'queue',
412 #'QUEUE_REDIS_PORT' => '',
413 #'QUEUE_REDIS_PASSWORD' => '${REDIS_PASSWORD}'
414 #'QUEUE_REDIS_TLS_ENABLED' => '',
415 #'QUEUE_REDIS_DATABASE' => '',
418 # **DEPRECATED**: Please use the above `['screwdriver']['api']['config']['scms']` attribute
419 # instead of `SCM_SETTINGS` env. variable.
420 # 'SCM_SETTINGS' => '{}',
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'
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}',
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',
438 #'SCM_GITLAB_HOST' => 'gitlab.io.example.com',
439 #'SCM_GITLAB_PROTOCOL' => 'https',
446 'image' => 'screwdrivercd/ui:latest',
448 #'9000:80', # default
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
461 'image' => 'screwdrivercd/store:latest',
463 #'9002:80', # default
466 # See https://github.com/screwdriver-cd/store/blob/master/config/custom-environment-variables.yaml
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
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',
484 # If node['screwdriver']['store']['backend'] is 'minio',
485 # these variables will be set by the screwdriver::docker-compose recipe automatically.
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',
494 # for S3 compatible server
502 config_srvs = node['screwdriver']['docker-compose']['config']['services']
503 case config_srvs['api']['environment']['DATASTORE_SEQUELIZE_DIALECT']
505 version_2_config['services']['db'] = {
506 'image' => 'mysql:5',
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",
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',
520 version_2_config['services']['db'] = {
521 'image' => 'postgres:9',
523 # This variable will be set by the screwdriver::docker-compose recipe automatically.
524 #"#{node['screwdriver']['docker-compose']['data_dir']}/postgres:/database:rw",
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',
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',
541 # This variable will be set by the screwdriver::docker-compose recipe automatically.
545 # These variables will be set by the screwdriver::docker-compose recipe automatically.
551 # S3 compatible server
552 case node['screwdriver']['store']['backend']
554 version_2_config['services']['screwdriver.s3'] = {
555 'image' => 'minio/minio',
557 #'9010:9000', # default
559 'command' => 'server /export',
561 # This variable will be set by the screwdriver::docker-compose recipe automatically.
562 #"#{node['screwdriver']['docker-compose']['data_dir']}//minio:/export:rw",
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}',
572 if node['screwdriver']['docker-compose']['network_mode_bridge']
573 version_2_config['services'].each_value {|srv_config|
574 srv_config['network_mode'] = 'bridge'
578 default['screwdriver']['docker-compose']['config'] = version_2_config