{"id":16,"date":"2013-09-21T01:51:27","date_gmt":"2013-09-21T01:51:27","guid":{"rendered":"http:\/\/192.168.1.102\/?p=16"},"modified":"2014-11-19T19:37:16","modified_gmt":"2014-11-19T19:37:16","slug":"chef-calculate-checksum","status":"publish","type":"post","link":"https:\/\/digitalsos.net\/?p=16","title":{"rendered":"Chef calculate checksum"},"content":{"rendered":"<p>I&#8217;ve been working with Chef at work and there are several items that I keep looking up.\u00a0 The first of these is calculating the checksum for a file that chef downloads.\u00a0 Since we are doing some customized recipes I keep looking at having to grab a file and check the checksum, although not completely necessary it is a nice to have.\u00a0 For example formatting the EBS volumes I use something that looks like this:<\/p>\n<pre><code>remote_file \"#{Chef::Config[:file_cache_path]}\/format9-11-13.sh\" do\r\nsource \"http:\/\/somebucket.s3.amazonaws.com\/format.sh\"\r\nchecksum \"70b8c25a25fb0aeca95b89d33571b6021a334ebbb706444fd266a6d73104f62c\"\r\nend<\/code><\/pre>\n<p>For <strong>Chef<\/strong> you need to use the following:<\/p>\n<pre><code>shasum -a 256 \/path\/to\/file<\/code><\/pre>\n<p>That will generate the checksum you need in your cookbook. You don&#8217;t need to use the whole thing either, just a portion is needed as shown here:\u00a0<a title=\"Claculate Checksum\" href=\"https:\/\/coderwall.com\/p\/bbfjrw\" target=\"_blank\">https:\/\/coderwall.com\/p\/bbfjrw<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>To calculate a checksum normally use the SHA-256 algorithm. Most of the time you would use the built-in cksum command like so:<\/p>\n<pre><code>$ cksum sample\r\n2072207789 477 sample<\/code><\/pre>\n<p>Where the CRC (Cyclical Redundancy Check) or checksum is the first number then the size then the name of the file.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been working with Chef at work and there are several items that I keep looking up.\u00a0 The first of these is calculating the checksum for a file that chef downloads.\u00a0 Since we are doing some customized recipes I keep looking at having to grab a file and check the checksum, although not completely necessary<\/p>\n<div class=\"read-more-wrapper\"><a class=\"read-more\" href=\"https:\/\/digitalsos.net\/?p=16\" title=\"Read More\"> <span class=\"button \">Read More<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"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","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[2,3],"tags":[39],"class_list":["post-16","post","type-post","status-publish","format-standard","hentry","category-chef","category-devops","tag-chef"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pgxmGV-g","_links":{"self":[{"href":"https:\/\/digitalsos.net\/index.php?rest_route=\/wp\/v2\/posts\/16","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/digitalsos.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/digitalsos.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/digitalsos.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/digitalsos.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=16"}],"version-history":[{"count":3,"href":"https:\/\/digitalsos.net\/index.php?rest_route=\/wp\/v2\/posts\/16\/revisions"}],"predecessor-version":[{"id":155,"href":"https:\/\/digitalsos.net\/index.php?rest_route=\/wp\/v2\/posts\/16\/revisions\/155"}],"wp:attachment":[{"href":"https:\/\/digitalsos.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=16"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/digitalsos.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=16"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/digitalsos.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=16"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}