A Chef cookbook for installing MariaDB and creating databases and database users from data bags.
MariaDB is an enhanced, drop-in replacement for MySQL.
Using Berkshelf, add the mariadb cookbook to your Berksfile.
cookbook 'mariadb', github: 'logankoester/chef-mariadb', branch: 'master'
Then run berks
to install it.
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.
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.
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.
Refer to attributes/default.rb
for details.
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.
git clone git@github.com:logankoester/chef-mariadb.git
cd chef-mariadb
bundle install
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.
Copyright (c) 2014-2015 Logan Koester. Released under the MIT license. See LICENSE
for details.