Basic Terminology
- Convergence:
- It is the when node (chef-client) interacts with chef-server.
- During the convergence the chef server responds back with the recipes in run_list configured for the node to be executed.
- By default the convergence happens every 1/2 hour and this can be changed

- Resource:
- In chef resource is smallest unit of work that automates some activity and allows us to express the desired state
- Refer Here for all the infra resources.

Approach for Automating Deployments
- To automate any deployment,
- make a note of all the manual steps involved
- Try to execute them on some test server to ensure manual steps are correct
- Once you have consolidated steps, for each step try to find a chef resource.
Activity-1: Installing a Lamp Server on Ubuntu 20.04
- Refer Here for the manual steps
- Manual steps:
sudo apt update
sudo apt install apache2 -y
sudo apt install php libapache2-mod-php php-mysql -y
echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php
sudo systemctl restart apache2
- Evalaute whether these commands work or not:
- Lets create an ubuntu 20.04 vm and execute the commands
- Navigate to
http://<public-ip>
- Navigate to
http://<public-ip>/info.php
- Goal: To automate the above mentioned manual steps in chef
- Steps to Achieve:
- We can start by creating a cookbook
- finding right resources
- Expressing the desired state
- Upload the cookbook
- Wait for convergence or manually force the chef-client run
