puppet 4.7 - how can I execute something at the end of a run?
<p>I need to execute something as the very last thing of a puppet apply run. I tried to do that by defining a stage 'last', but the syntax restrictions on declaring a class in resource mode are a problem. </p>

<p>Is there a good way to use stages like this? Or is there some other way to make sure some class is executed last? </p>

<p>for example, this gives me an error for a duplicate declaration(sometimes, and I'm not sure why at this point):</p>

<pre><code>class xyz::firstrun {

  exec { 'exec_firstrun':
    onlyif =&gt; '/usr/bin/test -e /tmp/firstrun.sh',
    command =&gt; '/tmp/firstrun.sh',
    path =&gt; ['/usr/bin/','/usr/sbin'],
    creates =&gt; '/tmp/firstrun.done',
  }

}

class { 'xyz::firstrun':
    stage =&gt; last,
}
</code></pre>

<p>Sometimes, the firstrun class runs without error, but in the main stage. </p>