DevOps Classroom Series – 21/Jan/2021

Scenario: Configure LAMP Server Contd

  • In this series lets try to configure lamp on centos7
  • Centos 7 Refer Here
  • Lets list out manual steps
sudo yum install httpd
sudo systemctl start httpd.service
sudo yum install php php-mysql php-fpm -y
# Create a file in /var/www/html/info.php with the following content
<?php
phpinfo();
?>
  • Lets create a new recipe lamp_centos Refer Here for the changeset Preview
  • create resources to install apache and start apache service Refer Here
  • Now lets configure kitchen.yaml file to create centos7 and create the resources Refer Here for the changeset Preview
  • Now lets try to converge the resources Preview Preview Preview
  • Now lets try creating resources for rest of the steps Refer Here Preview
  • Now if we need to run the same cookbook for both ubuntu and centos, we need to come up with a logic
if os is 'ubuntu' 
  run qtlampserver::lamp_ubuntu
else if os is 'centos'
  run qtlampserver::lamp_centos
end
  • The first thing which we need to understand is how do i know if the node is ubuntu or centos
  • Ohai is a tool in chef that collects system configuration data. so lets use ohai tools platform value to make a decision. Refer Here Preview
  • The file creation of info.php is the same code copied twice. lets create a different recipe where filecreation is handled, so both platforms can use it Refer Here Preview
  • Now lets look at recipes for ubuntu and centos and compare them
    • In chef we have a common resource called as package Refer Here which can be used for generic package installations Refer Here
  • Next Steps:
    • Lets see how we can apply variables, conditionals and looping in Chef.
    • Lets learn just enough ruby for chef
    • Lets understand node object and ohai

Leave a Reply

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

About learningthoughtsadmin