{"id":350,"date":"2016-04-07T13:19:00","date_gmt":"2016-04-07T13:19:00","guid":{"rendered":"https:\/\/opstree.com\/blog\/\/2016\/04\/07\/chef-cookbooks-walls-of-chef-house\/"},"modified":"2026-01-08T12:35:42","modified_gmt":"2026-01-08T07:05:42","slug":"chef-cookbooks-walls-of-chef-house","status":"publish","type":"post","link":"https:\/\/opstree.com\/blog\/2016\/04\/07\/chef-cookbooks-walls-of-chef-house\/","title":{"rendered":"Chef-Cookbooks Walls of chef-house.."},"content":{"rendered":"<div dir=\"ltr\" style=\"text-align: left;\">\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 3pt; margin-top: 0; text-align: center;\"><span id=\"docs-internal-guid-1f76428b-efb1-8cca-8179-d8caa12f3892\"><img loading=\"lazy\" decoding=\"async\" style=\"-webkit-transform: rotate(0.00rad); border: none; transform: rotate(0.00rad);\" src=\"https:\/\/lh5.googleusercontent.com\/Pk8b-_guwV6MHUpuTznTyIryU8IMMvbl4cUJxnsNWt54E3yDn94u4IA0NXjKgGaKsLwC_jthhI2k6jfvhQkfYHe6Zx60-O3xbpV3xRt8qT0Dti-NE7nmED8okzAdWKcV93AuDFRO\" width=\"161\" height=\"328\" \/><img loading=\"lazy\" decoding=\"async\" style=\"-webkit-transform: rotate(1.22rad); border: none; transform: rotate(1.22rad);\" src=\"https:\/\/lh6.googleusercontent.com\/DLMhPMeAdIiHa9UbPBOyEdS_QMRXEy5iYApsV9L0nOt6DSJgMlS_owS9jXFcZ3M5Bea0-9W4le1ZD8oXtki3W1aPRMTmJ2viXO2roBDjwlUhmVtlOHOCOsxsryzFzHXsY-_IJ4H0\" width=\"161\" height=\"249\" \/><\/span><\/div>\n<h2 style=\"line-height: 1.38; margin-bottom: 6pt; margin-top: 18pt;\">Introduction<\/h2>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">As we work with cookbook in our previous blog, we are now aware about how chef really works and manage machines using cookbooks. Its crucial to understand the potential of thoughts and theories behind any concept. According to Albert Einstein,<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.2; margin-bottom: 0; margin-top: 0; text-align: center;\">\u201cA Theory Can Be Proved By Experiment;<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.2; margin-bottom: 0; margin-top: 0; text-align: center;\">But No Paths Leads from Experiments To The Birth Of Theory\u201d<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-align: center;\"><img loading=\"lazy\" decoding=\"async\" style=\"-webkit-transform: rotate(0.00rad); border: none; transform: rotate(0.00rad);\" src=\"https:\/\/lh3.googleusercontent.com\/jZuWi3J5UuixezO8Cc8VagV3_pxmJ-emRCa5ZlBoditfbEefqJGlfG53j6ZpOByHLBaydrgNyHa-c_JkY3qhJTklrB2V7QbOntl342XXl0E21Bl8qtt_1-_MNAbH1jrzWfdeNehD\" width=\"72\" height=\"113\" \/><\/div>\n<h2 style=\"line-height: 1.656; margin-bottom: 6pt; margin-top: 18pt; text-align: justify;\">Prerequisites<\/h2>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-align: justify;\">To follow this article you need a prior information about Git and Vagrant. This blog uses centos7 \u00a0\u00a0as platform. It needs basic understanding of chef and it&#8217;s cookbooks. To know about chef cookbooks follow our previous blogs of this series Chef Start here with ease.. .<\/div>\n<h2 style=\"line-height: 1.38; margin-bottom: 6pt; margin-top: 18pt;\">Get started<\/h2>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-align: justify;\">Clone our github repository and spin up a bare centos7 vagrant machine.<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-align: justify;\">$ git clone https:\/\/github.com\/OpsTree\/Chef.git<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-align: justify; text-indent: 36pt;\">Go to Chef\/centos\/chefCookbooksBackings directory.<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 36pt; margin-top: 0; text-align: justify; text-indent: 36pt;\">$ cd \u00a0Chef\/centos\/chefCookbooksBackings<\/div>\n<ul>\n<li style=\"line-height: 1.38; text-align: justify;\"><span style=\"font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;\">This directory have a Vagrantfile. Which can initiate a centos7 vagrant box.<\/span><\/li>\n<\/ul>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 36pt; margin-top: 0; text-align: justify; text-indent: 36pt;\">$ cat Vagrantfile<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 72pt; margin-top: 0; text-align: justify;\"><img loading=\"lazy\" decoding=\"async\" style=\"-webkit-transform: rotate(0.00rad); border: none; transform: rotate(0.00rad);\" src=\"https:\/\/lh3.googleusercontent.com\/vvc2cnQ3HScJxx_SRJGMcEnr-DzcKqIFYDlrqH5gny5_BKI4-szZcKXGw_e3h3PMt_xhtfgmqIOpHMBJ5DXW4MAYMWZU1MhLOetIxjLU72urhEG8PtPHIwXJEiZ1zYhSr4vT592G\" width=\"432\" height=\"108\" \/><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 72pt; margin-top: 0; text-align: justify;\">This file update and install some basic tools in your vagrant machine using vagrant shell provisioning.<\/div>\n<ul>\n<li style=\"line-height: 1.38; text-align: justify;\"><span style=\"font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;\">Download Chefdk using below available command<\/span><\/li>\n<\/ul>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-align: justify;\">$ cd Chef\/centos\/chefResources<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 36pt; margin-top: 0;\">$ wget https:\/\/opscode-omnibus-packages.s3.amazonaws.com\/el\/7\/x86_64\/chefdk-0.11.2-1.el7.x86_64.rpm<\/div>\n<ul>\n<li style=\"line-height: 1.38; text-align: justify;\"><span style=\"font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;\">This directory also includes a knife.rb file which sets the cookbook folder path and default editor for the virtual machine.<\/span><\/li>\n<li style=\"line-height: 1.38; text-align: justify;\"><span style=\"font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;\">Launch new vagrant machine and login into it via ssh.<\/span><\/li>\n<\/ul>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 36pt; margin-top: 0; text-align: justify; text-indent: 36pt;\">$ vagrant up<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 36pt; margin-top: 0; text-align: justify; text-indent: 36pt;\">$ vagrant ssh<\/div>\n<h2 style=\"line-height: 1.38; margin-bottom: 6pt; margin-top: 18pt;\">Cookbooks<\/h2>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">As per chef\u2019s official document \u201cA cookbook is the fundamental unit of configuration and policy distribution. A cookbook defines a scenario and contains everything that is required to support that scenario.\u201d<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">Chef cookbooks are the first configurational unit of chef. These are the like a box which contains all the basic tools for the comfortable management of any machine. It consist of<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\"><\/div>\n<ul>\n<li style=\"line-height: 1.38;\"><span style=\"background-color: transparent; color: black; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;\">Recipes <\/span><\/li>\n<li style=\"line-height: 1.38;\"><span style=\"background-color: transparent; color: black; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;\">Attribute <\/span><\/li>\n<li style=\"line-height: 1.38;\"><span style=\"background-color: transparent; color: black; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;\">File <\/span><\/li>\n<li style=\"line-height: 1.38;\"><span style=\"background-color: transparent; color: black; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;\">Templates<\/span><\/li>\n<li style=\"line-height: 1.38;\"><span style=\"background-color: transparent; color: black; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;\">libraries, definitions, and custom resources <\/span><\/li>\n<\/ul>\n<h2 style=\"line-height: 1.38; margin-bottom: 6pt; margin-top: 18pt;\">Directory Structure<\/h2>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">The directory structure of any cookbook \u00a0is very straight and simple. We took an example cookbook which we are going to create in our next section, so have a look on what it looks like on completion.<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">$ tree cookbooks\/nginxVhostExtended\/<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\"><strong><img loading=\"lazy\" decoding=\"async\" style=\"-webkit-transform: rotate(0.00rad); border: none; transform: rotate(0.00rad);\" src=\"https:\/\/lh6.googleusercontent.com\/c6dRa5FBnHmxA_7Z_C-j8jkNrsfI_DGOnn9H-xOT10Tn3mEuTyA11U9zWADlhcC0nMOLqtkG7TVLwsDqY5AneOdsHFAhsIWZw7RhNKKm-se5RDkwHNnVJTu_BvFNcKZUZo4AoutD\" width=\"343\" height=\"386\" \/><\/strong><\/div>\n<ul>\n<li style=\"line-height: 1.38;\"><strong>Attributes<\/strong><\/li>\n<\/ul>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 36pt; margin-top: 0;\">This directory contains all files which holds the values of the variables used in the cookbook.<\/div>\n<ul>\n<li style=\"line-height: 1.38;\"><strong>Definitions<\/strong><\/li>\n<\/ul>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 36pt; margin-top: 0;\">This directory contains definition of new created resources.<\/div>\n<ul>\n<li style=\"line-height: 1.38;\"><strong>Files<\/strong><\/li>\n<\/ul>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 36pt; margin-top: 0;\">This folder holds static file used in cookbook.<\/div>\n<ul>\n<li style=\"line-height: 1.38;\"><strong>Libraries<\/strong><\/li>\n<\/ul>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 36pt; margin-top: 0;\">Allows users to use extended ruby libraries for new class declarations.<\/div>\n<ul>\n<li style=\"line-height: 1.38;\"><strong>Providers<\/strong><\/li>\n<\/ul>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 36pt; margin-top: 0;\">This will contains actions which will be taken on using a custom resource declared in resources directory.<\/div>\n<ul>\n<li style=\"line-height: 1.38;\"><strong>Recipes<\/strong><\/li>\n<\/ul>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 36pt; margin-top: 0;\">This directory holds all the the recipes of any cookbook. These are the main execution part of the cookbook.<\/div>\n<ul>\n<li style=\"line-height: 1.38;\"><strong>Resources<\/strong><\/li>\n<\/ul>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-indent: 36pt;\">Here custom resources are defined.<\/div>\n<ul>\n<li style=\"line-height: 1.38;\"><strong>Templates<\/strong><\/li>\n<\/ul>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-indent: 36pt;\">This directory provide templates for the dynamic solutions of a cookbook.<\/div>\n<ul>\n<li style=\"line-height: 1.38;\"><strong>Metadata.rb<\/strong><\/li>\n<\/ul>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 36pt; margin-top: 0;\">This file ensures that every cookbook is deployed correctly. Also holds the general information for any cookbook as like author copyright and version.<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\"><\/div>\n<h2 style=\"line-height: 1.38; margin-bottom: 6pt; margin-top: 18pt;\">Try with a complex one<\/h2>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">This time we introduce some extended concepts of chef cookbooks in our example cookbook. As in our previous blogs problem statement remain same to install nginx and setup nginx vhost with our cookbook. But this time we tried to be more efficient so that we can create multiple vhost in a single chef-client run.<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">First create a dedicated directory for our cookbooks. As in knife.rb file it will be created by following command.<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">$ mkdir \/vagrant\/cookbooks<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">Chef manage its cookbooks using a version control system so next we initialize and also make our first commit for \/vagrant\/cookbooks directory. Provide your name and email for git configuration.<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\"><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-indent: 36pt;\">$ mkdir \/vagrant\/cookbooks<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-indent: 36pt;\">$ cd \/vagrant\/cookbooks<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-indent: 36pt;\">$ git init<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-indent: 36pt;\">$ git add .<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-indent: 36pt;\">$ git config &#8211;global user.email &#8220;you@example.com&#8221;<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-indent: 36pt;\">$ git config &#8211;global user.name &#8220;Your Name&#8221;<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-indent: 36pt;\">$ git commit -m &#8220;Initial Commit&#8221;<\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">Now you are ready to start with the creation of your next cookbook.<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">$ knife cookbook create nginxVhostExtended -C &#8220;Saurabh Vajpayee&#8221; -m &#8220;myemail@email.com&#8221; -I nginxv1 -r md<\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\"><span id=\"docs-internal-guid-1f76428b-eff9-0e9f-d955-49ac975a1725\"><img loading=\"lazy\" decoding=\"async\" style=\"-webkit-transform: rotate(0.00rad); border: none; transform: rotate(0.00rad);\" src=\"https:\/\/lh5.googleusercontent.com\/1kVmW9VXSeNifhVh8O9DT1ZYqDuVfxlL6GtBHU6_mfrOso2Umea9e93qQbOmziB87vJu2uYd3riY9QLmFHiGLubbt-8by5-jMd6S1q7KNPzoUgNvhVXX8SgFVOVtmrFMK_wUtYAj\" width=\"562\" height=\"117\" \/><\/span><\/div>\n<h3 style=\"line-height: 1.38; margin-bottom: 4pt; margin-top: 16pt;\">Create default recipe<\/h3>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">Create a default recipe with following content to install \u00a0nginx.<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">$ vim \/vagrant\/cookbooks\/nginxVhostExtended\/recipes\/default.rb<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">include_recipe &#8216;yum-epel&#8217;<\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">package node[&#8216;nginx&#8217;][&#8216;packages&#8217;] do<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">action :install<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">end<\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">service &#8216;iptables&#8217; do<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">action :stop<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">end<\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">service &#8216;nginx&#8217; do<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">action [:start, :enable]<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">end<\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">This time we also \u00a0included another recipe \u201cyum-epel\u201d in our default recipe.<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">Generate another recipe to configure vhost with following content.<\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">$ chef generate recipe \/vagrant\/cookbooks\/nginxVhostExtended\/ vhost<\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">$ vim \/vagrant\/cookbooks\/nginxVhostExtended\/recipes\/vhost.rb<\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">include_recipe &#8216;nginxVhostExtended&#8217;<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">node[&#8216;nginx&#8217;][&#8216;vhost&#8217;].each do |name, attrs|<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0nginxVhostExtended_vhost &#8216;name&#8217; do<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0port attrs[&#8216;port&#8217;]<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0webroot attrs[&#8216;webroot&#8217;]<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0servername attrs[&#8216;servername&#8217;]<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0conffile attrs[&#8216;conffile&#8217;]<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0end<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">end<\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">service &#8216;nginx&#8217; do<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">action :restart<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">end<\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">This recipe contains a custom resource \u00a0\u201cnginxVhostExtended_vhost\u201d which has its definition and attribute declaration under provider and resource directory.<\/div>\n<h3 style=\"line-height: 1.38; margin-bottom: 4pt; margin-top: 16pt;\">Generate attribute file<\/h3>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">Generate default attribute file with following defined variables.<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">$ chef generate attribute \/vagrant\/cookbooks\/nginxVhostExtended\/<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">default<\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">$ vim \/vagrant\/cookbooks\/nginxVhostExtended\/attributes\/default.rb<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">default[&#8216;nginx&#8217;][&#8216;packages&#8217;] = &#8220;nginx&#8221;<\/div>\n<\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\" style=\"text-align: left;\">\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">default[&#8216;nginx&#8217;][&#8216;port&#8217;] = 80<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">default[&#8216;nginx&#8217;][&#8216;webroot&#8217;] = &#8220;\/usr\/share\/nginx\/blog&#8221;<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">default[&#8216;nginx&#8217;][&#8216;servername&#8217;] = &#8220;opstree.com\/blog\/&#8221;<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">default[&#8216;nginx&#8217;][&#8216;conffile&#8217;] = &#8220;opstree.com\/blog\/.conf&#8221;<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">default[&#8216;nginx&#8217;][&#8216;vhost&#8217;] = {}<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">This attribute file holds default values for variable used in templates<\/div>\n<h3 style=\"line-height: 1.38; margin-bottom: 4pt; margin-top: 16pt;\">Generate template files<\/h3>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">Generate two templates for conf and index.html files. Use following content to paste.<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">$ chef generate template \/vagrant\/cookbooks\/nginxVhostExtended\/ chefmanagedconf.conf<\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">$ chef generate template \/vagrant\/cookbooks\/nginxVhostExtended\/ index.html<\/div>\n<\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\" style=\"text-align: left;\">\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">$ vim \/vagrant\/cookbooks\/nginxVhostExtended\/templates\/default\/chefmanagedconf.conf.erb<\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">server {<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0listen \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0;<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0server_name \u00a0;<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0location \/ {<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0root \u00a0\u00a0;<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0index \u00a0index.html index.htm;<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0}<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0error_page \u00a0404 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\/404.html;<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0location = \/404.html {<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0root \u00a0\u00a0;<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0}<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0# redirect server error pages to the static page \/50x.html<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0error_page \u00a0\u00a0500 502 503 504 \u00a0\/50x.html;<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0location = \/50x.html {<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0root \u00a0\u00a0;<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0}<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">$ vim \/vagrant\/cookbooks\/nginxVhostExtended\/templates\/default\/index.html.erb<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\n<p><i>&lt;!DOCTYPE html PUBLIC &#8220;-\/\/W3C\/\/DTD XHTML 1.1\/\/EN&#8221; &#8220;http:\/\/www.w3.org\/TR\/xhtml11\/DTD\/xhtml11.dtd&#8221;&gt;<\/i><i>&lt;html xmlns=&#8221;http:\/\/www.w3.org\/1999\/xhtml&#8221; xml:lang=&#8221;en&#8221;&gt;<\/i><\/p>\n<p><i> \u00a0\u00a0\u00a0&lt;head&gt;<\/i><\/p>\n<p><i> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;title&gt;Test Page for the Opstree Server &lt;\/title&gt;<\/i><\/p>\n<p><i> \u00a0\u00a0\u00a0&lt;\/head&gt;<\/i><\/p>\n<p><i> \u00a0\u00a0\u00a0&lt;body&gt;<\/i><\/p>\n<p><i> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;h1&gt;Welcome to &lt;strong&gt; &lt;%= @servername %&gt; &lt;\/strong&gt;&lt;\/h1&gt;<\/i><\/p>\n<p><i> \u00a0\u00a0\u00a0&lt;\/body&gt;<\/i><\/p>\n<p><i>&lt;\/html&gt;<\/i><\/p>\n<\/div>\n<h3 style=\"line-height: 1.38; margin-bottom: 4pt; margin-top: 16pt;\">Generate a lwrp<\/h3>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">Generate a lwrp (light weight resource provider ) using knife command and use following content.<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">$ chef generate lwrp \/vagrant\/cookbooks\/nginxVhostExtended\/ vhost<\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">$ vim \u00a0\/vagrant\/cookbooks\/nginxVhostExtended\/resources\/vhost.rb<\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">actions :configure<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">default_action :configure<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">attribute :name,<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0kind_of: String,<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0required: true,<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0name_attribute: true<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">attribute :port,<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0kind_of: Fixnum<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">attribute :webroot,<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0kind_of: String<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">attribute :servername,<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0kind_of: String<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">attribute :conffile,<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0kind_of: String<\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">$ vim \/vagrant\/cookbooks\/nginxVhostExtended\/providers\/vhost.rb<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">action :configure do<\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">[:webroot, :conffile, :servername, :port].each do |attr|<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0unless new_resource.instance_variable_get(&#8220;@#{attr}&#8221;)<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0new_resource.instance_variable_set(&#8220;@#{attr}&#8221;, node[&#8216;nginx&#8217;][attr])<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0end<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0\u00a0end<\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">[:webroot].each do |attr|<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0directory new_resource.instance_variable_get(&#8220;@#{attr}&#8221;) do<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0mode &#8216;0755&#8217;<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0recursive true<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0end<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0template &#8220;#{new_resource.webroot}\/index.html&#8221; do<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0source &#8216;index.html.erb&#8217;<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0variables(<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0servername: new_resource.servername<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0)<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0end<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0\u00a0end<\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">template &#8220;\/etc\/nginx\/conf.d\/#{new_resource.conffile}&#8221; do<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0source &#8216;chefmanagedconf.conf.erb&#8217;<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0variables(<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0port: new_resource.port,<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0servername: new_resource.servername,<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0webroot: new_resource.webroot<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0)<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">end<\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">line = &#8220;127.0.0.1 #{new_resource.servername}&#8221;<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">file = Chef::Util::FileEdit.new(&#8216;\/etc\/hosts&#8217;)<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">file.insert_line_if_no_match(\/#{line}\/, line)<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">file.write_file<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">end<\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">Now our cookbook is ready but as we define in yum-epel dependency in our default \u00a0cookbook so in next steps we install this cookbook from chef repository.<\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">$ git status<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">$ git add .<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">$ git commit -m &#8220;nginxVhostExtended cookbook added&#8221;<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">$ knife cookbook site install yum-epel<\/div>\n<h2 style=\"line-height: 1.38; margin-bottom: 6pt; margin-top: 18pt;\">Go for it<\/h2>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">Lets run our cookbook to just install nginx using default recipe. Create \u00a0\u00a0installrunlist.json with following content.<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">$ vim installrunlist.json<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">{<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">&#8220;run_list&#8221;: [<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">&#8220;recipe[yum-epel]&#8221;,<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">&#8220;recipe[nginxVhostExtended]&#8221;<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">]<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">}<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">$ chef-client \u00a0&#8211;local-mode -j \/vagrant\/runlist.json<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">This will install your nginx server only.<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">Now we create a runlist file for configuring vhost.<\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">$ vim vhostrunlist.json<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">{<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0&#8220;nginx&#8221;: {<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;vhost&#8221;: {<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;vhost1&#8221;: {<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;webroot&#8221;: &#8220;\/usr\/share\/nginx\/chef&#8221;,<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;servername&#8221;: &#8220;chef.opstree.com&#8221;,<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;conffile&#8221;: &#8220;chef.opstree.com.conf&#8221;<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0},<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;vhost2&#8221;: {<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;webroot&#8221;: &#8220;\/usr\/share\/nginx\/blog&#8221;,<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;servername&#8221;: &#8220;opstree.com\/blog\/&#8221;,<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;conffile&#8221;: &#8220;opstree.com\/blog\/.conf&#8221;<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0},<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0&#8220;run_list&#8221;: [<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">&#8220;recipe[yum-epel]&#8221;,<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">&#8220;recipe[nginxVhostExtended]&#8221;,<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8220;recipe[nginxVhostExtended::vhost]&#8221;<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0]<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">}<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">$ chef-client \u00a0&#8211;local-mode -j \/vagrant\/vhostrunlist.json<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">This will run and configure two vhost opstree.com\/blog\/ and chef.opstree.com on your machine. Now with our new cookbook we are able to create and configure multiple vhost in single run.<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">We took some extended concepts of chef cookbooks. Chef and it&#8217;s cookbooks are beyond away from all limits. This is just a drop from the ocean but every drop in the ocean counts\u2026<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-align: center;\">\u201cYou need an entire life just to know about tomatoes. Ferran Adria\u201d<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">Don&#8217;t be panic by messing up with a lot of things and start playing with your own written cookbooks.<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-align: center;\"><img loading=\"lazy\" decoding=\"async\" style=\"-webkit-transform: rotate(0.00rad); border: none; transform: rotate(0.00rad);\" src=\"https:\/\/lh4.googleusercontent.com\/2HdoB_KUjNMQgFdaiHudOl8Ns8C0qbQSHOm2PysWnnHGbgcWeipz2n0GJlDKe3Bb5e_2DkLTvHXyhuh4en61cVEPwbyR1IE-RH-qN3nwSFGfco4rQtA2EvCZqYVIcOADRLNNTIhW\" width=\"282\" height=\"121\" \/><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Introduction As we work with cookbook in our previous blog, we are now aware about how chef really works and manage machines using cookbooks. Its crucial to understand the potential of thoughts and theories behind any concept. According to Albert Einstein, \u201cA Theory Can Be Proved By Experiment; But No Paths Leads from Experiments To &hellip; <a href=\"https:\/\/opstree.com\/blog\/2016\/04\/07\/chef-cookbooks-walls-of-chef-house\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Chef-Cookbooks Walls of chef-house..&#8221;<\/span><\/a><\/p>\n","protected":false},"author":72934568,"featured_media":29900,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[225871,28070474],"tags":[768739297,768739308,676319247,101807,28382],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/opstree.com\/blog\/wp-content\/uploads\/2025\/11\/DevSecOps-1.jpg","jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pfDBOm-5E","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts\/350"}],"collection":[{"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/users\/72934568"}],"replies":[{"embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/comments?post=350"}],"version-history":[{"count":7,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts\/350\/revisions"}],"predecessor-version":[{"id":30308,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts\/350\/revisions\/30308"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/media\/29900"}],"wp:attachment":[{"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/media?parent=350"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/categories?post=350"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/tags?post=350"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}