sous-chefs / mysql

Development repository for the mysql cookbook
https://supermarket.chef.io/cookbooks/mysql
Apache License 2.0
338 stars 690 forks source link

Clarify README to address recurring questions #302

Closed someara closed 9 years ago

someara commented 9 years ago
fletchowns commented 9 years ago

I had a bit of trouble getting this going. My goal was to install MySQL, start the service, create a database, and create a user for that database. I had been using the old attribute driven version of this cookbook but it seems a lot has changed since then, maybe I missed the doc that explained more about the differences in how it used to work vs. how it works now but it took some work to get setup on the new cookbook.

I ended up having to use 3 different cookbooks to accomplish my goal. It wasn't immediately clear what the responsibility of each cookbook was. For example, the readme for this cookbook currently has this in the beginning:

The Mysql Cookbook is a library cookbook that provides resource primitives (LWRPs) for use in recipes. It is designed to be a reference example for creating highly reusable cross-platform cookbooks.

It doesn't really tell me anything about what this cookbook actually does. i.e. Does it install MySQL?

My metadata.rb ended up looking like this:

depends 'mysql2_chef_gem'
depends 'mysql'
depends 'database'

My recipe ended up looking something like:

mysql2_chef_gem 'default' do
    action :install
end

database_secrets = Chef::EncryptedDataBagItem.load(node["my-cookbook"]["encrypted_data_bag_name"], "database")

mysql_service "default" do
    port "3306"
    version "5.6"
    initial_root_password database_secrets["root_password"]
    action [:create, :start]
end

mysql_connection_info = {
    :host => "127.0.0.1",
    :username => "root",
    :password => database_secrets["root_password"]
}

mysql_database node["my-cookbook"]["database_name"] do
    connection(mysql_connection_info)
    action :create
end

mysql_database_user database_secrets["username"] do
    connection (mysql_connection_info)
    password database_secrets["password"]
    action [:create, :grant]
    database_name node["my-cookbook"]["database_name"]
end

I ended up not doing anything with the mysql_config LWRP since I don't have a need to customize any config parameters just yet. But it was confusing because it was in the 'basic usage' example in the readme, and it expects that you already created a 'mysite.cnf.erb' template. I hadn't yet, and I wasn't even sure what is supposed to go in it.

Everything is working great now but I think the whole process could have been easier. I think setting up a LAMP stack will be a common starting point for newcomers to chef so it would be very beneficial to the community if this use case was a little more user friendly.

someara commented 9 years ago

I've added language to the README to address common usage questions. Let me know if this is still unclear.

lock[bot] commented 6 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.