Top 50 Interview questions on Configuration Management – Chef
1. Define Chef and its architecture in DevOps?
Chef is a powerful automation tool to transform the Company infrastructure into a well-structured code. With the assistance of Chef, you’ll write scripts that are further wont to automate the business processes. Of course, the processes are somewhat related to IT.
CHEF INFRASTRUCTURE
There are three major components of Chef architecture include – Chef workstation, Chef server, and Chef node. They need to arrange in the same format as shown below in the diagram.
Chef Server – this is often a central storage house that stores necessary data necessary to configure the nodes.
Chef Node – A node is predicated on the chef-client architecture where nodes are referred as client responsible to share data across the network
Chef Workstation – this is often a number that helps you to switch the configuration data and cookbooks then it’s forwarded to the Chef Server.
2. Explain Chef Resource and its functions in brief?
A Resource is employed to represent a neighborhood of the infrastructure and its state, a package that you simply have an interest in installing, a running service, or a file you’re planning to create. Now, let us see the functions of resources in brief –
It helps you to explain the specified state of a configuration item.
You will know the process or steps that will be followed to bring a particular item in the desirable state.
You can specify the sort of resources like template, package, or service etc.
It helps to list the resource properties and the additional details that are necessary.
Further, resources are often grouped into recipes to explain the working configurations.
3. Define Chef Recipe and its functions too?
When resources are grouped together, it becomes a Recipe that describes the working configurations and policy. With a Recipe, you’ll get to understand everything necessary to configure a specific system. Let us have a quick look at functions of Recipe –
Software components are often installed or configured with Chef Recipe.
It is wont to manage files and apps deployments too.
With one recipe, the opposite related recipes also can be executed.
4. Explain a Chef Node and why is it important?
A node is a virtual machine or a physical server that is an important part of the Chef architecture. It is basically wont to execute any resource in Chef.
5. What is a Cookbook and how is it different from the Recipe in Chef?
When resources are grouped together, it becomes a Recipe that describes the working configurations and policy. At an equivalent time, when recipes are combined together, it becomes a cookbook and straightforward to manage as compared to one recipe.
6. What is DK in Chef?
DK is that workstation that permits users to interact with the Chef. There are special tools available installed within the DK workstation space which will be wont to make the interaction even better.
7. What is a Chef Repository and how it works?
As a developer, you can consider the chef repository as a collection of environments, roles, cookbooks, data bags and more. You can also sync the chef repository with the version system to further enhance the general performance.
8. What is the use of Chef in DevOps?
Chef is beneficial for handling and atomizing the framework. With the help of different chef DevOps products such as Chef-server, Chef-client chef IT automation is concluded. It is the instrument to speed up the application of delivery and DevOps cooperation.
9. How will you define the run-list in Chef?
With the assistance of run-list in chef, you’ll specify which Recipes must run and what should be the order of execution for Recipes.
Run-list makes sure that recipes are executed in the same order as defined by you. In case, there is some recipe that is added twice by mistake then it will not be made two times by the run-list.
You also got to specify the node on which run-list should be executed. Rub-list is additionally defined because of the object of the node that’s stored on Chef server.
It is maintained on Knife then from the workstation it’s transferred to Chef server and management Console in Chef.
10. Why are starter kits needed within the Chef?
To create the specified configuration files in Chef, starter kids are necessary. It helps to define the clear information for every configuration file and straightforward interaction with the server. This is easy to download the starter kits and take it to the specified place on the workstation where you would like to use them.
11. How to update a cookbook in Chef? Give answers based on your experience?
This is easy to update a cookbook in Chef and you’ll use any of the three methods given below supported your convenience –
Knife SSH can be run from the workstation.
Run the chef-client then SSH in your server directly.
The chef-client can be used as a service or daemon and make it restarted after every selected time interval, say 15 or 20 mins.
12. How can you bootstrap in Chef and tell me the required information needed for the same purpose?
To bootstrap in Chef, you would like the subsequent information as given below –
The public IP address or the hostname of your node.
To log in to a specific node, you would like the credentials details like username and password for an equivalent .
Further, you’ll choose authentication supported keys rather than using any login credentials.
13. What is a chef in automation?
Chef may be a powerful automation platform that transforms infrastructure into code.s The Chef server acts as a hub for configuration data.
Cookbooks are stored in the Chef server, the policies that are applied to nodes, and metadata that describes each registered node that’s being managed by the chef-client.
15. What is a chef server?
It acts as an hub for configuration data. Cookbooks are stored in the Chef server, the policies that are applied to nodes, and metadata that describes each registered node that’s being managed by Chef. Nodes use the Chef client to ask the Chef server for configuration details, like recipes, templates, and file distributions.
16. What are chef workstations?
A workstation may be a computer running the Chef Development Kit (ChefDK) that wants to author cookbooks, interact with the Chef server, and interact with nodes.
The workstation is that the location from which most users do most of their work, including:
Developing and testing cookbooks and recipes
Testing Chef code
Keeping the chef-repo synchronized with version source control
Configuring organizational policy including defining environments and roles, and ensuring that critical data is stored in data bags
Interacting with nodes, as (or when) required, like performing a bootstrap operation
17. What is chef-client Run?
A “chef-client run” is that the term wont to describe a series of steps that are taken by the chef-client when it’s configuring a node.
18. What is a chef validator?
chef-validator – Every request made by the chef-client to the Chef server must be an authenticated request using the Chef server API and a personal key. When the chef-client makes an invitation to the Chef server, the chef-client authenticates each request employing a private key located in /etc/chef/client.pem.
19. What are Signed Headers for chefs?
Signed header authentication is employed to validate communications between the Chef server and any node that’s being managed by the Chef server.
20. What is SSL_CERT_FILE in chef?
Use the SSL_CERT_FILE environment variable to specify the situation for the SSL certificate authority (CA) bundle that’s employed by the chef-client.
21. What are Knife Subcommands in chef?
Chef-client has two knife commands for managing the SSL certificates:
To troubleshoot SSL certificate issues Use knife ssl check.
Use knife ssl fetch to tug down a certificate from the Chef server to the /.chef/trusted_certs directory on the workstation.
22. What is the knife ssl check command in chef?
Run the knife ssl check subcommand to verify the state of the SSL certificate, then use the response to assist troubleshoot issues which will be present.
23. What is the knife ssl fetch command in chef?
The knife ssl fetch Runs to download the self-signed certificate from the Chef server to the /.chef/trusted_certs directory on a workstation.
24. What is the function of the chef-client?
- To communicate with the central chef server.
- The central chef-server handles the intimal registration of the node with For configuring it pulls down the Cookbooks to apply on the Node.
- periodic polling of the central chef server needed for fetching new configuration items.
25. Which version of the cookbook is ideal when it is ready to use in production?
The chef interview questions also can be quite on point like this one. Semantic Versioning dictates that once a cookbook is ready to use in production, the version number should be 1.0.0.
26. Which command helps in uploading a cookbook to the Chef server?
The command for uploading a cookbook to the Chef server is “knife cookbook upload”.
27. What are the functions of the Test Kitchen?
It is another common topic among chef interview questions. You can describe the functions of the Test Kitchen as follows:
Test Kitchen gives the power for using different virtualization providers for creating a container or virtual machine instances locally. Both the workstation and the cloud are preferable options for creation of instances using the Test Kitchen.
Test kitchens radically improve the speed of the development cycle. Test kitchen achieves this through automatic provisioning and exclusion of temporary instances. Also, Test kitchen helps in addressing cookbook dependencies and application of cookbooks to instances.
28. What is the difference between chef-apply and chef-client?
Chef-apply involves the appliance of one recipe and Chef-client involves the appliance of a cookbook. Chef-apply provides a far better understanding of the chef basics quickly and is right for learning purposes. On the other hand, chef-client is applicable for production purposes when one or more cookbooks should be applied.
29. What is OHAI in Chef?
OHAI is a tool in Chef for collection of system configuration data that goes to the chef-client. The chef-client runs OHAI at the start of every Chef run for determining system state. The various built-in plugins in OHAI help in recognizing general configuration details. Furthermore, you also get a plugin model to write custom plugins with OHAI.
30. What are Data Bags in Chef?
Data Bags are global variables stored in the form of JSON data. Data Bags are accessible from Chef Server. The indexing of data bags helps in easily searching for it or accessing it through a recipe.
31. What is the use of Knife in Chef?
A knife is a command-line tool for creating an interface between the Chef server and a local chef-repo. The knife is ideal for the management of nodes, cookbooks and recipes as well as roles, data bags, and environments. Furthermore, a knife is a promising instrument for managing resources in different cloud environments. Also, Knife helps in managing the installation of chef-client onto nodes and searching indexed data on the Chef server.
32. How Does A Cookbook Differ From A Recipe?
A recipe may be a collection of resources, and typically configures a software package or some piece of infrastructure. A cookbook groups together recipes and other information during a way that’s more manageable than having just recipes alone.
For example, during this lesson you used a template resource to manage your HTML home page from an external file. The recipe stated the configuration policy for your internet site , and therefore the template file contained the info . You used a cookbook to package both parts up into one unit that you simply can later deploy.
33. What Are The Two Ways To Set Up A Chef Server?
Install an instance on your own infrastructure.
Use hosted Chef.
34. What is the value of local development using Test Kitchen in Chef?
Test Kitchen enables you to use a spread of virtualization providers that make virtual machine or container instances locally on your workstation or within the cloud.
It enables you to run your cookbooks on servers that resemble those that you use in production.
It accelerates the event cycle by razing temporary instances and automatically provisioning, resolving cookbook dependencies, and applying your cookbooks to your instances.
35. What is a chef_acl resource?
The chef_acl resource is used to interact with access control lists (ACLs) that exist on the Chef server.
Syntax: The syntax for using the chef_acl resource during a recipe is as follows:
chef_acl ‘name’ do
attribute ‘value’ # see properties section below
…
action :action # see actions section below
end
36. Write a service Resource that stops and then disables the httpd service from starting when the system boots in Chef?
Use the below Resource to prevent and disable the httpd service from starting when the system boots.
service ‘httpd’ do
action [:stop, :disable]
end
37. What is a cron resource?
The cron resource is employed to manage cron entries for time-based job scheduling.
38. What is metadata.rb in chef?
Every cookbook requires a small amount of metadata. A file named metadata.rb is found at the highest of each cookbook directory structure. The contents of the metadata.rb file provides hints to the Chef server to assist make sure that cookbooks are deployed to every node correctly.
39. What information is stored in the metadata.rb file?
A metadata.rb file is:
Located at the highest level of a cookbook’s directory structure.
Compiled whenever a cookbook is uploaded to the Chef server or when the knife cookbook metadata subcommand is run, then stored as JSON data.
whenever the knife cookbook create subcommand is run it is created automatically by knife .
Edited employing a text editor, then re-uploaded to the Chef server as a part of a cookbook upload.
40. What are handlers for chefs?
Handlers are wont to identify situations that arise during a chef-client run, then tell the chef-client the way to handle these situations once they occur.
41. How many types of handlers are there in chef? What are they?
In chef there are three sorts of handlers are there they are:
Exception Handler
Report Handler
Start Handler
42. What is an exception handler in chef?
An exception handler is employed to spot situations that have caused a chef-client run to fail. An exception handler is often loaded at the beginning of a chef-client travel by adding a recipe that contains the chef_handler resource to a node’s run-list. An exception handler runs when it fails? property for the run_status object returns true.
43. What is a report handler for a chef?
A report handler is employed when a chef-client run succeeds and reports back on certain details that chef-client run. A report handler is often loaded at the beginning of a chef-client travel by adding a recipe that contains the chef_handler resource to a node’s run-list. A report handler runs when the success? property for the run_status object returns true.
44. What is a start handler in chef?
A start handler is employed to run events at the start of the chef-client run. A start handler are often loaded at the beginning of a chef-client travel by adding the beginning handler to the start_handlers setting within the client.rb file or by installing the gem that contains the beginning handler by using the chef_gem resource during a recipe within the chef-client cookbook.
45. Define a step by step process to update the chef cookbook?
Here is that the step-by-step process you would like to follow while updating the chef cookbook:
Step 1: attend the workstation to run the knife SSH
Step 2: Run both knife SSH and chef-client directly on the server
Step 3: you’ll consider and utilize the chef-client as a daemon to restart the service
46. What is a Vagrant in chef?
It helps Test Kitchen communicate with VirtualBox and configures things like available
47. What is chef-deploy plugin in chef and what is the purpose of using it?
It adds a gem that contains resources and providers for deploying Ruby web applications from recipes.
48. What are the different Knife plugins for cloud hosting platforms?
There are different knife plugins available for cloud hosting platforms:
knife eucalyptus, knife google, knife azure, knife bluebox, knife ec2, knife linode, knife openstack, and knife rackspace
49. What is Knife and what is the purpose of using Knife in chef?
It may be a command-line tool that gives an interface between an area chef-repo and therefore the Chef server. knife helps users to manage:
Nodes
Cookbooks and recipes
Roles, Environments, and Data Bags
Resources within various cloud environments
The installation of the chef-client onto nodes
Searching of indexed data on the Chef server
50. What is Handler DSL for a chef?
Use the Handler DSL to connect a callback to an occasion . The associated callback is executed, If the event occurs during the chef-client run. For example:
Sending email if a chef-client run fails
Sending a notification to talk application if an audit run fails
During a chef-client runs to StatsD it updates aggregating statistics about resources