{"id":8296,"date":"2022-11-22T03:10:03","date_gmt":"2022-11-22T03:10:03","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=8296"},"modified":"2022-12-23T05:45:29","modified_gmt":"2022-12-23T05:45:29","slug":"top-10-chef-in-built-and-common-resource-types-with-example","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/top-10-chef-in-built-and-common-resource-types-with-example\/","title":{"rendered":"Chef Tutorials: Chef in-built and common resource types with example"},"content":{"rendered":"\n<ul class=\"wp-block-list\">\n<li>package: Used to manage packages on a node<\/li>\n\n\n\n<li>service: Used to manage services on a node<\/li>\n\n\n\n<li>user: Manage users on the node<\/li>\n\n\n\n<li>group: Manage groups<\/li>\n\n\n\n<li>template: Manage files with embedded ruby templates<\/li>\n\n\n\n<li>cookbook_file: Transfer files from the files subdirectory in the cookbook to a location on the node<\/li>\n\n\n\n<li>file: Manage contents of a file on node<\/li>\n\n\n\n<li>directory: Manage directories on node<\/li>\n\n\n\n<li>execute: Execute a command on the node. Use the&nbsp;<strong>script<\/strong>&nbsp;resource to execute a script using a specific interpreter (Ruby, Python, Perl, csh, or Bash).<\/li>\n\n\n\n<li>cron: Edit an existing cron file on the node<\/li>\n\n\n\n<li>bash: Use the\u00a0<strong>bash<\/strong>\u00a0resource to execute scripts using the Bash interpreter.<\/li>\n\n\n\n<li>log: A\u00a0<strong>log<\/strong>\u00a0resource block adds messages to the log file based on events that occur during a Chef Infra Client run:<\/li>\n<\/ul>\n\n\n\n<p><strong>Bash vs execute<\/strong><\/p>\n\n\n\n<p>For a single script, use an execute. The bash resource is for including the script contents inline in the recipe code.<\/p>\n\n\n\n<p>Use the bash resource to execute scripts using the Bash interpreter. Commands that are executed with this resource are (by their nature) not idempotent, as they are typically unique to the environment in which they are run.<\/p>\n\n\n\n<p>Use the execute resource to execute a single command. Commands that are executed with this resource are (by their nature) not idempotent, as they are typically unique to the environment in which they are run.Use the script resource to execute a script using a specific interpreter (Ruby, Python, Perl, csh, or Bash).<\/p>\n\n\n\n<p><strong>Chef in-built and common resource types<\/strong><\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/devops-school\/986439fd8804a79e713a70a3451dbaf0.js\"><\/script>\n\n\n<div class=\"epyt-gallery\" data-currpage=\"1\" id=\"epyt_gallery_30818\"><figure class=\"wp-block-embed wp-block-embed-youtube is-type-video is-provider-youtube epyt-figure\"><div class=\"wp-block-embed__wrapper\"><iframe loading=\"lazy\"  id=\"_ytid_53579\"  width=\"760\" height=\"427\"  data-origwidth=\"760\" data-origheight=\"427\" src=\"https:\/\/www.youtube.com\/embed\/?enablejsapi=1&#038;autoplay=0&#038;cc_load_policy=0&#038;cc_lang_pref=&#038;iv_load_policy=1&#038;loop=0&#038;rel=1&#038;fs=1&#038;playsinline=0&#038;autohide=2&#038;theme=dark&#038;color=red&#038;controls=1&#038;disablekb=0&#038;\" class=\"__youtube_prefs__  no-lazyload\" title=\"YouTube player\"  data-epytgalleryid=\"epyt_gallery_30818\"  allow=\"fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen data-no-lazy=\"1\" data-skipgform_ajax_framebjll=\"\"><\/iframe><\/div><\/figure><div class=\"epyt-gallery-list\"><div>Sorry, there was a YouTube error.<\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>Bash vs execute For a single script, use an execute. The bash resource is for including the script contents inline in the recipe code. Use the bash&#8230; <\/p>\n","protected":false},"author":1,"featured_media":8314,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[88],"tags":[],"class_list":["post-8296","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-chef"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/8296","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=8296"}],"version-history":[{"count":7,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/8296\/revisions"}],"predecessor-version":[{"id":31834,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/8296\/revisions\/31834"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/8314"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=8296"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=8296"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=8296"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}