Class: DanarchyDeploy::Services::MySQL

Inherits:
Object
  • Object
show all
Defined in:
lib/danarchy_deploy/services/mysql.rb,
lib/danarchy_deploy/services/mysql/new_server.rb,
lib/danarchy_deploy/services/mysql/privileges.rb

Defined Under Namespace

Classes: NewServer, Privileges

Class Method Summary collapse

Class Method Details

.generate_my_cnf(mysql, options) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/danarchy_deploy/services/mysql.rb', line 43

def self.generate_my_cnf(mysql, options)
  source = options[:deploy_dir] +
           '/templates/services/mysql/my.cnf.erb'
  
  templates = [{ target: mysql[:my_cnf],
                 source: source,
                 variables: {
                   datadir:      mysql[:datadir],
                   bind_address: mysql[:bind_address] }
               }]

  DanarchyDeploy::Templater.new(templates, options)
end

.new(os, mysql, options) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/danarchy_deploy/services/mysql.rb', line 7

def self.new(os, mysql, options)
  puts "\n" + self.name
  puts "\n > Configuring MySQL service."

  mysql = self.set_parameters(mysql)
  self.generate_my_cnf(mysql, options)

  if File.exist?(mysql[:defaults_file]) && Dir.exist?(mysql[:datadir])
    puts "   |+ Using existing MySQL service."
  else
    MySQL::NewServer.new(os, mysql, options)
  end

  if mysql[:privileges]
    puts "\n > Configuring MySQL Privileges"
    MySQL::Privileges.new(mysql, options)
  end
end

.set_parameters(mysql) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/danarchy_deploy/services/mysql.rb', line 26

def self.set_parameters(mysql)
  mysql[:defaults_file] = mysql[:defaults_file] ?
                           mysql[:defaults_file] :
                           '/root/.my.cnf'
  mysql[:my_cnf] = mysql[:my_cnf] ?
                     mysql[:my_cnf] :
                     '/etc/mysql/my.cnf'
  mysql[:datadir] = mysql[:datadir] ?
                      mysql[:datadir] :
                      '/var/lib/mysql'
  mysql[:bind_address] = mysql[:bind_address] ?
                           mysql[:bind_address] :
                           '127.0.0.1'

  mysql
end