Chef is the configuration management tool written in ruby. Chef can be used to automate most of the infrastructure related operations and helps to achieve you the desired state of your infrastructure and act as an enforcer of the state so that your environment always remain in the state you configured.
Chef takes the infrastructure as an code and manages it accordingly. It can be used for managing cloud based environment, VM based environment as well as physical servers.
For understanding the chef , need to have understanding of the following terms:-
1. Resource:- A resource represent a piece of the system and its desired state. For e.g.
- A package that should be installed
- A service that should be running
- A file that should be generated
- A cron job that should be configured
- A user that should be managed and more
Resources are the fundamental building blocks of the chef configurations. you identify the resources and there states. Achieving the desired states of the resources in all the servers in an environment is our objective.
2. Recipe:- Recipes can be considered as the configuration files that describes your resources and their desired state. Depending on the kind of requirement a Recipe can perform various functions
- Install and configure software components.
- Manage files
- Deploy applications
- Execute other recipes and more
3. Node :- The node are the servers in an environment. Depending on the kind of environment you can have one or many servers serving some particular functions. Like webservers behind a firewall. The chef-client runs on each node which can
- Gather the current system configuration of the node
- Download the desired system configuration policies from the chef server for that node
- Configures the node such that it adhere to those policies.
4. Run list : The Run list comprises of the ordered collection of the policies which the node should follow. Chef-client obtains the run list from thee chef server and ensures the node complies with the policy in the run-list.
This helps in achieving the policy enforcement and helps to keep the infrastructure nodes in sync.
5. Search:- Search is a unique function in the chef and can be used to search the nodes with the roles and find the topology data. Using search you can find the ip-address, hostnames, FQDNS etc. Consider a situation where you need to add all the webservers under your load balancer. Instead of describing each webserver ip individually you can get it from search. Now when you configure autoscaling or building the infrastructure in cloud this can be automated using the search function. You can also add node on the go while autoscaling using the search function.