DevOps Classroom Series – 02/Jun/2021

Cookbook Improvements

  • Raise an error message when cookbook is executed on unsupported platforms Refer Here for the changes

  • Supporting multiple operating systems/distributions for a cookbook

  • Lets support for RedHat 8:

    • Manual commands:
    sudo dnf update
    sudo dnf install httpd -y
    sudo systemctl enable httpd.service
    sudo systemctl start httpd.service
    sudo dnf install php php-mysqlnd php-mbstring php-opcache php-gd -y
    echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php
    
  • Refer Here for the change set with support for redhat

  • Reusing the resources rather than copying (redundant)

  • only_if and not_if gaurds to imporve readability

    • Consider the below resource
      if node['platform'] == 'ubuntu'
          apt_update 'update ubuntu packages' do
              ignore_failure true
              action :update
          end
      end
    
    • Can be written as
      apt_update 'update ubuntu packages' do
          ignore_failure true
          action :update
          only_if { node['platform'] == 'ubuntu' }
      end
      
  • Created one recipe apache which works on both ubuntu and redhat distributions Refer Here for the changes made

Leave a Reply

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

About learningthoughtsadmin