chef

https://github.com/opscode/chef

Ruby

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

Chef::Provider::File#inspect_existing_fs_entry

Handles resource requirements for action :create when some fs entry
already exists at the destination path. For actions other than create,
we don't care what kind of thing is at the destination path because:
* for :create_if_missing, we're assuming the user wanted to avoid blowing away the non-file here
* for :touch, we can modify perms of whatever is at this path, regardless of its type
* for :delete, we can blow away whatever is here, regardless of its type

For the action :create case, we need to deal with user-selectable
behavior to see if we're in an error condition.
* If there's no file at the destination path currently, we're cool to
  create it.
* If the fs entry that currently exists at the destination is a regular
  file, we're cool to update it with new content.
* If the fs entry is a symlink AND the resource has
  `manage_symlink_source` enabled, we need to verify that the symlink is
  a valid pointer to a real file. If it is, we can manage content and
  permissions on the symlink source, otherwise, error.
* If `manage_symlink_source` is not enabled, fall through.
* If force_unlink is true, action :create will unlink whatever is in the way.
* If force_unlink is false, we're in an exceptional situation, so we
  want to error.

Note that this method returns values to be used with requirement
assertions, which then decide whether or not to raise or issue a
warning for whyrun mode.

Source | Google | Stack overflow

Edit

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

cd chef

open lib/chef/provider/file.rb

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-Chef--Provider--File-inspect_existing_fs_entry-for-pr


# Commit to git

git add lib/chef/provider/file.rbgit commit -m "better docs for Chef::Provider::File#inspect_existing_fs_entry"


# 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--Provider--File-inspect_existing_fs_entry-for-pr

hub pull-request


# Celebrate!