Ask Your Question

Multiple Variables in the Case Control Expression

asked 2015-02-24 07:31:03 -0500

confusedpuppet gravatar image

I've been tasked with migrating our current (and very old) CFEngine rules to Puppet (Puppet was my choice). I am very new to Puppet and I am learning as I go. Something I am running into is the way that the CFEngine rules were written, which is doing things like:

      whatever the rule is

So basically in Puppet I'm thinking that this is essentially a Case statement, saying if these cases are true, then do this rule. So my question is, would something like this work:

case $::lifecycle and $::customer and $::role {
             'qa' and 'customer1' and 'webserver {
                        package { ...........

I am defining these variables using Heira and calling them in my manifests. Would this work? Am I thinking about this the wrong way?

Thanks in advance for the help!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2015-02-24 22:19:54 -0500

GregLarkin gravatar image

Interestingly, I just answered a similar question that was asked in a slightly different way, and I think you'll both benefit from the same ideas. Here is the answer to the other question, and roles/profiles + Hiera will work for you as well:

I think you would benefit greatly from watching Craig Dunn's excellent presentation about roles and profiles found here:

With well-defined role and profile modules, combined with lookups in a Hiera hierarchical database, you will be able to achieve exactly what you're trying to do with your data and code separated and one business role assigned per node.

Hope that helps!

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2015-02-24 07:31:03 -0500

Seen: 57 times

Last updated: Feb 24 '15