{"id":454,"date":"2022-11-30T07:01:32","date_gmt":"2022-11-30T07:01:32","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/2015\/11\/10\/chef-solo\/"},"modified":"2022-12-23T05:44:56","modified_gmt":"2022-12-23T05:44:56","slug":"chef-solo","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/chef-solo\/","title":{"rendered":"Chef Tutorials: What is Chef Solo with example programs"},"content":{"rendered":"\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n<cite>How to deploy chef cookbooks without chef server?  &#8211; Answer is &#8211; Chef Solo<\/cite><\/blockquote>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">What is Chef Solo?<\/h2>\n\n\n\n<p>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\u2019s Chef local mode, and does not support the following functionality present in Chef Infra Client \/ server configurations:<\/p>\n\n\n\n<p>Centralized distribution of cookbooks<br>A centralized API that interacts with and integrates infrastructure components<br>Authentication or authorization<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How Chef solo Works?<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"325\" height=\"455\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/11\/image-54.png\" alt=\"\" class=\"wp-image-32052\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/11\/image-54.png 325w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/11\/image-54-214x300.png 214w\" sizes=\"auto, (max-width: 325px) 100vw, 325px\" \/><\/figure>\n\n\n\n<p>chef-solo supports two locations from which cookbooks can be run:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A local directory.<\/li>\n\n\n\n<li>A URL at which a tar.gz archive is located.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>Before running Chef-Solo on the local machine, one needs to install the following two files on the local machine.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Solo.rb<\/strong>&nbsp;\u2212 This file tells Chef about where to find cookbooks, roles, and data bags.<\/li>\n\n\n\n<li><strong>Node.json<\/strong>&nbsp;\u2212 This file sets the run list and any node-specific attribute, if required.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">A small chef-solo example<\/h2>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<script src=\"https:\/\/gist.github.com\/devops-school\/3ed63bed4a22ed25b3f93943a59b7af9.js\"><\/script>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<div>\u00a0<\/div>\n<div><strong>Install chef<\/strong><\/div>\n<div>============<\/div>\n<div>&gt; curl -L https:\/\/www.opscode.com\/chef\/install.sh | bash<\/div>\n<div>\u00a0<\/div>\n<div><strong>Check<\/strong><\/div>\n<div>=====<\/div>\n<div>&gt; chef-solo -v<\/div>\n<div>\u00a0<\/div>\n<div>Setup chef repository<\/div>\n<div>=====================<\/div>\n<div>&gt; wget http:\/\/github.com\/opscode\/chef-repo\/tarball\/master<\/div>\n<div>\u00a0<\/div>\n<div>&gt; tar zxvf master<\/div>\n<div>\u00a0<\/div>\n<div>&gt; mv opscode-chef-repo-f9d4b0c\/ chef-repo<\/div>\n<div>\u00a0<\/div>\n<div>&gt;ls chef-repo\/<\/div>\n<div>\u00a0<\/div>\n<div><strong>Create .chef directory inside chef-repo<\/strong><\/div>\n<div>=======================================<\/div>\n<div>&gt; mkdir chef-repo\/.chef<\/div>\n<div>\u00a0<\/div>\n<div>Setup a local cookbook path<\/div>\n<div>===========================<\/div>\n<div>\u00a0<\/div>\n<div>&gt; vi chef-repo\/.chef\/knife.rb<\/div>\n<div>cookbook_path [ &#8216;\/root\/chef-repo\/cookbooks&#8217; ]<\/div>\n<div>\u00a0<\/div>\n<div><strong>Create your first cookbook<\/strong><\/div>\n<div>==========================<\/div>\n<div>\u00a0<\/div>\n<div>&gt; knife cookbook create ntp<\/div>\n<div>\u00a0<\/div>\n<div><strong>Writing your first recipe<\/strong><\/div>\n<div>=========================<\/div>\n<div>&gt; vi chef-repo\/cookbooks\/ntp\/recipes\/default.rb<\/div>\n<div>\u00a0<\/div>\n<div>package &#8216;ntp&#8217;<\/div>\n<div>\u00a0<\/div>\n<div><strong>Now configure your server using chef-solo<\/strong><\/div>\n<div>=========================================<\/div>\n<div>&gt; vi chef-repo\/solo.rb<\/div>\n<div>\u00a0<\/div>\n<div>file_cache_path &#8220;\/root\/chef-solo&#8221;<\/div>\n<div>cookbook_path &#8220;\/root\/chef-repo\/cookbooks&#8221;<\/div>\n<div>\u00a0<\/div>\n<div>&gt; vi node.json<\/div>\n<div>\u00a0<\/div>\n<div>{<\/div>\n<div>&#8220;run_list&#8221;: [ &#8220;recipe[ntp]&#8221; ]<\/div>\n<div>}<\/div>\n<div>\u00a0<\/div>\n<div><strong>Ensure ntp is not installed<\/strong><\/div>\n<div>===========================<\/div>\n<div>&gt; yum remove -y ntp<\/div>\n<div>\u00a0<\/div>\n<div><strong>Use chef-solo to configure your server<\/strong><\/div>\n<div>=====================================<\/div>\n<div>\u00a0<\/div>\n<div>&gt; chef-solo -c chef-repo\/solo.rb -j chef-repo\/node.json<\/div>\n<div>\u00a0<\/div>\n<div><strong>Confirm ntp is installed<\/strong><\/div>\n<div>========================<\/div>\n<div>&gt; yum info ntp<\/div>\n<div>\u00a0<\/div>\n\n\n<h2 class=\"wp-block-heading\">Reference<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>https:\/\/docs.chef.io\/chef_solo\/<\/li>\n\n\n\n<li>https:\/\/www.devopsschool.com\/blog\/difference-between-chef-infra-server-vs-chef-zero-vs-chef-solo\/<\/li>\n\n\n\n<li>https:\/\/docs.chef.io\/ctl_chef_solo\/<\/li>\n<\/ul>\n\n\n<div class=\"epyt-gallery\" data-currpage=\"1\" id=\"epyt_gallery_52797\"><iframe loading=\"lazy\"  id=\"_ytid_94753\"  width=\"760\" height=\"427\"  data-origwidth=\"760\" data-origheight=\"427\" src=\"https:\/\/www.youtube.com\/embed\/?enablejsapi=1&#038;autoplay=0&#038;cc_load_policy=0&#038;cc_lang_pref=&#038;iv_load_policy=1&#038;loop=0&#038;rel=1&#038;fs=1&#038;playsinline=0&#038;autohide=2&#038;theme=dark&#038;color=red&#038;controls=1&#038;disablekb=0&#038;\" class=\"__youtube_prefs__  no-lazyload\" title=\"YouTube player\"  data-epytgalleryid=\"epyt_gallery_52797\"  allow=\"fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen data-no-lazy=\"1\" data-skipgform_ajax_framebjll=\"\"><\/iframe><div class=\"epyt-gallery-list\"><div>Sorry, there was a YouTube error.<\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>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&#8230; <\/p>\n","protected":false},"author":1,"featured_media":3101,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[88],"tags":[407,943,1396,1398,1395,1397,942],"class_list":["post-454","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-chef","tag-chef","tag-chef-solo","tag-chef-solo-guide","tag-chef-solo-setup","tag-chef-solo-tutorial","tag-provision","tag-solo"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/454","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=454"}],"version-history":[{"count":14,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/454\/revisions"}],"predecessor-version":[{"id":32061,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/454\/revisions\/32061"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/3101"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=454"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=454"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=454"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}