/chef-mariadb

Chef cookbook for MariaDB (MySQL implementation)

Primary LanguageRubyMIT LicenseMIT

MariaDB cookbook

A Chef cookbook for installing MariaDB and creating databases and database users from data bags.

Build Status Gittip

MariaDB is an enhanced, drop-in replacement for MySQL.

Installation

Using Berkshelf, add the mariadb cookbook to your Berksfile.

cookbook 'mariadb', github: 'logankoester/chef-mariadb', branch: 'master'

Then run berks to install it.

Usage

Add recipe[mariadb::default] to your run list. This recipe will install mariadb, enable and start the mysql service. It's configuration file (my.cnf) is installed from a template. Databases and users will be set up from data bags you create.

Database users

Create a database_users data bag, with an item called root. This is your root database user:

{
  "id": "root",
  "username": "root",
  "password": "SET A SECURE ROOT PASSWORD!",
  "host": "127.0.0.1"
}

You can also create additional database_user items if you wish.

Databases

Create a databases data bag. Items should look like this:

{
  "id": "some_database",
  "name": "some_database",
  "users": {
    "some_database_user": ["all"]
  }
}

The users property maps items from the database_users data bag to an array of privileges which should be granted.

Attributes

Refer to attributes/default.rb for details.

Running the tests

This cookbook uses the Foodcritic linter, ChefSpec for unit testing, and ServerSpec for integration testing via Test Kitchen with the kitchen-docker driver.

It's not as complicated as it sounds, but you will need to have Docker installed.

  1. git clone git@github.com:logankoester/chef-mariadb.git
  2. cd chef-mariadb
  3. bundle install
  4. bundle exec rake

This will run all of the tests once. While developing, run bundle exec guard start and the relevant tests will run automatically when you save a file.

Author

Copyright (c) 2014-2015 Logan Koester. Released under the MIT license. See LICENSE for details.