Chef CookBook to install and Configure Web Server on Linux?OS
Samarth Pant
Information Technology Analyst @ TCS | Contextual Master | OpenTofu | Terraform |
About Chef:
Progress Chef (formerly Chef) is a configuration management tool written in Ruby and Erlang. It uses a pure-Ruby, domain-specific language (DSL) for writing system configuration “recipes”. Chef is used to streamline the task of configuring and maintaining a company’s servers and can integrate with cloud-based platforms such as Amazon EC2, Google Cloud Platform, Oracle Cloud, OpenStack, IBM Cloud, Microsoft Azure, and Rackspace to automatically provision and configure new machines. Chef contains solutions for both small and large scale.
About CookBook:
In the cookBook named webServer I have written configuration to install WebServer on Linux OS(RedHat or Ubuntu), and then create files for a httpd web server so that those files can be hosted on the WebServer.
Below is the CookBook Structure:
Step by Step process to Generate and Configure the CookBook:
mkdir cookbooks
领英推荐
chef generate cookbook webServer
mkdir webServer/templetes
vim mycompany.html.erb
# Add content to the file(link for GitHub repo will be shared for reference)
mkdir webServer/files
vim webpage.html
# Add content to the file(link for GitHub repo will be shared for reference)
vim installapache.rb # (you can give any file name you want or can also use the default.rb file which is already present)
# Add content to the file(Link for GitHub repo will be shared for reference)
# In this recipe:
-> webserver will be installed based on Linux Distribution,
-> service for http server will start,
-> sample.html file will be created
-> index.html file will be created using mycompany.html.erb template and variables will be passed for the file
-> webpage.html file will be created from the webpage.html file.
Now our CookBook is ready to be deployed.
Once all the changes are ready just run the below command to deploy the CookBook
chef-client -z -o "recipe[webServer::installapache]"
Once the above command successfully executes, we will have our WebServer deployed and one can test using the URL localhost:80/ followed by the file names.