if $enabled != undef {
do it
}
$enabled will have true or false or nothing/undef and it will be used
for multiple things but I don''t want to do anything if it is
''undef''.
Does this make sense?
Thanks.
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to
puppet-users+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.
On 04/28/2011 12:46 PM, Roberto Bouza wrote:> if $enabled != undef { > do it > } > > $enabled will have true or false or nothing/undef and it will be used > for multiple things but I don''t want to do anything if it is ''undef''.try: if $enabled { do it } if $enabled is false or undef then it won''t do it. -- Pietro Monteiro Senior Developer DECK Monitoring 115 W 8th Ave. Eugene, Oregon 97401 Office: 541-343-0110 www.deckmonitoring.com -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
That is the problem. :-)
If its false/true I need to do stuff like
if $enabled != undef {
class { ''doit'': enabled => $enabled } # This here will use
true or
false to delete or add files for example
}
But if it''s undef I don''t even want to include the class.
I''m guessing that if this is not a valid used syntax then I''ll
have to
do something like:
if $enabled == true or $enabled == false {
}
But If its supported/valid then better.
Thank you.
On Apr 28, 12:52 pm, Pietro Monteiro <pie...@deckmonitoring.com>
wrote:> On 04/28/2011 12:46 PM, Roberto Bouza wrote:
>
> > if $enabled != undef {
> > do it
> > }
>
> > $enabled will have true or false or nothing/undef and it will be used
> > for multiple things but I don''t want to do anything if it is
''undef''.
>
> try:
>
> if $enabled {
> do it
>
> }
>
> if $enabled is false or undef then it won''t do it.
>
> --
> Pietro Monteiro
> Senior Developer
> DECK Monitoring
> 115 W 8th Ave. Eugene, Oregon 97401
> Office: 541-343-0110www.deckmonitoring.com
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to
puppet-users+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.
On 04/28/2011 01:01 PM, Roberto Bouza wrote:> That is the problem. :-) > > If its false/true I need to do stuff like > > if $enabled != undef { > class { ''doit'': enabled => $enabled } # This here will use true or > false to delete or add files for example > }then try: if $foo == true or $foo == false { class { ''doit'': enabled => $enabled } } or: case $foo { true,false: { class { ''doit'': enabled => $enabled } } } -- Pietro Monteiro Senior Developer DECK Monitoring 115 W 8th Ave. Eugene, Oregon 97401 Office: 541-343-0110 www.deckmonitoring.com -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Thu, Apr 28, 2011 at 1:01 PM, Roberto Bouza <bouzafr@gmail.com> wrote:> That is the problem. :-) > > If its false/true I need to do stuff like > > if $enabled != undef { > class { ''doit'': enabled => $enabled } # This here will use true or > false to delete or add files for example > } >undef, '''', false all evaluate to false. However the string "false" evaluates to true.> But if it''s undef I don''t even want to include the class. > > I''m guessing that if this is not a valid used syntax then I''ll have to > do something like: > > if $enabled == true or $enabled == false { > } >I''m not sure it''s a good idea to take advantage of this behavior, but in theory you can set $enabled="true"|"false" and compare the string value in the class instead of true, false. Thanks, Nan -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On 04/28/2011 10:01 PM Roberto Bouza wrote:> That is the problem. :-) > > If its false/true I need to do stuff like > > if $enabled != undef { > class { ''doit'': enabled => $enabled } # This here will use true or > false to delete or add files for example > } > > But if it''s undef I don''t even want to include the class.Maybe this way? $foo = "true" if $foo in [ "true", "false" ] { alert "foo!" } [12:41:25] $ puppet apply test.pp alert: Scope(Class[main]): foo! ;)
Thanks for the help. I opted to used strings on the variables, which to me is not good!!! (not a proper defined language) I should be able to use the types true, false and should be able to check for the nothing/nil/undef variable which I can''t and I think is bad. Once again, thanks for your help. On Apr 29, 6:14 am, Jan <j...@agetty.de> wrote:> On 04/28/2011 10:01 PM Roberto Bouza wrote: > > > That is the problem. :-) > > > If its false/true I need to do stuff like > > > if $enabled != undef { > > class { ''doit'': enabled => $enabled } # This here will use true or > > false to delete or add files for example > > } > > > But if it''s undef I don''t even want to include the class. > > Maybe this way? > > $foo = "true" > > if $foo in [ "true", "false" ] { > alert "foo!" > > } > > [12:41:25] $ puppet apply test.pp > alert: Scope(Class[main]): foo! > > ;) > > signature.asc > < 1KViewDownload-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On 04/30/2011 01:52 AM, Roberto Bouza wrote:> Thanks for the help. > > I opted to used strings on the variables, which to me is not good!!! > (not a proper defined language) > > I should be able to use the types true, false and should be able to > check for the nothing/nil/undef variable which I can''t and I think is > bad.You should raise a bug then. I concur, the boolean semantics can be less than optimal. Cheers, Felix -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.