How do I use idempotency in Chef Opscode to run a mount resource once?

advertisements

I can not find how to mount a device in linux only once with chef. Meaning on the other chef client the resource should not execute because a device there has already been mounted to a specific path. How can I use chef's idempotency to do this? ...

This is the log stacktrace that I see in the end of chef-client log

[2013-11-06T23:12:28+00:00] ERROR: Running exception handlers
[2013-11-06T23:12:29+00:00] FATAL: Saving node information to /var/chef/cache/failed-run-data.json

[2013-11-06T23:12:29+00:00] ERROR: Exception handlers complete

[2013-11-06T23:12:29+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out

[2013-11-06T23:12:29+00:00] FATAL: Mixlib::ShellOut::ShellCommandFailed: mount[/testpath] (mycookbook::myrecipe line 53) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '32'

STDOUT: 

STDERR: mount: /dev/xvdb already mounted or /testpath busy
mount: according to mtab, /dev/xvdb is already mounted on /testpath

---- End output of mount -t auto -o defaults /dev/xvdb /testpath ----

Ran mount -t auto -o defaults /dev/xvdb /testpath returned 32


Use the mount resource:

mount '/testpath' do
  device '/dev/xvdb'
  action [:mount, :enable]
end