Class: DanarchyDeploy::Services::MySQL::Privileges
- Inherits:
-
Object
- Object
- DanarchyDeploy::Services::MySQL::Privileges
- Defined in:
- lib/danarchy_deploy/services/mysql/privileges.rb
Class Method Summary collapse
- .new(mysql, options) ⇒ Object
- .run_sql_grants(mysql, sql_grants, options) ⇒ Object
- .sql_template(mysql, options) ⇒ Object
Class Method Details
.new(mysql, options) ⇒ Object
8 9 10 11 |
# File 'lib/danarchy_deploy/services/mysql/privileges.rb', line 8 def self.new(mysql, ) sql_grants = sql_template(mysql, ) run_sql_grants(mysql, sql_grants, ) end |
.run_sql_grants(mysql, sql_grants, options) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/danarchy_deploy/services/mysql/privileges.rb', line 25 def self.run_sql_grants(mysql, sql_grants, ) # Using CLI commands for now; # mysql2 requires mysql client be installed even if we won't be using it. # client = Mysql2::Client.new(:default_file => default_file) cmd = "mysql --defaults-file=#{mysql[:default_file]} -v < #{sql_grants}" DanarchyDeploy::Helpers.run_command(cmd, ) end |
.sql_template(mysql, options) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/danarchy_deploy/services/mysql/privileges.rb', line 13 def self.sql_template(mysql, ) sql_grants = '/root/.user_grants.sql' source = [:deploy_dir] + '/templates/services/mysql/user_db_grants.sql.erb' templates = [{ target: sql_grants, source: source, variables: mysql[:privileges] }] DanarchyDeploy::Templater.new(templates, ) sql_grants end |