On Friday, 26 August 2016 07:58:39 UTC+1, Martin Alfke wrote:
>
> Hi Henrik,
> > On 26 Aug 2016, at 00:25, Henrik Lindberg <[email protected]
> <javascript:>> wrote:
> >
> >
> > The recommended approach is to always use 'include()' to include the
> classes (you can include the same class any number of times). You then use
> data binding (that is, automatic binding of class parameters to values) by
> storing the parameters in hiera.
>
> is include() still the recommended way?
> Or should we start using contain()?
>
Depends on if you want to ensure a class relationship or not. I would say
containing classes in other modules is bad design, and soon you'll end up
creating dependency loops. I would only ever contain a class that's in the
same module, a common pattern would be:
class drupal {
contain drupal::config
contain drupal::install
Class[drupal::install] -> Class[drupal::config]
}
https://docs.puppet.com/puppet/latest/reference/lang_containment.html
To comment on the original poster's problem, if Class[My_drupal_class] is
creating Class[Apache] using the resource like syntax, then
Class[My_drupal_class] is not designed very well. In practice Drupal does
not depend on Apache. It's a set of PHP files and a MySQL database, and it
may or may not have Apache serve it's PHP (it could be another web server).
If Class[My_drupal_class] is intended to be used under Apache, then it
should create it's own Apache::Vhost resource (assuming Puppetlabs' Apache
module) and that's it. Then somewhere else in your manifest, you will
instantiate Class[Apache] with all the settings you want. This way you
could even run other Apache services on the same Drupal machine, or, move
Drupal to any other Apache server. Here's a sketch of a role/profile
approach I would use:
class role::mywebserver {
class { 'apache':
all my options...
}
contain profile::drupal
contain profile::some_other_apache_service
Class[apache] -> Class[profile::drupal]
}
class profile::drupal {
class { 'my_drupal_class':
option => 'something',
parameter => 'something else',
woof => 'meow',
}
apache::vhost { 'my_drupal_vhost':
listen => 80,
docroot => '/opt/drupal',
otherparams => 'I can't remember',
}
}
In the above, profile::drupal is portable to any other role / node.
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/196f3238-edef-46d3-8b09-07f0f3e9621d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.