cookbook 'checksum_file', '= 1.0.1'
checksum_file (4) Versions 1.0.1 Follow0
Writes the checksum of a source file or directory to a target file, often for implementing idempotence
cookbook 'checksum_file', '= 1.0.1', :supermarket
knife supermarket install checksum_file
knife supermarket download checksum_file
Checksum File Cookbook
Maintainer: OIT Systems Engineering (ua-oit-se@alaska.edu)
Purpose
This cookbook provides a single resource that calculates the checksum of a source file, then writes that checksum and other file data to a target file.
The resource will signal convergence only if the content of the target file changes.
The most common use of the checksum_file resource is to implement idempotence in a more robust fashion than looking at a single file.
One caveat is that this resource takes longer than checking for the creation of a single file, so may be prohibitive for very large directories.
However, the resource typically performs a tar and an md5sum on a target directory, and has been used for source trees of popular open-source projects without significant overhead compared to that of an entire Chef run.
This method is far faster than recursively checking content or even metadata of directory content.
Requirements
Chef
This cookbook requires Chef 14+
Platforms
Supported Platform Families:
- Debian
- Ubuntu, Mint
- Red Hat Enterprise Linux
- Amazon, CentOS, Oracle
- Suse
Platforms validated via Test Kitchen:
- Ubuntu
- Debian
- CentOS
- Oracle
- Fedora
- Amazon
- Suse
Notes:
- This cookbook should support any recent Linux variant.
Dependencies
This cookbook does not constrain its dependencies because it is intended as a utility library.
It should ultimately be used within a wrapper cookbook.
Resources
This cookbook provides one resource for saving a checksum.
checksum_file
This resource provides a single action to save a checksum to a file.
Actions
One action is provided.
-
:save
- Post condition is that the checksum, and possibly the path and metadata of the source file, are written to the target file.
Attributes
This resource has five attributes.
-
source_path
- Required. The local path to the source file (regular file or directory) for which the checksum is to be calculated. -
target_path
- Defaults to the name of the resource if not set explicitly. The local path to which to write the checksum and file information. -
owner
- Defaults toroot
. The owner of the target file. -
group
- Defaults toroot
. The group of the target file. -
mode
- Defaults to0o644
. The permissions of the target file. -
include_path
- Defaults totrue
. Determines if path information is recorded along with the checksum. If true, a change to the source path (moving the source file) will cause the resource to converge and signal subscribers. The source path is canonicalized before recording so relative, absolute, double dots, and multiple slashes do not matter. -
include_metadata
- Defaults totrue
. For regular files, determines if metadata is recorded along with the checksum. If true, changing owner, group, mode, or touching the source file will cause the resource to converge and signal subscribers. For directories, metadata is always included for the directory itself and its content. Due to a limitation of GNU tar, modification times are only accurate to one second for directory content. -
checksum_algorithm
- Defaults tomd5
. The algorithm to use. Supported values aremd5
andsha1
, not case sensitive.
Recipes
This cookbook provides no recipes.
Examples
Custom resources can be used as below.
checksum_file 'Source Checksum' do source_path path_to_source_directory target_path '/var/chef/cache/source-checksum' end # Make sure the build triggers iff the sources change file path_to_bin_file do action :nothing subscribes :delete, 'checksum_file[Source Checksum]', :immediate end bash 'Compile and Install' do code 'make && make install' cwd path_to_source_directory creates path_to_bin_file end
Development
See CONTRIBUTING.md and TESTING.md.
Dependent cookbooks
This cookbook has no specified dependencies.
Contingent cookbooks
Changelog for Checksum File Cookbook
1.0.1
- Fixed build shield URL
- Added Codecov integration
1.0.0
- Initial release
Collaborator Number Metric
1.0.1 failed this metric
Failure: Cookbook has 0 collaborators. A cookbook must have at least 2 collaborators to pass this metric.
Contributing File Metric
1.0.1 passed this metric
Foodcritic Metric
1.0.1 passed this metric
No Binaries Metric
1.0.1 passed this metric
Testing File Metric
1.0.1 passed this metric
Version Tag Metric
1.0.1 passed this metric
1.0.1 failed this metric
1.0.1 passed this metric
Foodcritic Metric
1.0.1 passed this metric
No Binaries Metric
1.0.1 passed this metric
Testing File Metric
1.0.1 passed this metric
Version Tag Metric
1.0.1 passed this metric
1.0.1 passed this metric
1.0.1 passed this metric
Testing File Metric
1.0.1 passed this metric
Version Tag Metric
1.0.1 passed this metric
1.0.1 passed this metric
1.0.1 passed this metric