chef

https://github.com/opscode/chef

Ruby

A systems integration framework, built to bring the benefits of configuration management to your entire infrastructure.

Chef::Resource#only_if

A command or block that indicates whether to actually run this resource.
The command or block is run just before the action actually executes, and
the action will be skipped if the block returns false.

If a block is specified, it must return `true` in order for the Resource
to be executed.

If a command is specified, the resource's #guard_interpreter will run the
command and interpret the results according to `opts`.  For example, the
default `execute` resource will be treated as `false` if the command
returns a non-zero exit code, and `true` if it returns 0.  Thus, in the
default case:

- `only_if "your command"` will perform the action only if `your command`
returns 0.
- `only_if "your command", valid_exit_codes: [ 1, 2, 3 ]` will perform the
  action only if `your command` returns 1, 2, or 3.

Source | Google | Stack overflow

Edit

git clone [email protected]:opscode/chef.git

cd chef

open lib/chef/resource.rb

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-Chef--Resource-only_if-for-pr


# Commit to git

git add lib/chef/resource.rbgit commit -m "better docs for Chef::Resource#only_if"


# Open pull request

gem install hub # on a mac you can `brew install hub`

hub fork

git push <your name> -your-name--update-docs-Chef--Resource-only_if-for-pr

hub pull-request


# Celebrate!