title: Puppet Roles/Profiles and init.pp class parametrized only
body: <p>I would to apply the roles/profiles pattern as explained by Craig Dunn and at URL <a href="https://docs.puppet.com/pe/2016.4/r_n_p_full_example.html" rel="nofollow noreferrer">https://docs.puppet.com/pe/2016.4/r_n_p_full_example.html</a> to my modules built with the rules specified at <a href="https://docs.puppet.com/guides/module_guides/bgtm.html" rel="nofollow noreferrer">https://docs.puppet.com/guides/module_guides/bgtm.html</a>.</p>
  
  <p>Following these rules, every component modules (like Apache, OpenLDAP) keep only init.pp class parametrized.</p>
  
  <pre><code>#
  # Component classes.
  #
  
  class apache ($logfile = '.log', $backend = $::apache::params::backend) inherits ::apache::params {
      #
      # This is the unique parametrized class.
      #
  }
  
  class apache::log inherits ::apache {
      #
      # This class inherits the params.
      #
  }
  </code></pre>
  
  <p>Well, I usually use Roles/Profiles classes (like profile::apache, profile::openldap) using include-like or resource-like declaration of the component classes.</p>
  
  <p>If I use resource-like declaration in a parent profile class (like profile::apache), and I use inherited profile (like profile::apache::openssh or profile::apache::openldap) to apply new features, i need to override the parent definition of component, but with Puppet v4 I can't override the component class declared in the parent profile (Class[::apache] { backend => 'ldap' } ) or use resource collector (Class &lt;| name=='::apache'|> { backend => 'ldap' }).</p>
  
  <pre><code>#
  # Profile classes.
  #
  
  class profile::apache {
      class { ::apache:
          logfile =&gt; '.my_log',
      }
  }
  
  class profile::apache::openldap inherits profile::apache {
      include ::openldap
  
      # Doesn't work with Puppet 4.
      Class[::apache] {
          backend =&gt; 'ldap'
      }
  
      #
      # OR...
      #
  
      # Also, doesn't work with Puppet 4.
      Class &lt;| name=='::apache'|&gt; {
          backend =&gt; 'ldap'
      }
  }
  </code></pre>
  
  <p>In the past I used parametrized component classes and in the child profile classes I could call the component classes in the direct way without override the params of init.pp of component class.</p>
  
  <p>This is my old approch:</p>
  
  <pre><code>class apache::backend ($backend) inherits ::apache {
      #
      # Do stuff.
      #
  }
  
  class profile::apache::openldap inherits profile::apache {
      include ::openldap
  
      class { ::apache::backend:
          backend =&gt; 'ldap'
      }
  }
  
  class profile::apache::mysql inherits profile::apache {
      include ::mysql
  
      class { ::apache::backend:
          backend =&gt; 'mysql'
      }
  }
  </code></pre>
  
  <p>So, with my new style of coding, how can I apply the roles/profile pattern if I use only init.pp component class parametrized?</p>