FAQ
Remember that a puppet manifest is not a script. You are simply
making an unordered list of resources to apply to a host. With that
in mind, a "break" statement just doesn't make sense.

I do feel your pain, though, and have struggled with the same issue
myself. It feels wrong to have most of the lines of a class indented
an extra block. Maybe you can put the conditional outside the code:

node mynode {
   if $::flag_enabled {
     include mymodule
   }
}

or even rewrite the class:

class mymodule {
   if $::flag_enabled {
     include mymodule::enabled
   } else {
     include mymodule::disabled
   }
}


- Chad
On Thu, Oct 10, 2013 at 2:13 PM, Jay wrote:
Thanks Ryan!

I'm looking for something like a "break" statement, which should not proceed
execution of following resources.

Anyway thanks for the information about future parser. Appreciate your time
in answering my question.


Thanks,

jay
On Oct 10, 2013 11:57 AM, "Ryan Coleman" wrote:

Hi Jay,

You could simplify things a little using 'unless' which acts like the
reverse of 'if'. You'd place your resources within the unless block so that
they'd only be included in your catalog if your Fact or variable evaluated
to false.
http://docs.puppetlabs.com/puppet/3/reference/lang_conditional.html#unless-statements

I suspect this isn't exactly what you're looking for I wanted to take this
opportunity to remind you that Puppet 3.2 introduced an experimental future
parser that makes it pretty simple to collect and iterate over things. Maybe
it'll help at some point down the road.
http://docs.puppetlabs.com/puppet/3/reference/lang_experimental_3_2.html

Hope that helps,
--Ryan
On Wed, Oct 9, 2013 at 6:13 PM, Jay wrote:

Hi,

I have a puppet module with more than 15 blocks of resources.. based on a
validation I want puppet to decide to continue next blocks or skip with a
warning(with out failing).

currently I am doing this with a big if block.

class mymodule {
if $::flag_enabled {
package {...}

files {...}
....
}
else
{
warning("Flag is disabled")
}
}

Is there a way to skip the module something like this?

class mymodule {

if not $::flag_enabled {
warning("Flag is disabled, skipping mymodule")
//skip executing below resources
}
package {..}
file {...}
}

Appreciate your help on this.

Regards,
Jay

--
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 puppet-users+unsubscribe@googlegroups.com.
To post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.



--
Ryan Coleman | Modules & Forge | ryanycoleman on twitter & #puppet IRC


--
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 puppet-users+unsubscribe@googlegroups.com.
To post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.
--
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 puppet-users+unsubscribe@googlegroups.com.
To post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.


--
Chad M. Huneycutt

--
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 puppet-users+unsubscribe@googlegroups.com.
To post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Discussion Posts

Previous

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 5 of 5 | next ›
Discussion Overview
grouppuppet-users @
categoriespuppet
postedOct 10, '13 at 5:59a
activeOct 10, '13 at 9:04p
posts5
users3
websitepuppetlabs.com

People

Translate

site design / logo © 2022 Grokbase