DevOps Classroom Series – 28/Jan/2021

InSpec

  • This is an opensource framework for testing and auditing your applications and infrastructure. Refer Here for the official docs
  • Chef inspec comes with built in resources to test the behavior of your cookbook Refer Here
  • Scenario: Lets test our tomcat cookbook
  • Lets verify whether java is installed or not Refer Here for package resource
  • Write tests Refer Here for the changes made
  • Now execute kitchen verify Preview

Chef Cookstyle

  • This is a code linting tool that helps you in writing better chef cookbooks.
  • This increases code quality by
    • Enforcing style conventions & best practices
    • Maintaining uniformityin the source code
    • Detecting common mistakes that cause code to behave incorrectly or fail
  • To run cookstyle execute cookstyle <path to cookbook>
  • To autocorrect execute cookstyle -a <path to cookbook>
  • Refer Here for the changeset with cookstyle corrections
  • Refer Here for official documentation

Chef Custom Resources

  • In chef in some cases we might be intrested in create our own resources to perform some application action, Chef gives option to create our own resources
  • Execute chef generate resource --help Preview
  • Refer Here for official docs
  • Now lets generate a resource called as qttomcat Preview
  • Lets write a custom resource to install java Refer Here for the changeset Preview
  • Created one more custom resource to deploy war file Refer Here for the changeset

Leave a Reply

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

About learningthoughtsadmin