title: Puppet: Evaluating variables inside onlyif close
body: <p>I have a variable that I set at a very early stage, the variable is boolean, then at some point I want to <code>exec</code> a command based on the fact if this variable is true or false, something like this:</p>
  
  <pre><code>exec { 'update-to-latest-core': 
    command     =&gt; "do something",
    user        =&gt; 'root',
    refreshonly =&gt; true,
    path        =&gt; [ "/bin/bash", "sbin/" , "/usr/bin/", "/usr/sbin/" ], 
    onlyif      =&gt; 'test ${latest} =      true',
    notify      =&gt; Exec["update-to-latest-database"],
  }
  </code></pre>
  
  <p>So this command doesn't work (<code>onlyif =&gt; ['test ${latest} = true'],</code>) I tried several other ways too, but didn't work. Something so simple cannot be so hard to do. Can someone help me with this, and also explain the rules behind getting commands to execute inside <code>onlyif</code> close. (also I cannot use if-close on a higher level because I have other dependencies )</p>