{"id":363,"date":"2016-03-10T08:57:00","date_gmt":"2016-03-10T08:57:00","guid":{"rendered":""},"modified":"2025-11-27T17:27:16","modified_gmt":"2025-11-27T11:57:16","slug":"chef-resources-easy-as-pie","status":"publish","type":"post","link":"https:\/\/opstree.com\/blog\/2016\/03\/10\/chef-resources-easy-as-pie\/","title":{"rendered":"Chef-Resources Easy as pie.."},"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;\"><img loading=\"lazy\" decoding=\"async\" style=\"border: none; font-family: arial; font-size: 8.8px; line-height: 1.38; transform: rotate(0rad); white-space: pre-wrap;\" src=\"https:\/\/lh3.googleusercontent.com\/kZ0SJDWAPwSPohOLfj-UR19uTtIhx27DzKdzjgIpQUkZ9SZKzW-Zih03Ebeb9WKWaaNKa6K8AQKwA1wZ8-jlksk7dfsoWNjfAg-bJ9UpHjdHofoiygqZOWSK4BOj_9IRUvG3Y6wK\" width=\"535\" height=\"390\" \/><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 3pt; margin-top: 0; text-align: center;\"><b style=\"font-weight: normal;\">\u00a0<\/b><\/div>\n<h2 style=\"line-height: 1.38; margin-bottom: 6pt; margin-top: 18pt; text-align: justify;\">Introduction<\/h2>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-align: justify;\">Resources are the basal element of chef\u2019s heap. In all the functioning of chef, resources are in crux. These are a very first statement of any chef recipe or cookbook. In this blog we only intensify on the practical approach of \u00a0working with resources. This article will help you to compose a primitive awareness towards the execution of chef.<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 3pt; margin-top: 0; text-align: center;\"><b style=\"font-weight: normal;\">\u00a0<\/b><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-align: center;\">\u201cPie Makes Everybody Happy!! L. H. Anderson\u201d<\/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.<\/div>\n<h2 style=\"line-height: 1.38; margin-bottom: 6pt; margin-top: 18pt; text-align: justify;\">Getting Started<\/h2>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-align: justify;\">Sooner, probably but it necessitous to talk about chef installation. For this and some of next blogs we use chef-standalone mode. Chef-standalone mode provides a basic learning environment for beginners. Chef-standalone mode allow you to configure a machine directly.<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-align: justify;\">Chef cater a complete \u00a0package labeled as Chefdk (Chef Development Kit ). It encloses all the essential thing you need to start with chef.<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 3pt; margin-top: 0; text-align: center;\"><b style=\"font-weight: normal;\">\u00a0<\/b><\/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\/DtCxfyWeeVmENgNmOhgxs7olz0I1Tlf8ETLkXRsTCm1mF2zX0gXw7RVk3xOzlDRPlv9yh0yFVfTdSssYWH54sIZTrwXW3-px_xHx91v2GS1JGEwEOGw37JKihQOiXDEjuUWmkkZq\" width=\"240\" height=\"301\" \/><\/div>\n<h2 style=\"line-height: 1.38; margin-bottom: 6pt; margin-top: 18pt;\">Install Chefdk<\/h2>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">Clone our git repo and spin up a vagrant box with it.<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 3pt; margin-top: 0; text-align: center;\"><b style=\"font-weight: normal;\">\u00a0<\/b><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-align: justify;\">$ git clone git@github.com:OpsTree\/Chef.git<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 3pt; margin-top: 0; text-align: center;\"><b style=\"font-weight: normal;\">\u00a0<\/b><\/div>\n<ul style=\"margin-bottom: 0; margin-top: 0;\">\n<li style=\"background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666667px; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: disc; text-decoration: none; vertical-align: baseline;\">\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-align: justify;\">Go to chefResources directory. This directory contains a Vagrantfile, which can launch a centos7 vagrant machine with Chefdk and other essential tools installed.<\/div>\n<\/li>\n<\/ul>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-align: justify;\"><\/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;\">$ cat Vagrantfile<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 3pt; margin-top: 0; text-align: center;\"><b style=\"font-weight: normal;\">\u00a0<\/b><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 72pt; margin-top: 0; text-align: justify;\">\n<div class=\"separator\" style=\"clear: both; text-align: left;\"><a style=\"margin-left: 1em; margin-right: 1em;\" href=\"https:\/\/opstree.com\/blog\/\/wp-content\/uploads\/2016\/03\/daee0-vagrantfile.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/opstree.com\/blog\/\/wp-content\/uploads\/2016\/03\/daee0-vagrantfile.png?w=300\" width=\"400\" height=\"81\" border=\"0\" \/><\/a><\/div>\n<\/div>\n<ul style=\"margin-bottom: 0; margin-top: 0;\">\n<li style=\"background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666667px; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: disc; text-decoration: none; vertical-align: baseline;\">\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-align: justify;\">Launch a new vagrant machine and login into it.<\/div>\n<\/li>\n<\/ul>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 36pt; margin-top: 0; text-align: justify;\"><\/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 up<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 3pt; margin-top: 0; text-align: center;\"><b style=\"font-weight: normal;\">\u00a0<\/b><\/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<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 3pt; margin-top: 0; text-align: center;\"><b style=\"font-weight: normal;\">\u00a0<\/b><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-align: justify;\">Your learning environment is ready. Let&#8217;s start with chef resources.<\/div>\n<h2 style=\"line-height: 1.38; margin-bottom: 6pt; margin-top: 18pt; text-align: justify;\">Resource<\/h2>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-align: justify;\">Lets took our first resource package. As in our blog series we go through a common problem statement of installing nginx and then setup nginx vhost. This time we are going to do this with chef resources only. Chef resource have basic two parts properties and action. We will discuss both of these in our next article. Till then we start playing with \u00a0chef resources.<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 3pt; margin-top: 0; text-align: center;\"><b style=\"font-weight: normal;\">\u00a0<\/b><\/div>\n<ul style=\"margin-bottom: 0; margin-top: 0;\">\n<li style=\"background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666667px; font-style: normal; font-variant: normal; font-weight: bold; list-style-type: disc; text-decoration: none; vertical-align: baseline;\">\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">Package resource<\/div>\n<\/li>\n<\/ul>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 36pt; margin-top: 0; text-align: justify;\">Package resource is used to manage packages. This is the base resource for other package management resources for different platforms.<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 3pt; margin-top: 0; text-align: center;\"><b style=\"font-weight: normal;\">\u00a0<\/b><\/div>\n<ul style=\"margin-bottom: 0; margin-top: 0;\">\n<li style=\"list-style-type: none;\">\n<ul style=\"margin-bottom: 0; margin-top: 0;\">\n<li style=\"background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666667px; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: circle; text-decoration: none; vertical-align: baseline;\">\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">Add nginx repo by installing epel-release.<\/div>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 36pt; margin-top: 0;\"><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 36pt; margin-top: 0;\">$ sudo chef-apply<span style=\"font-family: 'courier new'; font-size: 12px; line-height: 18.4px; text-indent: 48px; white-space: pre-wrap;\"> -l info<\/span><span style=\"font-family: 'courier new'; font-size: 12px; line-height: 1.38; white-space: pre-wrap;\"> -e &#8220;package &#8216;epel-release'&#8221;<\/span><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 3pt; margin-top: 0; text-align: center;\"><b style=\"font-weight: normal;\">\u00a0<\/b><\/div>\n<ul style=\"margin-bottom: 0; margin-top: 0;\">\n<li style=\"list-style-type: none;\">\n<ul style=\"margin-bottom: 0; margin-top: 0;\">\n<li style=\"background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666667px; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: circle; text-decoration: none; vertical-align: baseline;\">\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">Install nginx using package resource<\/div>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 36pt; margin-top: 0;\"><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 36pt; margin-top: 0;\">$ sudo chef-apply<span style=\"font-family: 'courier new'; font-size: 12px; line-height: 18.4px; text-indent: 48px; white-space: pre-wrap;\"> -l info<\/span><span style=\"font-family: 'courier new'; font-size: 12px; line-height: 1.38; white-space: pre-wrap;\"> -e &#8220;package &#8216;nginx'&#8221;<\/span><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 3pt; margin-top: 0; text-align: center;\"><b style=\"font-weight: normal;\">\u00a0<\/b><\/div>\n<ul style=\"margin-bottom: 0; margin-top: 0;\">\n<li style=\"background-color: transparent; color: black; font-family: 'Courier New'; font-size: 12px; font-style: normal; font-variant: normal; font-weight: bold; list-style-type: disc; text-decoration: none; vertical-align: baseline;\">\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">Directory resource<\/div>\n<\/li>\n<\/ul>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 36pt; margin-top: 0; text-align: justify;\">Directory resource is responsible to maintain the directory lane in target node.This resource have multiple attributes to classify the permissions, owner and group.<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 3pt; margin-top: 0; text-align: center;\"><b style=\"font-weight: normal;\">\u00a0<\/b><\/div>\n<ul style=\"margin-bottom: 0; margin-top: 0;\">\n<li style=\"list-style-type: none;\">\n<ul style=\"margin-bottom: 0; margin-top: 0;\">\n<li style=\"background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666667px; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: circle; text-decoration: none; vertical-align: baseline;\">\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">Create home directory for vhosts.<\/div>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\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-left: 36pt; margin-top: 0; text-indent: 36pt;\">$ sudo chef-apply -l info -e &#8220;directory &#8216;\/usr\/share\/nginx\/blog'&#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-left: 36pt; margin-top: 0; text-indent: 36pt;\">$ sudo chef-apply -l info -e &#8220;directory &#8216;\/usr\/share\/nginx\/chef'&#8221;<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 3pt; margin-top: 0; text-align: center;\"><b style=\"font-weight: normal;\">\u00a0<\/b><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">This will create two directories blog and chef under \u2018\/usr\/share\/nginx directory\u2019.<\/p>\n<\/div>\n<ul style=\"margin-bottom: 0; margin-top: 0;\">\n<li style=\"background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666667px; font-style: normal; font-variant: normal; font-weight: bold; list-style-type: disc; text-decoration: none; vertical-align: baseline;\">\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">File resource<\/div>\n<\/li>\n<\/ul>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 36pt; margin-top: 0; text-align: justify;\">This resource is answerable for the file management on the node. This resource holds mode, content, owner, group and path attributes with their respective meaning for a file.<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 3pt; margin-top: 0; text-align: center;\"><b style=\"font-weight: normal;\">\u00a0<\/b><\/div>\n<ul style=\"margin-bottom: 0; margin-top: 0;\">\n<li style=\"list-style-type: none;\">\n<ul style=\"margin-bottom: 0; margin-top: 0;\">\n<li style=\"background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666667px; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: circle; text-decoration: none; vertical-align: baseline;\">\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">Create index files for nginx vhosts.<\/div>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 72pt; margin-top: 0;\">$ sudo chef-apply -l info -e &#8220;file &#8216;\/usr\/share\/nginx\/blog\/index.html&#8217; do content &#8216;Hello from blog server&#8217; end&#8221;<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 3pt; margin-top: 0; text-align: center;\"><b style=\"font-weight: normal;\">\u00a0<\/b><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 72pt; margin-top: 0;\">$ sudo chef-apply -l info -e &#8220;file &#8216;\/usr\/share\/nginx\/chef\/index.html&#8217; do content &#8216;Hello from chef server&#8217; end&#8221;<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 3pt; margin-top: 0; text-align: center;\"><b style=\"font-weight: normal;\">\u00a0<\/b><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 72pt; margin-top: 0;\">File resource creates a index.html file under chef and blog directories with the respective content available in resource.<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 3pt; margin-top: 0; text-align: center;\"><b style=\"font-weight: normal;\">\u00a0<\/b><\/div>\n<ul style=\"margin-bottom: 0; margin-top: 0;\">\n<li style=\"list-style-type: none;\">\n<ul style=\"margin-bottom: 0; margin-top: 0;\">\n<li style=\"background-color: transparent; color: black; font-family: Arial; font-size: 12px; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: circle; text-decoration: none; vertical-align: baseline;\">\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-align: justify;\">Create opstree.com\/blog\/.conf \u00a0and chef.opstree.com.conf into the \/etc\/nginx\/conf.d directory with files available for this.<\/div>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 36pt; margin-top: 0; text-align: justify;\"><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 36pt; margin-top: 0; text-indent: 36pt;\">$ sudo chef-apply -l info -e &#8220;file &#8216;\/etc\/nginx\/conf.d\/opstree.com\/blog\/.conf&#8217; do content IO.read(&#8216;\/vagrant\/resources\/opstree.com\/blog\/.conf&#8217;) end&#8221;<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 3pt; margin-top: 0; text-align: center;\"><b style=\"font-weight: normal;\">\u00a0<\/b><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 36pt; margin-top: 0; text-indent: 36pt;\">$ sudo chef-apply -l info -e &#8220;file &#8216;\/etc\/nginx\/conf.d\/chef.opstree.com.conf&#8217; do content IO.read(&#8216;\/vagrant\/resources\/chef.opstree.com.conf&#8217;) end&#8221;<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 3pt; margin-top: 0; text-align: center;\"><b style=\"font-weight: normal;\">\u00a0<\/b><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 72pt; margin-top: 0; text-align: justify;\">This file resource creates vhost configuration files for opstree.com\/blog\/ and chef.opstree.com. This time file resource uses a ruby function IO.read to read the content of a sample file and paste them into target file.<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 3pt; margin-top: 0; text-align: center;\"><b style=\"font-weight: normal;\">\u00a0<\/b><\/div>\n<ul style=\"margin-bottom: 0; margin-top: 0;\">\n<li style=\"background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666667px; font-style: normal; font-variant: normal; font-weight: bold; list-style-type: disc; text-decoration: none; vertical-align: baseline;\">\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">Make entry in \/etc\/hosts<\/div>\n<ul style=\"margin-bottom: 0; margin-top: 0;\">\n<li style=\"background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666667px; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: circle; text-decoration: none; vertical-align: baseline;\">\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-align: justify;\">This is possible to make these entry with chef but it is a little complex for this time as we are not so proficient with chef. So we are doing this manually for now, but in our next article we will do this with chef.<\/div>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 36pt; margin-top: 0;\"><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 36pt; margin-top: 0;\">$ sudo vim \/etc\/hosts<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 72pt; margin-top: 0; text-align: justify;\">127.0.0.1 opstree.com\/blog\/<\/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;\">127.0.0.1 chef.opstree.com<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 3pt; margin-top: 0; text-align: center;\"><b style=\"font-weight: normal;\">\u00a0<\/b><\/div>\n<ul style=\"margin-bottom: 0; margin-top: 0;\">\n<li style=\"background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666667px; font-style: normal; font-variant: normal; font-weight: bold; list-style-type: disc; text-decoration: none; vertical-align: baseline;\">\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">Service resource<\/div>\n<\/li>\n<\/ul>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 36pt; margin-top: 0;\">Service resource is used to manage services. Use this resource to restart the nginx service.<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 3pt; margin-top: 0; text-align: center;\"><b style=\"font-weight: normal;\">\u00a0<\/b><\/div>\n<ul style=\"margin-bottom: 0; margin-top: 0;\">\n<li style=\"list-style-type: none;\">\n<ul style=\"margin-bottom: 0; margin-top: 0;\">\n<li style=\"background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666667px; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: circle; text-decoration: none; vertical-align: baseline;\">\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">Restart your nginx server to make changes effective.<\/div>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 3pt; margin-top: 0; text-align: center;\"><b style=\"font-weight: normal;\">\u00a0<\/b><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 72pt; margin-top: 0;\">$ sudo chef-apply \u00a0-e &#8220;service &#8216;nginx&#8217; do action [:stop, :start] end&#8221;<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 3pt; margin-top: 0; text-align: center;\"><b style=\"font-weight: normal;\">\u00a0<\/b><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 72pt; margin-top: 0; text-align: justify;\">This resource has two defied actions ie. stop and start which run in defined order to stop and then start nginx. You can use restart action of service resource but it is a good habit to use stop and start.<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 3pt; margin-top: 0; text-align: center;\"><b style=\"font-weight: normal;\">\u00a0<\/b><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-align: justify;\">You can find all these resources in our git repo under \u201cChef\/centos\/chefResources\/resources\u201d directory. Just run the all \u201c.sh\u201d files to run our resources.<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 3pt; margin-top: 0; text-align: center;\"><b style=\"font-weight: normal;\">\u00a0<\/b><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-align: justify;\">So now you start sensing the power of chef and also aware with the basics of resources. We will next come up with the theory behind the resources \u00a0and some new exciting examples in our blog.<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-align: center;\">\u201cThe Good NEWS Is You&#8217;re The Pilot. Michael Altshuler\u201d<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-align: justify;\">So stay great as Chef. <img loading=\"lazy\" decoding=\"async\" style=\"-webkit-transform: rotate(0.00rad); border: none; transform: rotate(0.00rad);\" src=\"https:\/\/lh3.googleusercontent.com\/frzChqLxJYtFkzfUJhriOj6BIH2GovDhtHETzDMyXPkQxU0Ji5-Q6YbA0zkcKE0Agp-oM1ttCHZ4dyEAwx3OFwtoAiZROnOLyXZQmBqEuicwN5l3BMm0dt0LPzcTTUTSCqPK3iZE\" width=\"30\" height=\"31\" \/><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u00a0 Introduction Resources are the basal element of chef\u2019s heap. In all the functioning of chef, resources are in crux. These are a very first statement of any chef recipe or cookbook. In this blog we only intensify on the practical approach of \u00a0working with resources. This article will help you to compose a primitive &hellip; <a href=\"https:\/\/opstree.com\/blog\/2016\/03\/10\/chef-resources-easy-as-pie\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Chef-Resources Easy as pie..&#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-5R","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts\/363"}],"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=363"}],"version-history":[{"count":3,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts\/363\/revisions"}],"predecessor-version":[{"id":30086,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts\/363\/revisions\/30086"}],"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=363"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/categories?post=363"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/tags?post=363"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}