2012-02-10 08:15:06 +01:00
# Mysql module for Puppet
2012-02-09 20:26:00 +01:00
This module manages mysql on Linux (RedHat/Debian) distros. A native mysql provider implements database resource type to handle database, database user, and database permission.
2012-02-10 08:15:06 +01:00
## Description
2012-02-09 20:26:00 +01:00
2012-03-15 06:58:25 +01:00
This module uses the fact osfamily which is supported by Facter 1.6.1+. If you do not have facter 1.6.1 in your environment, the following manifests will provide the same functionality in site.pp (before declaring any node):
if ! $::osfamily {
case $::operatingsystem {
'RedHat', 'Fedora', 'CentOS', 'Scientific', 'SLC', 'Ascendos', 'CloudLinux', 'PSBM', 'OracleLinux', 'OVS', 'OEL': {
$osfamily = 'RedHat'
}
'ubuntu', 'debian': {
$osfamily = 'Debian'
}
'SLES', 'SLED', 'OpenSuSE', 'SuSE': {
$osfamily = 'Suse'
}
'Solaris', 'Nexenta': {
$osfamily = 'Solaris'
}
default: {
$osfamily = $::operatingsystem
}
}
}
2012-02-09 20:26:00 +01:00
This module is based on work by David Schmitt. The following contributor have contributed patches to this module (beyond Puppet Labs):
* Christian G. Warden
* Daniel Black
* Justin Ellison
* Lowe Schmidt
* Matthias Pigulla
* William Van Hevelingen
2012-02-10 08:15:06 +01:00
## Usage
### mysql
Installs the mysql-client package.
2012-02-09 20:26:00 +01:00
class { 'mysql': }
2012-02-10 08:15:06 +01:00
### mysql::python
Installs mysql bindings for python.
2012-02-09 20:26:00 +01:00
class { 'mysql::python': }
2012-02-10 08:15:06 +01:00
### mysql::ruby
Installs mysql bindings for ruby.
2012-02-09 20:26:00 +01:00
class { 'mysql::ruby': }
2012-02-10 08:15:06 +01:00
### mysql::server
2012-02-09 20:26:00 +01:00
Installs mysql-server packages, configures my.cnf and starts mysqld service:
class { 'mysql::server':
config_hash => { 'root_password' => 'foo' }
}
2012-02-10 08:15:06 +01:00
2012-02-09 20:26:00 +01:00
Database login information stored in `/root/.my.cnf` .
2012-02-10 08:15:06 +01:00
### mysql::db
Creates a database with a user and assign some privileges.
2012-02-09 20:26:00 +01:00
mysql::db { 'mydb':
user => 'myuser',
password => 'mypass',
host => 'localhost',
grant => ['all'],
}
2012-02-10 08:15:06 +01:00
### Providers for database types:
2012-02-09 20:26:00 +01:00
MySQL provider supports puppet resources command:
$ puppet resource database
database { 'information_schema':
ensure => 'present',
charset => 'utf8',
}
database { 'mysql':
ensure => 'present',
charset => 'latin1',
}
The custom resources can be used in any other manifests:
database { 'mydb':
charset => 'latin1',
}
database_user { 'bob@localhost':
password_hash => mysql_password('foo')
}
database_grant { 'user@localhost/database':
privileges => ['all'] ,
}
A resource default can be specified to handle dependency:
Database {
require => Class['mysql::server'],
}