No description
Find a file
Ashley Penney 2abccab4d9 Refactor and rename database_grant to mysql_grant.
This provider has undergone the largest set of changes and currently
just accepts a full SQL grant string as the name and then applies it,
making things easier for DBAs and removes the awkward attempts at
modelling grants into Puppet.
2013-09-03 17:24:21 -04:00
files (#12412) mysqltuner.pl update 2012-02-04 07:08:08 +11:00
lib/puppet Refactor and rename database_grant to mysql_grant. 2013-09-03 17:24:21 -04:00
manifests Refactor and rename database_grant to mysql_grant. 2013-09-03 17:24:21 -04:00
spec Refactor and rename database_grant to mysql_grant. 2013-09-03 17:24:21 -04:00
templates Add option to mysql::backup to set the backup script to perform a mysqldump on each database to its own file 2013-08-27 15:15:29 -05:00
tests Refactor and rename database_grant to mysql_grant. 2013-09-03 17:24:21 -04:00
.fixtures.yml Update specs for current testing practices and GH publish 2013-06-26 14:19:57 -07:00
.gitignore Add rspec-system / serverspec tests 2013-07-05 15:19:02 -07:00
.nodeset.yml Add rspec-system / serverspec tests 2013-07-05 15:19:02 -07:00
.travis.yml Update specs for current testing practices and GH publish 2013-06-26 14:19:57 -07:00
CHANGELOG Fix this so we don't list dates or versions yet. 2013-07-26 14:04:18 -04:00
Gemfile Refactor and rename database_grant to mysql_grant. 2013-09-03 17:24:21 -04:00
LICENSE Added documentation and license to module. 2011-05-31 20:47:19 -07:00
Modulefile Release 0.9.0 2013-07-15 16:55:13 -07:00
Rakefile Add rspec-system / serverspec tests 2013-07-05 15:19:02 -07:00
README.md Use new provider names in manifests. 2013-08-28 18:11:21 -04:00
TODO added some additional TODOS 2011-06-03 13:27:44 -07:00

Mysql module for Puppet

Build Status

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.

Pluginsync needs to be enabled for this module to function properly. Read more about pluginsync in our docs

Description

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
    }
  }
}

This module depends on the creates_resources function which is introduced in Puppet 2.7. Users on puppet 2.6 can use the following module which provides this functionality:

http://github.com/puppetlabs/puppetlabs-create_resources

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
  • Michael Arnold
  • Chris Weyl

Usage

mysql

Installs the mysql-client package.

class { 'mysql': }

mysql::java

Installs mysql bindings for java.

class { 'mysql::java': }

mysql::perl

Installs mysql bindings for perl

class { 'mysql::perl': }

mysql::php

Installs mysql bindings for php

class { 'mysql::php': }

mysql::python

Installs mysql bindings for python.

class { 'mysql::python': }

mysql::ruby

Installs mysql bindings for ruby.

class { 'mysql::ruby': }

mysql::server

Installs mysql-server packages, configures my.cnf and starts mysqld service:

class { 'mysql::server':
  config_hash => { 'root_password' => 'foo' }
}

Database login information stored in /root/.my.cnf.

mysql::db

Creates a database with a user and assign some privileges.

mysql::db { 'mydb':
  user     => 'myuser',
  password => 'mypass',
  host     => 'localhost',
  grant    => ['all'],
}

mysql::backup

Installs a mysql backup script, cronjob, and privileged backup user.

class { 'mysql::backup':
  backupuser     => 'myuser',
  backuppassword => 'mypassword',
  backupdir      => '/tmp/backups',
}

Providers for database types:

MySQL provider supports puppet resources command:

$ puppet resource database
mysql_database { 'information_schema':
  ensure  => 'present',
  charset => 'utf8',
  collate => 'utf8_swedish_ci',
}
mysql_database { 'mysql':
  ensure  => 'present',
  charset => 'latin1',
  collate => 'latin1_swedish_ci',
}

The custom resources can be used in any other manifests:

mysql_database { 'mydb':
  charset => 'latin1',
}

mysql_user { 'bob@localhost':
  password_hash => mysql_password('foo')
}

database_grant { 'user@localhost/database':
  privileges => ['all'] ,
  # Or specify individual privileges with columns from the mysql.db table:
  # privileges => ['Select_priv', 'Insert_priv', 'Update_priv', 'Delete_priv']
}

A resource default can be specified to handle dependency:

Mysql_database {
  require => Class['mysql::server'],
}