Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

Chef Tutorials: What is Chef Solo with example programs

chef-solo

How to deploy chef cookbooks without chef server? – Answer is – Chef Solo

What is Chef Solo?

chef-solo is a command that executes Chef Infra Client in a way that does not require the Chef Infra Server to converge cookbooks. chef-solo uses Chef Infra Client’s Chef local mode, and does not support the following functionality present in Chef Infra Client / server configurations:

Centralized distribution of cookbooks
A centralized API that interacts with and integrates infrastructure components
Authentication or authorization

How Chef solo Works?

chef-solo supports two locations from which cookbooks can be run:

  • A local directory.
  • A URL at which a tar.gz archive is located.

Before running Chef-Solo on the local machine, one needs to install the following two files on the local machine.

  • Solo.rb − This file tells Chef about where to find cookbooks, roles, and data bags.
  • Node.json − This file sets the run list and any node-specific attribute, if required.

A small chef-solo example



 
Install chef
============
> curl -L https://www.opscode.com/chef/install.sh | bash
 
Check
=====
> chef-solo -v
 
Setup chef repository
=====================
> wget http://github.com/opscode/chef-repo/tarball/master
 
> tar zxvf master
 
> mv opscode-chef-repo-f9d4b0c/ chef-repo
 
>ls chef-repo/
 
Create .chef directory inside chef-repo
=======================================
> mkdir chef-repo/.chef
 
Setup a local cookbook path
===========================
 
> vi chef-repo/.chef/knife.rb
cookbook_path [ ‘/root/chef-repo/cookbooks’ ]
 
Create your first cookbook
==========================
 
> knife cookbook create ntp
 
Writing your first recipe
=========================
> vi chef-repo/cookbooks/ntp/recipes/default.rb
 
package ‘ntp’
 
Now configure your server using chef-solo
=========================================
> vi chef-repo/solo.rb
 
file_cache_path “/root/chef-solo”
cookbook_path “/root/chef-repo/cookbooks”
 
> vi node.json
 
{
“run_list”: [ “recipe[ntp]” ]
}
 
Ensure ntp is not installed
===========================
> yum remove -y ntp
 
Use chef-solo to configure your server
=====================================
 
> chef-solo -c chef-repo/solo.rb -j chef-repo/node.json
 
Confirm ntp is installed
========================
> yum info ntp
 

Reference

  • https://docs.chef.io/chef_solo/
  • https://www.devopsschool.com/blog/difference-between-chef-infra-server-vs-chef-zero-vs-chef-solo/
  • https://docs.chef.io/ctl_chef_solo/
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments

Certification Courses

DevOpsSchool has introduced a series of professional certification courses designed to enhance your skills and expertise in cutting-edge technologies and methodologies. Whether you are aiming to excel in development, security, or operations, these certifications provide a comprehensive learning experience. Explore the following programs:

DevOps Certification, SRE Certification, and DevSecOps Certification by DevOpsSchool

Explore our DevOps Certification, SRE Certification, and DevSecOps Certification programs at DevOpsSchool. Gain the expertise needed to excel in your career with hands-on training and globally recognized certifications.

0
Would love your thoughts, please comment.x
()
x