diff --git a/cookbooks/app/recipes/prep.rb b/cookbooks/app/recipes/prep.rb index 22e66d2c..15518b0a 100644 --- a/cookbooks/app/recipes/prep.rb +++ b/cookbooks/app/recipes/prep.rb @@ -4,9 +4,9 @@ is_solo = ['solo'].include?(node['dna']['instance_role']) unless is_solo # for solo leave the db stuff to the db cookbook case node.engineyard.environment['db_stack_name'] - when /postgres/ + when /^postgres\d+/, /^aurora-postgresql\d+/ include_recipe "postgresql::default" - when /mysql/, /aurora/, /mariadb/ + when /^mysql\d+/, /^aurora\d+/, /^mariadb\d+/ include_recipe "mysql::client" include_recipe "mysql::user_my.cnf" when "no_db" diff --git a/cookbooks/ey-lib/libraries/db_log_paths.rb b/cookbooks/ey-lib/libraries/db_log_paths.rb deleted file mode 100644 index 151430d2..00000000 --- a/cookbooks/ey-lib/libraries/db_log_paths.rb +++ /dev/null @@ -1,21 +0,0 @@ -class Chef - class Recipe - # Returns list of locations to find logs - # for the chosen database - # Returns [] if no database was chosen - def db_log_paths - db_type, db_version = db_type_and_version - if db_type == "postgres" - ["/db/postgresql/#{db_version}/data/pg_log/*"] - elsif db_type == "mysql" - if db_version == "5.0" - ["/db/mysql/log/mysqld.err"] - else - ["/db/mysql/#{db_version}/log/mysqld.err"] - end - else - [] - end - end - end -end diff --git a/cookbooks/ey-lib/libraries/db_type_and_version.rb b/cookbooks/ey-lib/libraries/db_type_and_version.rb index fa746233..4b3bbce4 100644 --- a/cookbooks/ey-lib/libraries/db_type_and_version.rb +++ b/cookbooks/ey-lib/libraries/db_type_and_version.rb @@ -1,32 +1,15 @@ +module RDSHelpers + def db_host_is_rds? + node.engineyard.environment[:db_provider_name] == 'amazon_rds' + end +end + class Chef class Recipe - # returns the db_type and specific version number - # nil - no database, or unknown database - def db_type_and_version - case node.engineyard.environment['db_stack_name'] - when "postgres" - ["postgres", "8.3"] - when "postgres9" - ["postgres", "9.0"] - when /postgres(\d+)_(.*)/ - ["postgres", "#{$1}.#{$2}"] - when "mysql" - ["mysql", "5.0"] - when /mysql(\d+)_(.*)/ - ["mysql", "#{$1}.#{$2}"] - else - nil - end - end - - def db_host_is_rds? - node.engineyard.environment[:db_provider_name] == 'amazon_rds' - end + include RDSHelpers end class Resource - def db_host_is_rds? - node.engineyard.environment[:db_provider_name] == 'amazon_rds' - end + include RDSHelpers end end diff --git a/cookbooks/ey-lib/libraries/ey-environment.rb b/cookbooks/ey-lib/libraries/ey-environment.rb index 0ce1b3de..a7e7d1d9 100644 --- a/cookbooks/ey-lib/libraries/ey-environment.rb +++ b/cookbooks/ey-lib/libraries/ey-environment.rb @@ -181,9 +181,9 @@ def db_adapter(app_type) stack_name = @hash['db_stack_name'].gsub /[^a-z]+/, '' # see https://tickets.engineyard.com/issue/DATA-66 to understand this case stack_name - when 'aurora', 'mariadb' + when 'aurora', 'mariadb', 'mysql' 'mysql' - when 'postgres' + when 'postgres', 'aurorapostgresql' 'postgresql' else stack_name diff --git a/cookbooks/postgresql/attributes/version.rb b/cookbooks/postgresql/attributes/version.rb index 4f482ecf..090e7de6 100644 --- a/cookbooks/postgresql/attributes/version.rb +++ b/cookbooks/postgresql/attributes/version.rb @@ -1,14 +1,14 @@ case attribute['dna']['engineyard']['environment']['db_stack_name'] -when "postgres9_5" +when "postgres9_5", "aurora-postgresql9_5" default['postgresql']['latest_version'] = '9.5.18' default['postgresql']['short_version'] = '9.5' -when "postgres9_6" +when "postgres9_6", "aurora-postgresql9_6" default['postgresql']['latest_version'] = '9.6.14' default['postgresql']['short_version'] = '9.6' -when "postgres10" +when "postgres10", "aurora-postgresql10" default['postgresql']['latest_version'] = '10.9' default['postgresql']['short_version'] = '10' -when "postgres11" +when "postgres11", "aurora-postgresql11" default['postgresql']['latest_version'] = '11.4' default['postgresql']['short_version'] = '11' end diff --git a/cookbooks/util/recipes/prep.rb b/cookbooks/util/recipes/prep.rb index e1fb55a0..bff5c615 100644 --- a/cookbooks/util/recipes/prep.rb +++ b/cookbooks/util/recipes/prep.rb @@ -2,9 +2,9 @@ include_recipe "ey-cron" case node.engineyard.environment['db_stack_name'] -when /postgres/ +when /^postgres\d+/, /^aurora-postgresql\d+/ include_recipe "postgresql::default" -when /mysql/, /aurora/, /mariadb/ +when /^mysql\d+/, /^aurora\d+/, /^mariadb\d+/ include_recipe "mysql::client" include_recipe "mysql::user_my.cnf" when "no_db"