I'm having some trouble understanding one of many Puppet logic mechanisms : the module failing scenario.
I have multiple modules doing various things on a set of differences nodes and I want to implement the following scenario :
- deploy all modules for specified nodes
- if a module execution fails, only fail this module but keep applying other modules
I wrote something along these lines in my test module (yum
) :
init.pp
:
class yum {
case $operatingsystem {
/(RedHat|CentOS)/ : { include yum:config }
default: { include yum:fail }
}
}
class yum::config {
debug("[${fqdn}] Deploying yum.conf file")
#DEPLOY YUM.CONF CODE
}
class yum:fail {
fail("[${fqdn}] This module is only for RedHat or CentOS")
}
And in my site.pp
manifest :
node 'redhat', 'centos', 'debian' {
include yum
include motd
}
The problem is, if the operatingsystem
case is not satisfied by a given node (debian
in this instance), it will fail all consecutive modules (motd
will NOT be applied).
So the question is : what am I doing wrong in this case ?
PS: Keep in mind that I'm still in the process of learning Puppet best practices and, as such, I am not pretending my code is spotless.
Best Answer
Silly me. It seems indeed that, considering my module structure, I just have to do nothing once we are in the child class
yum::fail
(maybe just put aninfo
and/ordebug
message). No need to fail it explicitly.