joerocklin / chef-mariadb

A cookbook for installing MariaDB, based on a fork of the Opscode Cookbook for MySQL.
Apache License 2.0
25 stars 24 forks source link

mariadb Cookbook

Build Status

Installs and configures MariaDB client or server.

A word of caution: I have not tested it on anything beside CentOS 6.4 with chef solo. I would be happy to accept patches for other platforms!

Requirements

Chef 0.10.10+.

Platform

Tested on:

See TESTING.md for information about running tests in Opscode's Test Kitchen.

Cookbooks

Requires Opscode's openssl cookbook for secure password generation. See Attributes and Usage for more information.

The RubyGem installation in the mysql::ruby recipe requires a C compiler and Ruby development headers to be installed in order to build the mysql gem.

The RubyGem installation in the mariadb::ruby recipe requires a C compiler and Ruby development headers to be installed in order to build the mariadb gem.

Requires homebrew cookbook on Mac OS X.

Resources and Providers

The LWRP that used to ship as part of this cookbook has been refactored into the database cookbook. Please see the README for details on updated usage.

Attributes

See the attributes/server.rb or attributes/client.rb for default values. Several attributes have values that vary based on the node's platform and version.

Performance and other "tunable" attributes are under the node['mariadb']['tunable'] attribute, corresponding to the same-named parameter in my.cnf, and the default values are used. See attributes/server.rb.

By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment.

Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network.

The following attributes are randomly generated passwords handled in the mariadb::server recipe, using the OpenSSL cookbook's secure_password helper method. These are set using the set_unless node attribute method, which allows them to be easily overridden e.g. in a role.

Windows Specific

The following attributes are specific to Windows platforms.

Security Options

Further information is already available at Symantec and Deutsche Telekom (German)

Usage

On client nodes, use the client (or default) recipe:

    { "run_list": ["recipe[mariadb::client]"] }

This will install the MariaDB client libraries and development headers on the system.

On nodes which may use the database cookbook's mariadb resources, also use the ruby recipe. This installs the mariadb RubyGem in the Ruby environment Chef is using via chef_gem.

{ "run_list": ["recipe[mariadb::client]", "recipe[mariadb::ruby]"] }

If you need to install the mariadb Ruby library as a package for your system, override the client packages attribute in your node or role. For example, on an Ubuntu system:

{
  "mariadb": {
    "client": {
      "packages": ["mariadb-client", "libmariadbclient-dev","ruby-mariadb"]
    }
  }
}

This creates a resource object for the package and does the installation before other recipes are parsed. You'll need to have the C compiler and such (ie, build-essential on Ubuntu) before running the recipes, but we already do that when installing Chef :-).

On server nodes, use the server recipe:

    { "run_list": ["recipe[mariadb::server]"] }

On Debian and Ubuntu, this will preseed the mariadb-server package with the randomly generated root password in the recipe file. On other platforms, it simply installs the required packages. It will also create an SQL file, /etc/mariadb/grants.sql, that will be used to set up grants for the root, repl and debian-sys-maint users.

The recipe will perform a node.save unless it is run under chef-solo after the password attributes are used to ensure that in the event of a failed run, the saved attributes would be used.

On EC2 nodes, use the server_ec2 recipe and the mariadb data dir will be set up in the ephmeral storage.

    { "run_list": ["recipe[mariadb::server_ec2]"] }

When the ec2_path doesn't exist we look for a mounted filesystem (eg, EBS) and move the data_dir there.

The client recipe is already included by server and 'default' recipes.

For more infromation on the compile vs execution phase of a Chef run:

Chef Solo Note

These node attributes are stored on the Chef server when using chef-client. Because chef-solo does not connect to a server or save the node object at all, to have the same passwords persist across chef-solo runs, you must specify them in the json_attribs file used. For example:

    {
      "mariadb": {
        "server_root_password": "iloverandompasswordsbutthiswilldo",
        "server_repl_password": "iloverandompasswordsbutthiswilldo",
        "server_debian_password": "iloverandompasswordsbutthiswilldo"
      },
      "run_list":["recipe[mariadb::server]"]
    }

License & Authors

Copyright:: 2009-2013 Opscode, Inc

- Author:: Joe Rocklin (<joe.rocklin@gmail.com>)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.