I am trying to find a way to run an exec
if another exec
failed (so I can cleanup the directory the first exec created).
My scenario is:
exec
creates a directory but does not fully finish setting it up (fails for network error).exec
uses creates => $target_dir
param so subsequent runs will not try again to setup the folder.exec
is skipped.I'd love to remove the directory (maybe using file
type) if the previous exec
was a failure. I know this is similar to http://ask.puppetlabs.com/question/14726/run-exec-only-if-another-exec-ran/ and run Exec only if another Exec ran. But I only want to notify on failure (maybe exit other than 0).
Any ideas how I can accomplish this?
What you can easily do within exec is:
Exec { 'exec_name':
cmd => "${some_command} || rm -rf ${directory}",
creates => $directory,
}
where ${some_command} is your actual command.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments