example42 / puppet-mysql

Mysql Puppet Module
http://www.example42.com
Other
16 stars 38 forks source link

Deprecation notice

This module was designed for Puppet versions 2 and 3. It should work also on Puppet 4 but doesn't use any of its features.

The current Puppet 3 compatible codebase is no longer actively maintained by example42.

Still, Pull Requests that fix bugs or introduce backwards compatible features will be accepted.

Puppet module: mysql

This is a Puppet mysql module from the second generation of Example42 Puppet Modules.

Made by Alessandro Franceschi / Lab42

Official site: http://www.example42.com

Official git repository: http://github.com/example42/puppet-mysql

Released under the terms of Apache 2 License.

This module requires functions provided by the Example42 Puppi module.

For detailed info about the logic and usage patterns of Example42 modules read README.usage on Example42 main modules set.

USAGE - Module specific

Create database and manage GRANT

The simplest way to create database is the following.

    mysql::grant { 'db1':
      mysql_user     => 'myusername',
      mysql_password => 'mypassword',
    }

This will create a MySQL database named 'db1' with a MySQL grant allowing full access to user 'myusername' with 'mypassword' password on local host.

Customize host source

If you want to customize the host the new user can connect from you have to use the 'mysql_host'.

    mysql::grant { 'db1':
      mysql_user     => 'myusername',
      mysql_password => 'mypassword',
      mysql_host     => '10.42.42.0/255.255.255.0',
    }

Here the whole 10.42.42.0/24 can connect.

Customize privileges

For privileges customization there is the 'mysql_privileges' parameter.

    mysql::grant { 'db1':
      mysql_user       => 'myusername',
      mysql_password   => 'mypassword',
      mysql_privileges => 'SELECT',
    }

The default grant privileges is 'ALL'.

Remove GRANT

Like for standard puppet resource you can use the 'ensure' parameter in order to remove a grant.

    mysql::grant { 'db1':
      ensure         => 'absent',
      mysql_user     => 'myusername',
      mysql_password => 'mypassword',
    }

This will ensure the 'myusername@localhost' grant is absent but not the database.

Load initial data

The mysql_db_init_query_file is an optional parameter allowing to specify a sql file. The execution of this SQL file will be triger only once at the creation time.

    mysql::grant { 'db1':
      ensure                   => 'absent',
      mysql_user               => 'myusername',
      mysql_password           => 'mypassword',
      mysql_db_init_query_file => '/full/path/to/the/schema.sql',
    }

NOTE: The SQL file should already be uploaded on mysql server host.

USAGE - Basic management

USAGE - Overrides and Customizations

USAGE - Hiera Support

mysql::template: 'modules/mysql/my.cnf.erb'
mysql::root_password: 'example42'
mysql::options:
  port: '3306'
  bind-address: '127.0.0.1'
mysql::grant_hash:
  'db1':
    mysql_user: 'myusername'
    mysql_password: 'mypassword'
    mysql_host: '10.42.42.0/255.255.255.0'

USAGE - Example42 extensions management

Build Status