-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmysql-deploy.pp
84 lines (68 loc) · 2.52 KB
/
mysql-deploy.pp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
class galaxy::db::mysql {
$packagelist = ["mysql-server"]
package { $packagelist:
ensure => installed
}
file { "/mnt/logs" :
ensure => directory,
}
file { "/mnt/logs/mysql":
owner => "mysql",
group => "mysql",
mode => "0644",
replace => false,
recurse => "true",
ignore => [".svn"],
source => "puppet:///galaxy/mysql",
}
file { "/etc/my.cnf":
owner => "root",
group => "root",
mode => "0644",
replace => true,
require => Package["mysql-server"],
notify => Service[mysqld],
source => "puppet:///galaxy/my.cnf",
}
define mysql_master_conf($shard_master_id) {
file { "/etc/my.cnf":
path => "/etc/my.cnf",
owner => "root",
group => "root",
mode => "0644",
content => template("galaxy/my_master.erb"),
content => Service[mysqld],
}
}
service { mysqld:
enable => "true",
ensure => "running",
# require => File["/etc/my.cnf"]
}
$mysql_password = "aravind-secret"
exec { "set-mysql-password":
unless => "mysqladmin -uroot -p$mysql_password status",
path => ["/bin", "/usr/bin"],
command => "mysqladmin -uroot password $mysql_password",
require => Service["mysqld"],
}
$user = "dchoc"
$muser = "munin"
$dbname = "star"
$password = "imaz0mb1e"
exec { "create-${dbname}-db":
unless => "/usr/bin/mysql -uroot -p${password} ${dbname}",
command => "/usr/bin/mysql -uroot -p$password -e \"create database $dbname;\"",
require => Service["mysqld"],
}
exec { "grant-${dbname}-db":
unless => "/usr/bin/mysql -u${user} -p${password} ${dbname}",
command => "/usr/bin/mysql -uroot -p$password -e \"grant all on ${dbname}.* to ${user}@localhost identified by '$password'; grant all on ${dbname}.* to ${user}@'%' identified by '$password';\"",
require => [Service["mysqld"], Exec["create-${dbname}-db"]]
}
exec { "grant-${dbname}-munin":
unless => "/usr/bin/mysql -u${muser} -p${password} ${dbname}",
command => "/usr/bin/mysql -uroot -p$password -e \"grant all on ${dbname}.* to ${muser}@localhost identified by '$password'; grant all on ${dbname}.* to ${muser}@'%' identified by '$password';\"",
require => [Service["mysqld"], Exec["create-${dbname}-db"]]
}
}