Chef is a configuration-management tool that brings servers to a desired state using code written in a Ruby-based domain-specific language. Where Ansible favors simple YAML and pushes over SSH, Chef uses a richer programming model and a pull architecture: an agent on each node periodically fetches its policy from a central Chef Server and converges the machine to match. That model scales well to large, long-lived fleets.
Recipes, cookbooks, and resources
Configuration is expressed as resources - declarations like "this package is installed," "this service is running," "this file has these contents." Resources are grouped into recipes, and recipes plus supporting files into cookbooks, the unit of distribution. Because the DSL is real Ruby, recipes can include conditionals, loops, and computed values, which gives more expressive power than pure-data formats at the cost of a steeper learning curve.
package 'nginx' do
action :install
end
service 'nginx' do
action [:enable, :start]
end
Pull model and convergence
Each node runs the chef-client agent on a schedule. It pulls the node's assigned run-list from the Chef Server, evaluates the resources, and changes only what doesn't already match the declared state - the same idempotent convergence idea seen across the category. The pull model means nodes self-correct continuously and new nodes configure themselves on first boot, which suits autoscaling and large fleets better than pushing to every host.
Where it fits
Chef suits organizations managing large numbers of long-running servers that want strong, programmatic control over configuration and continuous enforcement. It carries more operational weight than Ansible - a Chef Server to run, agents to manage - so for smaller environments or quick automation, agentless tools are often simpler. Like other config tools, it pairs with a provisioning layer that creates the machines first.
Frequently asked questions
Is Chef push or pull? Pull - a chef-client agent on each node fetches its policy from the Chef Server on a schedule and converges the machine, so nodes self-correct continuously.
What are recipes and cookbooks? Recipes are ordered sets of resource declarations; cookbooks bundle recipes with their supporting files and are the unit you distribute and version.
Chef or Ansible? Chef's Ruby DSL and pull model give expressive, continuously enforced configuration for large fleets; Ansible's agentless YAML is simpler to adopt for smaller or ad-hoc needs.