Mysql – How to use Chef Data bags to setup a thesql server

chefMySQL

Ok I'm getting started with Chef using the opscode server.

I'm using the community cookbooks, and I've got basics working (I created a users/myname.json data bag and added the user::sysadmins recipe to my node, and that works fine, the myname user is created).

I added the mysql::server receipe to the node , which installs the server fine, however, where I am stuck is configuring the servers passwords using data bags.

I created a apps/dbmaster.json data bag, with the following contents

{
  "id":"dbmaster",
  "mysql_root_password": {
    "_default": "strawberry"
  },
   "mysql_repl_password": {
    "_default": "apple"
  }
}

but the mysql users are set up with the default passwords. I think I'm confused on how data bags are related to nodes ? Any help appreciated.

Best Answer

The mysql::server recipe does not use data bags to set up the passwords by default. It uses node attributes, which get randomly generated in that recipe, unless they are present from another source such as a role.

The database::master recipe in Opscode's database cookbook will manage the attributes based on values in a data bag for an application. This cookbook is intended to be used with the application cookbook also by Opscode, for managing application deployment and configuration integration through data bags.