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
|
# Using recipe from
#
# http://reductivelabs.com/trac/puppet/wiki/Recipes/MySQLStoredConfiguration
#
# Using snippets from git://git.puppet.immerda.ch/module-mysql.git, whose original
# disclaimer is:
#
# Copyright (C) 2007 David Schmitt <david@schmitt.edv-bus.at>
# See LICENSE for the full license granted to you.
# Copyright 2008, admin(at)immerda.ch
# Copyright 2008, Puzzle ITC GmbH
# Marcel Härry haerry+puppet(at)puzzle.ch
# Simon Josi josi+puppet(at)puzzle.ch
class mysql {
package { "mysql-client":
ensure => installed,
}
}
class mysql::server inherits mysql {
package { "mysql-server":
ensure => installed,
}
service { "mysql":
ensure => running,
enable => true,
hasrestart => true,
hasstatus => true,
require => Package["mysql-server"],
}
case $mysql_rootpw {
'': { fail("You need to define a mysql root password! Please set \$mysql_rootpw in your site.pp or host config") }
}
file { '/usr/local/sbin/setmysqlpass.sh':
content => template('mysql/setmysqlpass.sh.erb'),
require => Service['mysql'],
owner => root,
group => root,
mode => 0500,
}
exec { 'set_mysql_rootpw':
command => "/usr/local/sbin/setmysqlpass.sh",
require => [ File['/usr/local/sbin/setmysqlpass.sh'], Package[mysql-server] ],
refreshonly => true,
user => root,
}
mysql::cnf { "root":
home => "/root",
passwd => $mysql_rootpw,
}
define mysql::cnf($home, $passwd) {
$mysql_passwd = $passwd
file { "$home/.my.cnf":
content => template('mysql/my.cnf.erb'),
require => Service['mysql'],
owner => root,
group => root,
mode => 0400,
notify => Exec['set_mysql_rootpw'],
}
}
}
|