OSDN Git Service

adds MySQL support.
[metasearch/grid-chef-repo.git] / cookbooks / screwdriver / attributes / default.rb
index 4d548d8..4428f3c 100644 (file)
@@ -24,6 +24,7 @@ default['screwdriver']['with_ssl_cert_cookbook'] = false
 default['screwdriver']['ssl_cert']['ca_names'] = []
 default['screwdriver']['ssl_cert']['common_name'] = node['fqdn']
 cn = node['screwdriver']['ssl_cert']['common_name']
+cn = node['ipaddress'] if cn.nil? || cn.empty?
 
 default['screwdriver']['jwt_private_key_vault_item'] = {
 =begin
@@ -75,6 +76,42 @@ default['screwdriver']['password_vault_item'] = {
   #'key' => 'hash/path/to/password',  # real hash path: "/#{node.chef_environment}/hash/path/to/password"
 =end
 }
+default['screwdriver']['db_username_vault_item'] = {
+=begin
+  'vault' => 'screwdriver',
+  'name' => 'db_username',
+  # single usernaem or nested hash username path delimited by slash
+  'env_context' => false,
+  'key' => 'username',  # real hash path: "/username"
+  # or nested hash password path delimited by slash
+  #'env_context' => true,
+  #'key' => 'hash/path/to/username',  # real hash path: "/#{node.chef_environment}/hash/path/to/username"
+=end
+}
+default['screwdriver']['db_password_vault_item'] = {
+=begin
+  'vault' => 'screwdriver',
+  'name' => 'db_password',
+  # single password or nested hash password path delimited by slash
+  'env_context' => false,
+  'key' => 'password',  # real hash path: "/password"
+  # or nested hash password path delimited by slash
+  #'env_context' => true,
+  #'key' => 'hash/path/to/password',  # real hash path: "/#{node.chef_environment}/hash/path/to/password"
+=end
+}
+default['screwdriver']['db_root_password_vault_item'] = {
+=begin
+  'vault' => 'screwdriver',
+  'name' => 'db_root_password',
+  # single password or nested hash password path delimited by slash
+  'env_context' => false,
+  'key' => 'password',  # real hash path: "/password"
+  # or nested hash password path delimited by slash
+  #'env_context' => true,
+  #'key' => 'hash/path/to/password',  # real hash path: "/#{node.chef_environment}/hash/path/to/password"
+=end
+}
 
 force_override['screwdriver']['ui']['tls_setup_mode'] = 'reverseproxy'
 # These hash objects are expanded to a `/config/local.yaml` file in each Docker container.
@@ -154,7 +191,7 @@ default['screwdriver']['api']['scms_vault_items'] = {
       'key' => 'secret',  # real hash path: "/secret"
       # or nested hash password path delimited by slash
       #'env_context' => true,
-      #'key' => 'hash/path/to/secret',  # real hash path: "/#{node.chef_environment}/hash/path/to/secret"    
+      #'key' => 'hash/path/to/secret',  # real hash path: "/#{node.chef_environment}/hash/path/to/secret"
     },
   },
   'scm_b' => {
@@ -259,7 +296,7 @@ version_2_config = {
       'volumes' => [
         '/var/run/docker.sock:/var/run/docker.sock:rw',
         # This volume will be set by the screwdriver::docker-compose recipe automatically.
-        #"#{node['screwdriver']['docker-compose']['data_dir']}:/sd-data:rw",
+        #"#{node['screwdriver']['docker-compose']['data_dir']}:/sd-data:rw",  # for sqlite
       ],
       'environment' => {
         # See:
@@ -278,8 +315,16 @@ version_2_config = {
         'SECRET_WHITELIST' => '[]',
         'SECRET_ADMINS' => '[]',
         'DATASTORE_PLUGIN' => 'sequelize',
+        'DATASTORE_SEQUELIZE_DATABASE' => 'screwdriver',
         'DATASTORE_SEQUELIZE_DIALECT' => 'sqlite',
-        'DATASTORE_SEQUELIZE_STORAGE' => '/sd-data/storage.db',
+        # This variable will be set by the screwdriver::docker-compose recipe automatically.
+        #'DATASTORE_SEQUELIZE_STORAGE' => '/sd-data/storage.db',
+        # for MySQL
+        #'DATASTORE_SEQUELIZE_DIALECT' => 'mysql',
+        # These variables will be set by the screwdriver::docker-compose recipe automatically.
+        #'DATASTORE_SEQUELIZE_USERNAME' => '${DB_USERNAME}',
+        #'DATASTORE_SEQUELIZE_PASSWORD' => '${DB_PASSWORD}',
+        #'DATASTORE_SEQUELIZE_HOST' => 'db',
         # This variable will be set by the screwdriver::docker-compose recipe automatically.
         #'IS_HTTPS' => 'false',
         #'NODE_TLS_REJECT_UNAUTHORIZED' => '0',  # workaround for self-signed cetificates
@@ -297,7 +342,7 @@ EOS
         # **DEPRECATED**: Please use the above `['screwdriver']['api']['config']['scms']` attribute
         # instead of `SCM_SETTINGS` env. variable.
         # 'SCM_SETTINGS' => '{}',
-        # 
+        #
         # **DEPRECATED**: Non-Multiple SCMs setting format.
         #   - Note: Multiple SCMs not supported yet.
         #     https://github.com/screwdriver-cd/screwdriver/issues/365
@@ -356,4 +401,23 @@ EOS
   },
 }
 
+config_srvs = node['screwdriver']['docker-compose']['config']['services']
+case config_srvs['api']['environment']['DATASTORE_SEQUELIZE_DIALECT']
+when 'mysql'
+  version_2_config['services']['db'] = {
+    'image' => 'mysql:5',
+    'volumes' => [
+      # This variable will be set by the screwdriver::docker-compose recipe automatically.
+      #"#{node['screwdriver']['docker-compose']['data_dir']}/mysql:/var/lib/mysql:rw",
+    ],
+    'environment' => {
+      # These variables will be set by the screwdriver::docker-compose recipe automatically.
+      #'MYSQL_ROOT_PASSWORD' => '${DB_ROOT_PASSWORD}',
+      #'MYSQL_USER' => '${DB_USERNAME}',
+      #'MYSQL_PASSWORD' => '${DB_PASSWORD}',
+      #'MYSQL_DATABASE' => 'screwdriver',
+    },
+  }
+end
+
 default['screwdriver']['docker-compose']['config'] = version_2_config