DevOps Classroom Series – 02/Dec/2019

Chef-Client Supermarket cookbook

  • Using this cookbook from supermarket
    • Convergence can be changed
    • Scheduled jobs can be created
    • Chef-Client log locations can be changed.

Changing default convergance of a node to 2 hours.

  • search for chef-client cookbook in Chef Supermarket. Refer Here
  • Create a cookbook called as changecovnergence.
  • Add depends 'chef-client', '~> 11.4.0' to metadata.rb
  • Execute berks install
  • create a attribute file called as default using chef generate attribute . default
  • In the attributes/default.rb add the following line
default['chef_client']['interval'] = 7200
  • In recipes/default.rb add the following line
include_recipe 'chef-client::default'
  • Now upload this cookbook to chef server using berks upload and add this recipe to run_list of any node will change convergence from 30 minutes to 2 hours.

Scenario:

  • The Servers look as shown below Preview
  • How do you design this deployment using chef
  • Create 3 cookbooks
    • Mysql
    • tomcat
    • IIS Server
  • use kitchen to verify cookbooks are working
  • upload the cookbooks to chef server
  • Ensure all the 8 servers are bootstrapped.
  • Change the run_list of each server and add the necessary recipe or recipe list

Pain points

  • Bootstrapping multiple servers
  • Changing run list of every server

Change in scenario.

  • Lets assume you are asked to install git on every node.
  • For this we need to change the run list of every node.

Lets try to minimize efforts in Changing run_lists

  • Chef has a concept called as role.

  • Role is nothing but list of recipes.

  • We create 3 roles

    • mysql-role => mysql::default
    • tomcat-role => tomcat::default
    • iis-role => iis::default
  • In all the server where i need mysql to be installed in run_list i will add mysql-role

  • In all the server where i need tomcat to be installed in run_list i will add tomcat-role

  • In all the server where i need iis to be installed in run_list i will add iis-role

  • If i need to add git to every node, there is no need to change run_list just edit the roles.

    • mysql-role => mysql::default, git::default
    • tomcat-role => tomcat::default, git::default
    • iis-role => iis::default, git::default
  • Its always a best practice to have roles like

    • db-role
    • app-role
    • web-role

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About continuous learner

devops & cloud enthusiastic learner