title: Puppet File resource runs despite Exec unless
body: <p>I'm applying a local manifest to test an <code>exec</code> and <code>file</code> resource:</p>
  
  <pre><code>class test_file {   
    exec { "touch /tmp/testfile":
      path   =&gt; ["/bin", "/usr/bin", "/sbin", "/usr/sbin"],
      unless =&gt; "test -d /tmp 2&gt;/dev/null",
    }
  
    file { "/tmp/success":
      mode    =&gt; "0777",
      owner   =&gt; "root",
      group   =&gt; "staff",
      source  =&gt; "file:///Users/Shared/success",
      require =&gt; Exec["touch /tmp/testfile"],
    }
  }
  </code></pre>
  
  <p><strong>What I expect to happen:</strong> 
  The <code>exec</code> runs and exits because the <code>unless</code> statement returns 0, so the file resource never runs and neither file is created in <code>/tmp</code>.</p>
  
  <p><strong>What Actually happens:</strong> 
  The <code>file</code> resource always runs, and copies the "success" file to <code>/tmp</code></p>
  
  <p>I've run this on macOS 10.11 and 10.12 with both puppet agent 4.10 and 5.3.2 ... with the same results. I'm simply trying to run a conditional that says don't copy a file if some command exits successful. Any insights or directions would be appreciated.</p>