title: Defining puppet class ordering when if statement exists
body: <p>I have a Puppet class which, among other things, sets up a whole bunch of Debian repositories, performs an apt-get update and then installs a few packages. </p>
  
  <p>The ordering must be strictly as follows: </p>
  
  <ol>
  <li>setup apt sources </li>
  <li>apt-get update</li>
  <li>install application packages</li>
  </ol>
  
  <p>To define the ordering, I have used the following chaining after declaring all of my resources:</p>
  
  <pre><code>File['/etc/apt/apt.conf','/etc/apt/sources.list'] -&gt;
  Exec['apt-get update'] -&gt;
  Class['vim','sudo', ..., ..., ]
  </code></pre>
  
  <p>However, here is the issue:</p>
  
  <p>If I set vim to install only if the host is a virtual machine, and the host I am performing the Puppet run on is physical, the run will fail. I assume this is because it is attempting to run Class['vim'] as per my chaining but cannot find the class declaration due to the contents of the if statement not being parsed.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>if $::is_virtual == 'true' {
      class {'vim': 
        set_default =&gt; true,
    }
  }
  </code></pre>
  
  <p>I can work around this by adding a "requires => Exec['apt-get update']" to my vim resource declaration and removing from my chain, but this feels a bit hacky. Here is what my class declaration looks like once I do this:</p>
  
  <pre><code>if $::is_virtual == 'true' {
      class {'vim':
        requires =&gt; Exec['apt-get update'],
        set_default =&gt; true,
    }
  }
  </code></pre>
  
  <p>Does anybody have any other methods of dealing with such ordering issues? Is there anyway I can deal with ordering classes held within conditional statements which may or may not be triggered via chaining? Any advice is appreciated. </p>