opscode/chef — pull request #1393 by sysbot (2014-04-27 21:37:53+00:00)
Title: Making sure file exist before attemping unlinking it. Otherwise cause er...

When "force_unlink true" is use, if the file doesn't already exist, file creation will fail because the old code will attempt to unlink it without checking to see if it exist.

* file[/etc/resolvconf/resolv.conf.d/tail] action create [2014-04-27T18:53:31+00:00] INFO: Processing file[/etc/resolvconf/resolv.conf.d/tail] action create (resolvconf::install line 23)

================================================================================

Error executing action `create` on resource 'file[/etc/resolvconf/resolv.conf.d/tail]'
================================================================================

Errno::ENOENT
-------------
No such file or directory - /etc/resolvconf/resolv.conf.d/tail

Resource Declaration:
---------------------
# In /tmp/kitchen/cache/cookbooks/resolvconf/recipes/install.rb

23: file "/etc/resolvconf/resolv.conf.d/tail" do
24: mode 00644
25: content "abc"
26: action :create
27: # Remove file if it is not a regular file (e.g. a symlink)

28: # This is useful, as sometimes the backup stored in the file "original"
29: # is symlinked to "tail"
30: force_unlink true
31: end

Compiled Resource:
------------------
# Declared in /tmp/kitchen/cache/cookbooks/resolvconf/recipes/install.rb:23:in `from_file'

file("/etc/resolvconf/resolv.conf.d/tail") do
provider Chef::Provider::File

action [:create]
retries 0
retry_delay 2
guard_interpreter :default
path "/etc/resolvconf/resolv.conf.d/tail"
backup 5
atomic_update true
force_unlink true
cookbook_name "resolvconf"
recipe_name "install"
mode 420
content "abc"
end