DevOps Classroom Series – 20/Jan/2021
Scenario: Configure LAMP Server
- Linux Apache Server and mysql (LAMP Stack)
- Ubuntu Refer Here
- Centos 7 Refer Here
- Generate a cookbook
- Now lets generate a recipe for installing lamp in ubuntu server
- Now lets configure kitchen.yaml file to create an ubuntu instance in aws
- Refer Here for the change set
- Now lets execute
kitchen create
- Now lets write down manual linux commands to be executed to configure lamp server
sudo apt update
sudo apt install apache2
sudo apt install php libapache2-mod-php php-mysql php-cli
sudo systemctl restart apache2
# Create a file in /var/www/html/info.php with the following content
<?php
phpinfo();
?>
- In Chef to perform steps we have resource. Resource is a statement of configuration that describes the desired state
- Resource Syntax
type 'name' do
attribute 'value'
action :type_of_action
end
- Refer Here for chef resource documentation
- Refer Here for the Resources reference
- We can find resource for manual command
- by searching in resources section
- by searching in google
- by searching in resources section
- Ensure Chef Extension to Visual studio code is installed
- To install visual studio and other softwares required Refer Here
- Refer Here for the first step automation & now lets converge using
kitchen converge
- Now lets move to the next step Refer Here for the changeset. Now lets converge
- Now lets verify if apache is installed or not
- Now lets try to configure for the step
sudo apt install php libapache2-mod-php php-mysql php-cli -y
- Refer Here for the changes and perform convergence
- Refer Here for the changes and perform convergence
- We were able to perform lamp installation on ubuntu and verify it manually using test kitchen
- Our cookbook might not be effective at this point of time
- Our recipe has to use loops to become effective
- Our cookbook is restarting apache during every convergane which is not a good sign
- So in our next session we will learn how to overcome this and also learn more about chef resources
- Exercise: Create a new recipe lamp_centos and try to automate the steps mentioned Refer Here
- AMI ID for centos 7 in us-west-2 is ami-0bc06212a56393ee1