Devops Classroom Series – 29/Jan/2021

Chef Supermarket

  • There are lot of community cookbooks available for usage, we can use them instead of writing/developing cookbooks from scratch

  • They are hosted at Chef Supermarket website Refer Here

  • Scenario: Lets make use of chef supermarket cookbooks to install mysql and tomcat on ubuntu and centos machines

  • Refer Here for the mysql cookbook that can be used

  • Lets create a cookbook called as supermarket demo Preview

  • Lets configure kitchen.yaml to create centos and ubuntu machines

  • Mention about the depencies in the metadata.rb file.

    • ~> refers to pesimistic versioning. (~> 1.0.0 => will accept 1.0.x)
    • = refers equals (=> 1.0.1 )
    • > < <= >= for less and grater than particular version numbers
  • Add depends to the metadata.rb to define dependency Preview

  • Now execute berks install Preview

  • Refer Here for the changeset

  • Now lets add the dependency to install tomcat server. Refer Here for supermarket docs

  • Refer Here for the changeset

  • Now lets try to install mongo db Refer Here

  • Whenever we use supermarket cookbooks as dependencies, there are two possible ways of using dependency

    • use the custom resources developed to perform some action
      tomcat_install 'helloworld' do
          version '8.0.36'
      end
    
      tomcat_service 'helloworld' do
          action :start
      end
    
    • Include the recipe of the dependency in run_list or use include_recipe. In this case we might also define some attributes to change the behavior
    include_recipe "sc-mongodb::default"
    
  • Best Practices

    • Always use the cookbooks from supermarket which have recent updates and lot of followers
    • For Production try to use equals operator in metadata.rb as the results will be consistent
  • Exercise:

    • Try install postgres server using supermarket cookbooks

Leave a Reply

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

Please turn AdBlock off
Floating Social Media Icons by Acurax Wordpress Designers

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube