title: How do I get a package conditionally executed in Puppet?
body: <p>How do I get the packages to execute only if and when <code>exec['get-chocolatey']</code> is complete and successful? Right now, the packages try to get executed before the exec command and hence fails with the error reading</p>
  
  <blockquote>
    <p>Chocolatey is not functional on the node</p>
  </blockquote>
  
  <p>I don't get why 'require' doesn't work here.</p>
  
  <pre><code>exec { 'get-chocolatey':
      path        =&gt; 'C:\Windows\system32\WindowsPowerShell\v1.0',
      command     =&gt; 'Powershell.exe "Invoke-WebRequest https://chocolatey.org/install.ps1 -UseBasicParsing | Invoke-Expression"',
      refreshonly =&gt; true,
      logoutput   =&gt; true
  }
  
  package { 'webpi':
      provider =&gt; 'chocolatey',
      ensure   =&gt; latest,
      require  =&gt; Exec['get-chocolatey']
  }
  
  package { 'redis-64':
      provider =&gt; 'chocolatey',
      ensure   =&gt; latest,
      require  =&gt; Exec['get-chocolatey']
  }
  </code></pre>