I would to apply the roles/profiles pattern as explained by Craig Dunn and at URL https://docs.puppet.com/pe/2016.4/r_n_p_full_example.html to my modules built with the rules specified at https://docs.puppet.com/guides/module_guides/bgtm.html.
Following these rules, every component modules (like Apache, OpenLDAP) keep only init.pp class parametrized.
#
# 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.
#
}
Well, I usually use Roles/Profiles classes (like profile::apache, profile::openldap) using include-like or resource-like declaration of the component classes.
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 <| name=='::apache'|> { backend => 'ldap' }).
#
# Profile classes.
#
class profile::apache {
class { ::apache:
logfile => '.my_log',
}
}
class profile::apache::openldap inherits profile::apache {
include ::openldap
# Doesn't work with Puppet 4.
Class[::apache] {
backend => 'ldap'
}
#
# OR...
#
# Also, doesn't work with Puppet 4.
Class <| name=='::apache'|> {
backend => 'ldap'
}
}
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.
This is my old approch:
class apache::backend ($backend) inherits ::apache {
#
# Do stuff.
#
}
class profile::apache::openldap inherits profile::apache {
include ::openldap
class { ::apache::backend:
backend => 'ldap'
}
}
class profile::apache::mysql inherits profile::apache {
include ::mysql
class { ::apache::backend:
backend => 'mysql'
}
}
So, with my new style of coding, how can I apply the roles/profile pattern if I use only init.pp component class parametrized?