title: Puppet: Passing parameters through classes
body: <p>This is a follow on to my earlier question about <a href="https://stackoverflow.com/questions/21151902/puppet-stopping-service-on-individual-nodes/21153390">parameterized classes</a>.  Following on that example a little further, I want to be able to pass running or stopped into the service, but when I add the service to a box, I don't use "include poodle::service", I use "include poodle" which does all of the other stuff Poodle requires to be installed.</p>
  
  <p>So, can I pass the variable along to the service class like this:</p>
  
  <pre><code># SITE.PP
  node 'tweedle.example.com' {
      include basicstuff
      include poodle
  }
  node 'beetle.example.com' {
      include basicstuff
      class { 'poodle':
          $ensure =&gt; 'stopped'
      }
  }
  
  ## POODLE MODULE, manifests/init.pp
  class poodle ( $ensure = 'running' ) {
      class {'poodle::install': }
      class {'poodle::config': }
      class {'poodle::service': 
          ensure =&gt; $ensure
      }
      Class ['poodle::install'] -&gt; Class ['poodle::config'] ~&gt; Class ['poodle::service']
  }
  
  ...
  
  class poodle::service ( $ensure ) {
      service {'poodle':
          ensure     =&gt; $ensure,
          enable     =&gt; true,
          restart    =&gt; "/etc/init.d/poodle stop &amp;&amp; sleep 5 &amp;&amp; /etc/init.d/poodle start",
          subscribe  =&gt; File['/opt/poodle/poodle.py'],
      }
  }
  </code></pre>
  
  <p>Or should I put the parameter directly on the service class and the explicitly call both the Poodle class and Poodle's service class like this:</p>
  
  <pre><code># SITE.PP
  node 'tweedle.example.com' {
      include basicstuff
      include poodle
  }
  node 'beetle.example.com' {
      include basicstuff
      include poodle
      class { 'poodle::service':
          $ensure =&gt; 'stopped'
      }
  }
  
  ## POODLE MODULE, manifests/init.pp
  class poodle {
      class {'poodle::install': }
      class {'poodle::config': }
      class {'poodle::service': 
          ensure =&gt; $ensure
      }
      Class ['poodle::install'] -&gt; Class ['poodle::config'] ~&gt; Class ['poodle::service']
  }
  
  ...
  
  class poodle::service ( $ensure = 'running') {
      service {'poodle':
          ensure     =&gt; $ensure,
          enable     =&gt; true,
          restart    =&gt; "/etc/init.d/poodle stop &amp;&amp; sleep 5 &amp;&amp; /etc/init.d/poodle start",
          subscribe  =&gt; File['/opt/poodle/poodle.py'],
      }
  }
  </code></pre>
  
  <p>Or is adding the parameter to the service class and including ONLY that enough, because the service class has dependencies, like this:</p>
  
  <pre><code># SITE.PP
  node 'tweedle.example.com' {
      include basicstuff
      include poodle
  }
  node 'beetle.example.com' {
      include basicstuff
      class { 'poodle::service':
          $ensure =&gt; 'stopped'
      }
  }
  
  ## POODLE MODULE, manifests/init.pp
  class poodle {
      class {'poodle::install': }
      class {'poodle::config': }
      class {'poodle::service': 
          ensure =&gt; $ensure
      }
      Class ['poodle::install'] -&gt; Class ['poodle::config'] ~&gt; Class ['poodle::service']
  }
  
  ...
  
  class poodle::service ( $ensure = 'running') {
      service {'poodle':
          ensure     =&gt; $ensure,
          enable     =&gt; true,
          restart    =&gt; "/etc/init.d/poodle stop &amp;&amp; sleep 5 &amp;&amp; /etc/init.d/poodle start",
          subscribe  =&gt; File['/opt/poodle/poodle.py'],
      }
  }
  </code></pre>
  
  <p>What is the right course and best practice here?  Thanks in advance!</p>