bbfjrw
Last Updated: February 22, 2017
·
12.36K
· mlafeldt
2190d7a468f51fa3be5eabfc9397a28b

Calculate checksum for Chef's remote_file resource

The remote_file resource that comes with Chef accepts an optional checksum attribute, which is

"The SHA-256 checksum (or portion thereof) of the file. If the local file matches the checksum, Chef will not download it. Default value: nil."

I'm using the checksum in my git::source recipe to make sure the Git source tarball is only downloaded once.

Here's how I calculated (and shortened) it:

$ curl -L -s https://github.com/gitster/git/tarball/v1.8.1 | shasum -a 256 | cut -c-12
1a9d87a5e898

And in case you already have the file on your hard disk:

$ shasum -a 256 /path/to/file | cut -c-12
Say Thanks
Respond

2 Responses
Add your response

14415
5455c491c0e626506a2e66ef0764dfbd

On centos (and probably fedora and red hat as well) shasum doesn't exist. Use sha256sum without any arguments.

From my 5 minute search, it appears that shasum is an OS X utility, perhaps BSD based.

over 1 year ago ·
18055
8bd253b21871a6ef96e96115aee69cbc

Since Chef 12 it seems you need to remove the "cut -c-12" bit.

over 1 year ago ·
Filed Under