OSDN Git Service

adds MySQL support.
[metasearch/grid-chef-repo.git] / cookbooks / screwdriver / attributes / default.rb
index 73c8343..4428f3c 100644 (file)
@@ -76,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.
@@ -260,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:
@@ -279,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
@@ -357,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