1. Home
  2. Docs
  3. ClusterControl
  4. Installation
  5. Automatic Installation
  6. Chef Cookbooks

Chef Cookbooks

If you are automating your infrastructure using Chef, we have created a cookbook for this purpose and it is available at Chef Supermarket. Getting the cookbook is as easy as:

$ knife cookbook site download clustercontrol


This cookbook requires the following criteria to be met:

  • The node for ClusterControl must be a clean/dedicated host.
  • ClusterControl node must be running on a 64bit OS platform and together with the same OS distribution with the monitored DB hosts. Mixing Debian with Ubuntu and CentOS with Red Hat is acceptable.
  • ClusterControl node must have an internet connection during the deployment. After the deployment, ClusterControl does not need internet access.
  • Make sure your database cluster is up and running before performing this deployment.

Data items are used by the ClusterControl controller recipe to configure SSH public key on database hosts, grants cmon database user and setting up CMON configuration file. We provide a helper script located under clustercontrol/files/default/s9s_helper.sh. Please run this script prior to the deployment.

Answer all the questions and at the end of the wizard, it will generate a data bag file called config.json and a set of commands that you can use to create and upload the data bag. If you run the script for the first time, it will ask to re-upload the cookbook since it contains a newly generated SSH key:

$ knife cookbook upload clustercontrol

Chef Workstation

This section shows example ClusterControl installation with Chef and requires you to use knife. Please ensure it has been configured correctly and is able to communicate with the Chef Server before you proceed with the following steps. The steps in this section should be performed on the Chef Workstation node.

1. Get the ClusterControl cookbook using knife:

$ cd ~/chef-repo/cookbooks
$ knife cookbook site download clustercontrol
$ tar -xzf clustercontrol-*
$ rm -Rf *.tar.gz

2. Run s9s_helper.sh to auto-generate SSH key file, ClusterControl API token and data bag items:

$ cd ~/chef-repo/cookbooks/clustercontrol/files/default
$ ./s9s_helper.sh
Helper script for ClusterControl Chef cookbook

ClusterControl will install a MySQL server and setup the MySQL root user.
Enter the password for MySQL root user [password] : R00tP4ssw0rd

ClusterControl will create a MySQL user called 'cmon' for automation tasks.
Enter the password for user cmon [cmon] : Bj990sPkj

Generating config.json..
  "id" : "config",
  "mysql_root_password" : "R00tP4ssw0rd",
  "cmon_password" : "Bj990sPkj",
  "clustercontrol_api_token" : "662894d3e854ed779babd895a82dc0f8eed86ccc"

Data bag file generated at /root/cookbooks/clustercontrol/files/default/config.json
To upload the data bag, you can use following command:
$ knife data bag create clustercontrol
$ knife data bag from file clustercontrol /root/cookbooks/clustercontrol/files/default/config.json

** We highly recommend you to use encrypted data bag since it contains confidential information **

3. As per instructions above, on Chef Workstation host, do:

$ knife data bag create clustercontrol
Created data_bag[clustercontrol]

$ knife data bag from file clustercontrol /home/ubuntu/chef-repo/cookbooks/clustercontrol/files/default/config.json
Updated data_bag_item[clustercontrol::config]

$ knife cookbook upload clustercontrol
Uploading clustercontrol [0.1.6]
Uploaded 1 cookbook

4. Create a role, cc_controller:

$ cat cc_controller.rb
name "cc_controller"
description "ClusterControl Controller"
run_list ["recipe[clustercontrol]"]

5. Add the defined roles into Chef Server:

$ knife role from file cc_controller.rb
Updated Role cc_controller!

6. Assign the roles to the relevant nodes:

$ knife node run_list add clustercontrol.domain.com "role[cc_controller]"

Chef Client

Let chef-client run on each Chef client node and apply the cookbook:

$ sudo chef-client

Once completed, open the ClusterControl UI at http://ClusterControl_host/clustercontrol and create the default admin user and password.

For more examples of deployments using Chef, please refer to Chef Cookbooks for ClusterControl – Management and Monitoring for your Database Clusters. For more info on the configuration options, please refer to the ClusterControl Chef Cookbooks page.


Was this article helpful to you? Yes No