{"id":360,"date":"2016-03-17T06:20:00","date_gmt":"2016-03-17T06:20:00","guid":{"rendered":""},"modified":"2025-11-27T17:13:34","modified_gmt":"2025-11-27T11:43:34","slug":"chef-resources-elementary-ingredient","status":"publish","type":"post","link":"https:\/\/opstree.com\/blog\/2016\/03\/17\/chef-resources-elementary-ingredient\/","title":{"rendered":"Chef-Resources Elementary ingredient.."},"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;\"><\/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:\/\/lh6.googleusercontent.com\/DhLljMvQ0lqLA7jmHJhEmZLviQkPROlFlnVWO5Ks-CehEuO-BuVVDh8yZdjJlSL3i1rpnL0-x_gg9vzpaVr2ii02-DTlZDGNy6DyJCOBg2FA0PYdSAhCylVwvamNeLNkGjRoyuJC\" width=\"349\" height=\"417\" \/><\/div>\n<p><b style=\"font-weight: normal;\">\u00a0<\/b><\/p>\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; text-align: justify;\">Resources are the \u201celementary ingredient\u201d of Chef house. Before mounting up on the spikes of chef\u2019s elevations, it&#8217;s favorable to tailor your suit with basics. Combining common ingredients to make a new play substance is always thrilling!. I wish I had some magic secrets or shortcuts to share, but the truth is that you have to start with the ABC&#8217;s and then you can rule over the game.<\/div>\n<p><b style=\"font-weight: normal;\">\u00a0<\/b><\/p>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-align: center;\"><\/div>\n<div class=\"separator\" style=\"clear: both; text-align: center;\"><a style=\"margin-left: 1em; margin-right: 1em;\" href=\"https:\/\/opstree.com\/blog\/\/wp-content\/uploads\/2016\/03\/411a8-gaston-juggling-eggs-beauty-and-the-beast.gif\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/opstree.com\/blog\/\/wp-content\/uploads\/2016\/03\/411a8-gaston-juggling-eggs-beauty-and-the-beast.gif?w=300\" width=\"400\" height=\"225\" border=\"0\" \/><\/a><\/div>\n<div style=\"text-align: center;\"><b style=\"font-weight: normal;\">\u00a0<\/b><\/div>\n<h2 style=\"line-height: 1.38; margin-bottom: 6pt; margin-top: 18pt;\">Trigger a VM<\/h2>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-align: justify;\">Git clone our repository dedicated for this blog series.<\/div>\n<p><b style=\"font-weight: normal;\">\u00a0<\/b><\/p>\n<div dir=\"ltr\" style=\"line-height: 1.656; margin-bottom: 0; margin-top: 0; text-align: justify;\">$ git clone git@github.com:OpsTree\/Chef.git<\/div>\n<p><b style=\"font-weight: normal;\">\u00a0<\/b><\/p>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-align: justify;\">\n<p>Change directory to Chef\/centos\/chefResourceBackings. Here you find a Vagrantfile which spin up a centos7 machine with chefdk and other tools installed in it.<\/p>\n<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-indent: 36pt;\">$ cat Vagrantfile<\/div>\n<h2 style=\"line-height: 1.38; margin-bottom: 6pt; margin-top: 18pt; text-indent: 36pt;\"><img loading=\"lazy\" decoding=\"async\" style=\"-webkit-transform: rotate(0.00rad); border: none; transform: rotate(0.00rad);\" src=\"https:\/\/lh5.googleusercontent.com\/KJK0OKe24cFu3p6Xvushmf8lINVo-OQquoEbIHiAOJvuijw5iuVPVTLiiLVMUXn4woWFyPr3XA4_EFuwTMU3dzrsX6X08QsE4pH_adUrizwEDbgiSuav0JZnhvW_z7Pdv8ZgdTxr\" width=\"512\" height=\"108\" \/><\/h2>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-align: justify;\">\n<p>Launch a new vagrant machine and login.<\/p>\n<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">\n<p>$ vagrant up<\/p>\n<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">$ vagrant ssh<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-align: justify;\">Your learning environment is ready. Although in this blog we do not focus a lot on practicals, we try to clear our theoretical concepts.<\/div>\n<p><b style=\"font-weight: normal;\">\u00a0<\/b><\/p>\n<h2 style=\"line-height: 1.38; margin-bottom: 6pt; margin-top: 18pt;\">Backings of Resources<\/h2>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-align: justify;\">Chef resources are the statements which define the configuration approach for any element. From the officials of chef, resources are<\/div>\n<p><b style=\"font-weight: normal;\">\u00a0<\/b><\/p>\n<ul style=\"margin-bottom: 0; margin-top: 0;\">\n<li style=\"background-color: white; color: #666666; font-family: Arial; font-size: 14px; font-style: italic; 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;\">Describes the desired state for a configuration item<\/div>\n<\/li>\n<li style=\"background-color: white; color: #666666; font-family: Arial; font-size: 14px; font-style: italic; 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;\">Declares the steps needed to bring that item to the desired state<\/div>\n<\/li>\n<li style=\"background-color: white; color: #666666; font-family: Arial; font-size: 14px; font-style: italic; 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;\">Specifies a resource type\u2014such as package, template, or service<\/div>\n<\/li>\n<li style=\"background-color: white; color: #666666; font-family: Arial; font-size: 14px; font-style: italic; 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;\">Lists additional details (also known as resource properties), as necessary<\/div>\n<\/li>\n<li style=\"background-color: white; color: #666666; font-family: Arial; font-size: 14px; font-style: italic; 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;\">Are grouped into recipes, which describe working configurations<\/div>\n<\/li>\n<\/ul>\n<p><b style=\"font-weight: normal;\">\u00a0<\/b><\/p>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-align: justify;\">Chef works with two basic parts, properties and actions.<\/div>\n<h3 style=\"line-height: 1.38; margin-bottom: 4pt; margin-top: 16pt;\">Properties<\/h3>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-align: justify;\">Properties are the attributes and definitions for the target element of any resources. Some common properties for all resources without exception.<\/div>\n<h4 style=\"line-height: 1.8; margin-bottom: 4pt; margin-top: 14pt;\">ignore_failure<\/h4>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 13pt; margin-left: 23pt; margin-top: 2pt; text-align: justify;\">What to do when a resource is fail in its doings i.e. continue or stop. Default value is false or stop.<\/div>\n<h4 style=\"line-height: 1.8; margin-bottom: 4pt; margin-top: 14pt;\">provider<\/h4>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 13pt; margin-left: 23pt; margin-top: 2pt; text-align: justify;\">This is an optional property. You can explicitly define the correct provider for a resource. In common practices this is not mandatory to specified.<\/div>\n<h4 style=\"line-height: 1.8; margin-bottom: 4pt; margin-top: 14pt;\">retries<\/h4>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 13pt; margin-left: 23pt; margin-top: 2pt; text-align: justify;\">Number of attempts that a resource tries in chef-run. Default value is 0.<\/div>\n<h4 style=\"line-height: 1.8; margin-bottom: 4pt; margin-top: 14pt;\">retry_delay<\/h4>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 13pt; margin-left: 23pt; margin-top: 2pt; text-align: justify;\">Time duration between two consecutive tries. Default value is 2.<\/div>\n<h4 style=\"line-height: 1.8; margin-bottom: 4pt; margin-top: 14pt;\">sensitive<\/h4>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 13pt; margin-left: 23pt; margin-top: 2pt; text-align: justify;\">This defines that the data in resource is sensitive and is not logged by chef-client. Default value is false. This property only applies to the execute, file and template resources.<\/div>\n<p><b style=\"font-weight: normal;\">\u00a0<\/b><\/p>\n<h3 style=\"line-height: 1.38; margin-bottom: 4pt; margin-top: 16pt;\">Action<\/h3>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-align: justify;\">Actions differ for distinct resources. A common action for every resource is :nothing. Nothing action stated that resource should not do anything until it is notified by any other resource.<\/div>\n<h2 style=\"line-height: 1.38; margin-bottom: 6pt; margin-top: 18pt;\">Some Basic Resources<\/h2>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-align: justify;\">Lets took example of some of the basic resources.<\/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: 12pt; margin-top: 0;\">Package<\/div>\n<\/li>\n<\/ul>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 12pt; margin-left: 36pt; margin-top: 0;\">This resource manage packages. This install, uninstall and upgrade any package. This resource is also a platform for some other dependent package management resources such as apt_package, dpkg_package, gem_package, yum_package etc. Available actions are :install, :purge, :remove, :upgrade and :nothing.<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-indent: 36pt;\">Example:<\/div>\n<p><b style=\"font-weight: normal;\">\u00a0<\/b><\/p>\n<div dir=\"ltr\" style=\"line-height: 1.368; margin-bottom: 6pt; margin-left: 72pt; margin-top: 0;\">package &#8216;tar&#8217; do<br class=\"kix-line-break\" \/>\u00a0version &#8216;1.26-29.el7&#8217;<br class=\"kix-line-break\" \/>\u00a0action :install<br class=\"kix-line-break\" \/>end<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.368; margin-bottom: 6pt; margin-left: 72pt; margin-top: 0;\">OR<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.368; margin-bottom: 6pt; margin-left: 72pt; margin-top: 0;\">package &#8216;tar&#8217; do<br class=\"kix-line-break\" \/>\u00a0action :remove<br class=\"kix-line-break\" \/>end<\/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<\/div>\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-align: justify;\">This is responsible to manage files on a machine. Available actions are :create, :create_if_missing, :delete, :nothing and :touch.<\/div>\n<p><b style=\"font-weight: normal;\">\u00a0<\/b><\/p>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 36pt; margin-top: 0;\">Example<\/div>\n<p><b style=\"font-weight: normal;\">\u00a0<\/b><\/p>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 72pt; margin-top: 0;\">file &#8216;\/tmp\/test.txt&#8217; do<br class=\"kix-line-break\" \/>\u00a0content &#8216;This is testing file.&#8217;<br class=\"kix-line-break\" \/>\u00a0mode &#8216;0755&#8217;<br class=\"kix-line-break\" \/>\u00a0owner &#8216;root&#8217;<br class=\"kix-line-break\" \/>\u00a0group &#8216;root&#8217;<br class=\"kix-line-break\" \/>end<\/div>\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; text-indent: 36pt;\">OR<\/div>\n<p><b style=\"font-weight: normal;\">\u00a0<\/b><\/p>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 72pt; margin-top: 0;\">file &#8216;\/tmp\/test2.txt&#8217; do<br class=\"kix-line-break\" \/>\u00a0content IO.read(&#8216;\/vagrant\/resources\/string.txt&#8217;)<br class=\"kix-line-break\" \/>\u00a0action :create<br class=\"kix-line-break\" \/>end<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 72pt; margin-top: 0; text-align: justify;\">This will create a test.txt file under \/tmp directory and put the contents of string.txt file into it.<\/div>\n<p><b style=\"font-weight: normal;\">\u00a0<\/b><\/p>\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<\/div>\n<\/li>\n<\/ul>\n<p><b style=\"font-weight: normal;\">\u00a0<\/b><\/p>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 36pt; margin-top: 0; text-align: justify;\">\n<p>Subjected to manage services. Available actions are :disable, :enable, :nothing, :reload, :restart, :start and :stop.<\/p>\n<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-indent: 36pt;\">\n<p>Example<\/p>\n<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.368; margin-bottom: 6pt; margin-left: 72pt; margin-top: 0;\">service &#8216;nginx&#8217; \u00a0do<br class=\"kix-line-break\" \/>\u00a0action :start<br class=\"kix-line-break\" \/>end<\/div>\n<p><b style=\"font-weight: normal;\">\u00a0<\/b><\/p>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 72pt; margin-top: 0;\">\n<p>OR<\/p>\n<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.368; margin-bottom: 6pt; margin-left: 72pt; margin-top: 0;\">service &#8216;nginx&#8217; do<br class=\"kix-line-break\" \/>\u00a0supports :status =&gt; true, :restart =&gt; true, :reload =&gt; true<br class=\"kix-line-break\" \/>\u00a0action [ :enable, :start ]<br class=\"kix-line-break\" \/>end<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.368; margin-bottom: 6pt; margin-left: 72pt; margin-top: 0;\">This will ensure enable then start options for nginx service. Before this, install nginx using package resource.<\/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;\">Template<\/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;\">\n<p>This resource calls chef templates to dynamically generate static files. Templates are &#8220;.erb&#8221; files with some variables and placed under \u201c\/templates\u201d directory of cookbook. Available actions are \u00a0:create, :create_if_missing, :delete, :nothing and :touch. \u00a0Template resource only available with cookbooks, you can not use this resource with chef-apply from command line.<\/p>\n<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 36pt; margin-top: 0;\">\n<p>Example<\/p>\n<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.368; margin-bottom: 6pt; margin-left: 72pt; margin-top: 0;\">template &#8216;\/tmp\/sshd_config&#8217; do<br class=\"kix-line-break\" \/>\u00a0source &#8216;sshd_config.erb&#8217;<br class=\"kix-line-break\" \/>\u00a0owner &#8216;root&#8217;<br class=\"kix-line-break\" \/>\u00a0group &#8216;root&#8217;<br class=\"kix-line-break\" \/>\u00a0mode &#8216;0755&#8217;<br class=\"kix-line-break\" \/>end<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 36pt; margin-top: 0; text-indent: 36pt;\">OR<\/div>\n<p><b style=\"font-weight: normal;\">\u00a0<\/b><\/p>\n<div dir=\"ltr\" style=\"line-height: 1.368; margin-bottom: 6pt; margin-left: 72pt; margin-top: 0;\">template &#8216;\/tmp\/config.conf&#8217; do<br class=\"kix-line-break\" \/>\u00a0source &#8216;config.conf.erb&#8217;<br class=\"kix-line-break\" \/>\u00a0variables(<br class=\"kix-line-break\" \/>\u00a0\u00a0\u00a0:config_var =&gt; &#8216;mytext&#8217;<br class=\"kix-line-break\" \/>\u00a0)<br class=\"kix-line-break\" \/>end<\/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;\">This will pass variables to config.conf.erb file to generate config.conf file.<\/div>\n<h2 style=\"line-height: 1.38; margin-bottom: 6pt; margin-top: 18pt;\">Extended Resource<\/h2>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-align: justify;\">Have some attention towards less likely used but important resources.<\/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;\">\n<p>Git<\/p>\n<\/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 manages git repository by interacting with source code management system. Git version 1.6.5 (or higher) is required. Available actions are :checkout, :export, :nothing and :sync.<\/div>\n<p><b style=\"font-weight: normal;\">\u00a0<\/b><\/p>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-indent: 36pt;\">\n<p>Example<\/p>\n<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.368; margin-bottom: 6pt; margin-left: 72pt; margin-top: 0;\">git &#8216;\/opt\/mygit\/&#8217; do<br class=\"kix-line-break\" \/>\u00a0repository &#8216;https:\/\/github.com\/OpsTree\/Chef.git&#8217;<br class=\"kix-line-break\" \/>\u00a0revision &#8216;master&#8217;<br class=\"kix-line-break\" \/>\u00a0action :sync<br class=\"kix-line-break\" \/>end<\/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;\">\n<p>Link<\/p>\n<\/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;\">\n<p>Resource is responsible to manage soft and hard links. Available actions are :create, :delete and :nothing.<\/p>\n<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 36pt; margin-top: 0;\">\n<p>Example<\/p>\n<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 72pt; margin-top: 0;\">link &#8216;\/tmp\/myfile&#8217; do<br class=\"kix-line-break\" \/>\u00a0to &#8216;\/etc\/ssh\/sshd_config&#8217;<br class=\"kix-line-break\" \/>end<\/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;\">OR<\/div>\n<p><b style=\"font-weight: normal;\">\u00a0<\/b><\/p>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 72pt; margin-top: 0;\">link &#8216;\/tmp\/myhardfile&#8217; do<br class=\"kix-line-break\" \/>\u00a0to &#8216;\/etc\/ssh\/sshd_config&#8217;<br class=\"kix-line-break\" \/>\u00a0link_type :hard<br class=\"kix-line-break\" \/>end<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 36pt; margin-top: 0; text-indent: 36pt;\">The default link_type is :symbolic.<\/div>\n<p><b style=\"font-weight: normal;\">\u00a0<\/b><\/p>\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;\">\n<p>Script<\/p>\n<\/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 resources is used to execute external script. The supported interpreters are Bash, csh, Perl, Python, or Ruby. Available actions are :run and :nothing.<\/div>\n<p><b style=\"font-weight: normal;\"><br \/>\n<\/b>Example<\/p>\n<div dir=\"ltr\" style=\"line-height: 1.368; margin-bottom: 6pt; margin-left: 72pt; margin-top: 0;\">script &#8216;extract_module&#8217; do<br class=\"kix-line-break\" \/>\u00a0interpreter &#8216;bash&#8217;<br class=\"kix-line-break\" \/>\u00a0cwd &#8216;\/tmp&#8217;<br class=\"kix-line-break\" \/>\u00a0code &lt;&lt;-EOH<br class=\"kix-line-break\" \/>\u00a0\u00a0\u00a0mkdir -p \/tmp\/mytest<br class=\"kix-line-break\" \/>\u00a0\u00a0\u00a0touch \/tmp\/mytest\/file.txt<br class=\"kix-line-break\" \/>\u00a0\u00a0\u00a0EOH<br class=\"kix-line-break\" \/>end<\/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;\">Cron<\/div>\n<\/li>\n<\/ul>\n<p><b style=\"font-weight: normal;\">\u00a0<\/b><\/p>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 36pt; margin-top: 0; text-align: justify;\">To manage your cron jobs use this resource. If a property is not specified then default \u2018*\u2019 value is taken. Available actions are :create, :delete and :nothing.<\/div>\n<p><b style=\"font-weight: normal;\">\u00a0<\/b><\/p>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 36pt; margin-top: 0;\">Example<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 72pt; margin-top: 0;\"><\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 72pt; margin-top: 0;\">cron &#8216;noop&#8217; do<br class=\"kix-line-break\" \/>\u00a0hour &#8216;5&#8217;<br class=\"kix-line-break\" \/>\u00a0minute &#8216;0&#8217;<br class=\"kix-line-break\" \/>\u00a0command &#8216;\/bin\/true&#8217;<br class=\"kix-line-break\" \/>end<\/div>\n<p><b style=\"font-weight: normal;\">\u00a0<\/b><\/p>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 72pt; margin-top: 0;\">OR<\/div>\n<p><b style=\"font-weight: normal;\">\u00a0<\/b><\/p>\n<div dir=\"ltr\" style=\"line-height: 1.368; margin-bottom: 6pt; margin-left: 72pt; margin-top: 0;\">cron &#8216;tuesdaycron&#8217; do<br class=\"kix-line-break\" \/>\u00a0minute &#8217;50&#8217;<br class=\"kix-line-break\" \/>\u00a0hour &#8217;11&#8217;<br class=\"kix-line-break\" \/>\u00a0weekday &#8216;2&#8217;<br class=\"kix-line-break\" \/>\u00a0command &#8216;\/bin\/true&#8217;<br class=\"kix-line-break\" \/>\u00a0action :create<br class=\"kix-line-break\" \/>end<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-left: 36pt; margin-top: 0; text-indent: 36pt;\">This will run the cron job only on tuesday 11:50am.<\/div>\n<p><b style=\"font-weight: normal;\">\u00a0<\/b><\/p>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0;\">To test all resources available above, go to resource directory under \u201cchefResourceBackings\u201d directory. \u00a0All resources are available as bash script.<\/div>\n<h2 style=\"line-height: 1.38; margin-bottom: 6pt; margin-top: 18pt;\">Custom Resources<\/h2>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-align: justify;\">It\u2019s an extension of the initially available properties. \u00a0Chef allows you to create your own resources. These custom resources extend the basic definitions of the built-in resources. The custom resources resides in the \u201c\/resources\u201d directory of any cookbook. Conventionally name of any custom resource is the name of cookbook and name of resource file separated by underscore (_). \u00a0Custom resource creation is not an initial task for us so we skip this for now.<\/div>\n<p><b style=\"font-weight: normal;\">\u00a0<\/b><\/p>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-align: justify;\">This is difficult to cover all about the resource(every resource and their properties or actions) in this article. Refer to <a style=\"text-decoration: none;\" href=\"https:\/\/docs.chef.io\/resources.html\" target=\"_blank\" rel=\"noopener\">chef-resources<\/a> for more information.<\/div>\n<p><b style=\"font-weight: normal;\">\u00a0<\/b><\/p>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-align: justify;\">It\u2019s hard to get this boring stuff exciting in any manner. But it&#8217;s a fact that every serious effort makes you closer towards the excellence.<\/div>\n<p><b style=\"font-weight: normal;\">\u00a0<\/b><\/p>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-align: center;\">\u201cThe Expert In Anything Was Once A Beginner. \u201c<\/div>\n<div dir=\"ltr\" style=\"line-height: 1.38; margin-bottom: 0; margin-top: 0; text-align: justify;\">Wanna be an adroit of Chef then from now \u201cpractice like a devil play like an angel\u201d.<img loading=\"lazy\" decoding=\"async\" style=\"-webkit-transform: rotate(0.00rad); border: none; transform: rotate(0.00rad);\" src=\"https:\/\/lh5.googleusercontent.com\/jGv3Ey46nBrYZEVWgVDACM1owXvzv1AMajmxjQCaikYwbrGrbLUKj840bQ4qS3YMB04zvYFAt517pmEZOp_rpW6sdfUgKrUS5Dp-h6SHSOC2yibFeb5OKC9UNJxtpsEFIul1PnSn\" width=\"52\" height=\"42\" \/><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u00a0 Introduction Resources are the \u201celementary ingredient\u201d of Chef house. Before mounting up on the spikes of chef\u2019s elevations, it&#8217;s favorable to tailor your suit with basics. Combining common ingredients to make a new play substance is always thrilling!. I wish I had some magic secrets or shortcuts to share, but the truth is that &hellip; <a href=\"https:\/\/opstree.com\/blog\/2016\/03\/17\/chef-resources-elementary-ingredient\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Chef-Resources Elementary ingredient..&#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-5O","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts\/360"}],"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=360"}],"version-history":[{"count":7,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts\/360\/revisions"}],"predecessor-version":[{"id":30084,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts\/360\/revisions\/30084"}],"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=360"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/categories?post=360"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/tags?post=360"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}