Adoptable Cookbooks List

Looking for a cookbook to adopt? You can now see a list of cookbooks available for adoption!
List of Adoptable Cookbooks

Supermarket Belongs to the Community

Supermarket belongs to the community. While Chef has the responsibility to keep it running and be stewards of its functionality, what it does and how it works is driven by the community. The chef/supermarket repository will continue to be where development of the Supermarket application takes place. Come be part of shaping the direction of Supermarket by opening issues and pull requests or by joining us on the Chef Mailing List.

Select Badges

Select Supported Platforms

RSS

idempotence_file (1) Versions 1.0.0

Provides a resource for managing a sentinel file

Berkshelf
Policyfile
Knife
cookbook 'idempotence_file', '~> 1.0.0'
cookbook 'idempotence_file', '~> 1.0.0', :supermarket
knife supermarket install idempotence_file
knife supermarket download idempotence_file
README
Dependencies
Changelog
Quality 88%

Idempotence File Cookbook

License GitHub Tag Build status

Maintainer: OIT Systems Engineering (ua-oit-se@alaska.edu)

Purpose

Sentinel files are often used to cheaply detect if some code has run once. A typical example is shown below.

idempotence_file = File.join('some_dir', 'some_file')

apt_update 'Pre-Install Update' do
  action :update
  not_if { File.exist?(idempotence_file) }
end

# Do we remember the dir the first time?
directory 'some_dir' do
  owner 'root'
  group 'root'
  mode 0o755
end

file idempotence_file  do
  content 'Who cares?'
  owner 'root'
  group 'root'
  mode 0o644
end

Such code is conceptually simple, but verbose and unnecessarily error prone. Across many cookbooks, such code is also not DRY.

The resource provided by this cookbook reduces the sentinel pattern to two lines of code. See the example below.

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 Windows or 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 resources for managing idempotence files.

Both the content and the location of the file are implementation-defined. A helper is provided for querying the existence of the file.

# Returns true iff the file exists
idempotence_file?('Argument must match the name of the idempotence_file')

idempotence_file

An idempotence_file manages a single file.

Actions

Two action are provided.

  • create - Post condition is that the file exists.
  • delete - Post condition is that the file does not exist.

Attributes

This resource has no attributes.

Recipes

This cookbook includes no recipes.

Attributes

This cookbook references no attributes.

Examples

The idempotence_file resource can be used as below.

apt_update 'Pre-Install Update' do
  action :update
  not_if { idempotence_file?('Pre-Install Update') }
end

idempotence_file 'Pre-Install Update'

Development

See CONTRIBUTING.md and TESTING.md.

Changelog for Idempotence File Cookbook

1.0.0

  • Initial release

Collaborator Number Metric
            

1.0.0 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.0 passed this metric

Foodcritic Metric
            

1.0.0 passed this metric

No Binaries Metric
            

1.0.0 passed this metric

Publish Metric
            

1.0.0 passed this metric

Supported Platforms Metric
            

1.0.0 passed this metric

Testing File Metric
            

1.0.0 passed this metric

Version Tag Metric
            

1.0.0 passed this metric