2

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 :

  1. deploy all modules for specified nodes
  2. 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.

  • 1
    Why are you explicitly doing a fail()? What benefit do you think that gives you? If you use fail(), then puppet is going to fail. Perhaps what you really need to do is log a warning()/notice()? – Zoredache Feb 28 '14 at 17:35
1

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 an info and/or debug message). No need to fail it explicitly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.