Class: DanarchyDeploy::Services::MySQL::NewServer

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

Class Method Summary collapse

Class Method Details

.centos_new_mysql(mysql, options) ⇒ Object



42
43
44
45
# File 'lib/danarchy_deploy/services/mysql/new_server.rb', line 42

def self.centos_new_mysql(mysql, options)
  puts "   ! CentOS/Redhat MySQL configuration not yet implemented!"
  
end

.debian_new_mysql(mysql, options) ⇒ Object



38
39
40
# File 'lib/danarchy_deploy/services/mysql/new_server.rb', line 38

def self.debian_new_mysql(mysql, options)
  puts "   ! Debian/Ubuntu MySQL configuration not yet implemented!"
end

.generate_root_mycnf(mysql, options) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/danarchy_deploy/services/mysql/new_server.rb', line 51

def self.generate_root_mycnf(mysql, options)
  return if File.exist?(mysql[:default_file])
  puts "   |+ Generating #{mysql[:default_file]} file."
  password = SecureRandom.base64(14)
  source = options[:deploy_dir] +
           '/templates/services/mysql/root_my.cnf.erb'

  templates = [{ target: mysql[:default_file],
                 source: source,
                 variables: {
                   host: 'localhost',
                   user: 'root',
                   pass: password,
                   port: '3306' }
               }]

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

.gentoo_new_mysql(mysql, options) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/danarchy_deploy/services/mysql/new_server.rb', line 22

def self.gentoo_new_mysql(mysql, options)
  puts "\n > Performing first time MySQL configuration."
  cmd = 'emerge --config mariadb'
  config_result = DanarchyDeploy::Helpers.run_command(cmd, options)

  if config_result[:stderr]
    abort('   |! ERROR: Failed to configure MySQL')
  else config_result[:stdout]
    puts "   |+ MySQL configured successfully"
    puts config_result[:stdout]
  end

  puts "\n > Starting MySQL."
  DanarchyDeploy::Services::Init.init_manager('gentoo', 'mysql', 'start', options)
end

.new(os, mysql, options) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/danarchy_deploy/services/mysql/new_server.rb', line 6

def self.new(os, mysql, options)
  self.generate_root_mycnf(mysql, options)

  if os == 'gentoo'
    self.gentoo_new_mysql(mysql, options)
  elsif os == 'opensuse'
    self.opensuse_new_mysql(mysql, options)
  elsif %w[debian ubuntu].include?(os)
    self.debian_new_mysql(mysql, options)
  elsif %w[centos redhat].include?(os)
    self.centos_new_mysql(mysql, options)
  end
end

.opensuse_new_mysql(mysql, options) ⇒ Object



47
48
49
# File 'lib/danarchy_deploy/services/mysql/new_server.rb', line 47

def self.opensuse_new_mysql(mysql, options)
  puts "   ! OpenSUSE MySQL configuration not yet implemented!"
end