Chef calculate checksum
I’ve been working with Chef at work and there are several items that I keep looking up. The first of these is calculating the checksum for a file that chef downloads. 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. For example formatting the EBS volumes I use something that looks like this:
remote_file "#{Chef::Config[:file_cache_path]}/format9-11-13.sh" do
source "http://somebucket.s3.amazonaws.com/format.sh"
checksum "70b8c25a25fb0aeca95b89d33571b6021a334ebbb706444fd266a6d73104f62c"
end
For Chef you need to use the following:
shasum -a 256 /path/to/file
That will generate the checksum you need in your cookbook. You don’t need to use the whole thing either, just a portion is needed as shown here: https://coderwall.com/p/bbfjrw
To calculate a checksum normally use the SHA-256 algorithm. Most of the time you would use the built-in cksum command like so:
$ cksum sample
2072207789 477 sample
Where the CRC (Cyclical Redundancy Check) or checksum is the first number then the size then the name of the file.
You may also like
Chef change attributes node level Java cookbook
Putty is the worst ssh client ever!
Chef-client fails to complete
Archives
Calendar
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 | 31 | |||||
Leave a Reply