title: How to get Puppet exec to cleanup directory on failure?
body: <p>I am trying to find a way to run an <code>exec</code> if another <code>exec</code> failed (so I can cleanup the directory the first exec created).</p>
  
  <p>My scenario is:</p>
  
  <ol>
  <li>The <code>exec</code> creates a directory but does not fully finish setting it up (fails for network error).</li>
  <li>The <code>exec</code> uses <code>creates =&gt; $target_dir</code> param so subsequent runs will not try again to setup the folder.</li>
  <li>The Puppet manifest is applied again after the failure and the <code>exec</code> is skipped.</li>
  </ol>
  
  <p>I'd love to remove the directory (maybe using <code>file</code> type) if the previous <code>exec</code> was a failure. I know this is similar to <a href="http://ask.puppetlabs.com/question/14726/run-exec-only-if-another-exec-ran/" rel="nofollow noreferrer">http://ask.puppetlabs.com/question/14726/run-exec-only-if-another-exec-ran/</a> and <a href="https://stackoverflow.com/questions/27150839/run-exec-only-if-another-exec-ran">run Exec only if another Exec ran</a>. But I only want to notify on failure (maybe exit other than 0).</p>
  
  <p>Any ideas how I can accomplish this?</p>