I''ve been through the documentation and for the life of me I can''t figure out how to implement if not defined. Puppet doesn''t like the ! operator. I tried this: if ! $var { do_something } But that barfs. My current working kludge is: if $var { notify( yadda_yadda ) } else { do_something } If you can de-kludge me, I''d appreciate it... --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Jeff wrote:> I''ve been through the documentation and for the life of me I can''t > figure out how to implement if not defined. Puppet doesn''t like the ! > operator. I tried this: >There is no "if not". Only a Boolean if/else without any equality, comparisons or other operators. See: http://reductivelabs.com/trac/puppet/wiki/LanguageTutorial#conditionals Regards James Turnbull - -- Author of: * Pulling Strings with Puppet (http://www.amazon.com/gp/product/1590599780/) * Pro Nagios 2.0 (http://www.amazon.com/gp/product/1590596099/) * Hardening Linux (http://www.amazon.com/gp/product/1590594444/) -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFIymO89hTGvAxC30ARAhJ9AJ4/NGEpACknw3Igjjmt615pbbv9EQCgqajk yfyuEJnui1+eW+6vKKENDzo=/l0C -----END PGP SIGNATURE----- --~--~---------~--~----~------------~-------~--~----~ 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 Sep 12, 8:42 am, James Turnbull <ja...@lovedthanlost.net> wrote:> -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Jeff wrote: > > I''ve been through the documentation and for the life of me I can''t > > figure out how to implement if not defined. Puppet doesn''t like the ! > > operator. I tried this: > > There is no "if not". Only a Boolean if/else without any equality, > comparisons or other operators. > > See: > > http://reductivelabs.com/trac/puppet/wiki/LanguageTutorial#conditionals > > Regards > > James TurnbullThanks. What''s a best practice for this? I really don''t want to set notifys. Should I use a dummy var? if $var { $haha = "papa" } else { $var = $globals::var } Or maybe do a redundant assignment so the intent is clear: if $var { $var = $var } else { $var = $globals::var } Cheers, Jeff --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I at least, have gone the dummy var route -L --~--~---------~--~----~------------~-------~--~----~ 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 Sep 12, 1:44 pm, Jeff <joesi...@gmail.com> wrote:> On Sep 12, 8:42 am, James Turnbull <ja...@lovedthanlost.net> wrote: > > -----BEGIN PGP SIGNED MESSAGE----- > > Hash: SHA1 > > > Jeff wrote: > > > I''ve been through the documentation and for the life of me I can''t > > > figure out how to implement if not defined. Puppet doesn''t like the ! > > > operator. I tried this: > > > There is no "if not". Only a Boolean if/else without any equality, > > comparisons or other operators. > > > See: > > >http://reductivelabs.com/trac/puppet/wiki/LanguageTutorial#conditionals > > > Regards > > > James Turnbull > > Thanks. What''s a best practice for this? I really don''t want to set > notifys. Should I use a dummy var?Couldn''t you just use a comment? Something like this: if $var { ## This is here because Puppet doesn''t have a NOT operator } else { $var = $globals::var } BTW: What''s with the $globals::var? Am I not the only one who is working around the variable scope problem. Is there a best practice for *that*? :) Later... Richard --~--~---------~--~----~------------~-------~--~----~ 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 Sep 13, 7:43 am, Richard <rnh...@gmail.com> wrote:> On Sep 12, 1:44 pm, Jeff <joesi...@gmail.com> wrote: > > Couldn''t you just use a comment? Something like this: > > if $var { > ## This is here because Puppet doesn''t have a NOT operator} else { > > $var = $globals::var > > } >That doesn''t work. Puppet needs a statement in the if clause. After (prolly too much) preponderance I''m going with this: if $java_home { $java_home = $java_home } else { $java_home = $globals::java_home } Why? The dummy var is only going to cause me to scratch my head in the future and confuse other members of my team. While the above code *seems* strange, its intent is clear. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi> That doesn''t work. Puppet needs a statement in the if clause. > > After (prolly too much) preponderance I''m going with this: > > if $java_home { > $java_home = $java_home > } else { > $java_home = $globals::java_home > } > > Why? The dummy var is only going to cause me to scratch my head in the > future and confuse other members of my team. While the above code > *seems* strange, its intent is clear.you can also use a info("don''t assign var xy") statement. this is what i normally do. greets pete --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
2008/9/15 Jeff <joesiege@gmail.com>:> > On Sep 13, 7:43 am, Richard <rnh...@gmail.com> wrote: >> On Sep 12, 1:44 pm, Jeff <joesi...@gmail.com> wrote: >> >> Couldn''t you just use a comment? Something like this: >> >> if $var { >> ## This is here because Puppet doesn''t have a NOT operator} else { >> >> $var = $globals::var >> >> } >> > > That doesn''t work. Puppet needs a statement in the if clause. > > After (prolly too much) preponderance I''m going with this: > > if $java_home { > $java_home = $java_home > } else { > $java_home = $globals::java_home > } > > Why? The dummy var is only going to cause me to scratch my head in the > future and confuse other members of my team. While the above code > *seems* strange, its intent is clear.I know it''s not the clean solution you want, but you could comment the code so you remember, and your team will know why the variable is there. Kent --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jeff wrote:> I''ve been through the documentation and for the life of me I can''t > figure out how to implement if not defined. Puppet doesn''t like the ! > operator. I tried this: > > if ! $var { > do_something > }I have a puppet patch that implements this feature. It semmes to work (I performed only minimal testing), and I think I''ll submit it on the dev list soon for review, when the rspec tests will be finalized. If you want to use it, it is available in the wip/ifnot branch in my githib repository. http://github.com/masterzen/puppet/commits/wip/ifnot/ It might even evoluate in a full-fledged if ''expression'' (ie combination of ==,!=, and/or...) if I find the motivation and the spare time :-) Let me know if there is interest for this. -- Brice Figureau Days of Wonder http://www.daysofwonder.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 Mon, Sep 15, 2008 at 1:41 PM, Brice Figureau < brice-puppet@daysofwonder.com> wrote:> If you want to use it, it is available in the wip/ifnot branch in my > githib repository. > http://github.com/masterzen/puppet/commits/wip/ifnot/ > > It might even evoluate in a full-fledged if ''expression'' (ie combination > of ==,!=, and/or...) if I find the motivation and the spare time :-) > > Let me know if there is interest for this. >I often find I''d like to be able to do: if $foo == "bar" and if $foo and $bar and the subsequent variants. I mean you can always do it with case statements, but this would be clearer to read and write. -- Nigel Kersten Systems Administrator Tech Lead - MacOps --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Brice, I think that you''re going to see a LOT of people welcoming this feature. +1 Trevor On Mon, Sep 15, 2008 at 4:41 PM, Brice Figureau <brice-puppet@daysofwonder.com> wrote:> > Jeff wrote: >> I''ve been through the documentation and for the life of me I can''t >> figure out how to implement if not defined. Puppet doesn''t like the ! >> operator. I tried this: >> >> if ! $var { >> do_something >> } > > I have a puppet patch that implements this feature. > It semmes to work (I performed only minimal testing), and I think I''ll > submit it on the dev list soon for review, when the rspec tests will be > finalized. > > If you want to use it, it is available in the wip/ifnot branch in my > githib repository. > http://github.com/masterzen/puppet/commits/wip/ifnot/ > > It might even evoluate in a full-fledged if ''expression'' (ie combination > of ==,!=, and/or...) if I find the motivation and the spare time :-) > > Let me know if there is interest for this. > -- > Brice Figureau > Days of Wonder > http://www.daysofwonder.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 -~----------~----~----~----~------~----~------~--~---
> It might even evoluate in a full-fledged if ''expression'' (ie combination > of ==,!=, and/or...) if I find the motivation and the spare time :-)Actually in some ways I DON''T want to see full comparison operators. Why? Because it makes testing much hard to ensure the code is correct. -L -- Larry Ludwig Empowering Media 1-866-792-0489 x600 Fully Managed VPSes http://www.hostcube.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 -~----------~----~----~----~------~----~------~--~---
Yes, but.... And the but is that it can dramatically reduce your execution path. You don''t *have* to use them. Trevor On Tue, Sep 16, 2008 at 11:45 AM, Larry Ludwig <larrylud@gmail.com> wrote:> > >> It might even evoluate in a full-fledged if ''expression'' (ie combination >> of ==,!=, and/or...) if I find the motivation and the spare time :-) > > Actually in some ways I DON''T want to see full comparison operators. > Why? Because it makes testing much hard to ensure the code is correct. > > -L > > -- > Larry Ludwig > Empowering Media > 1-866-792-0489 x600 > Fully Managed VPSes > http://www.hostcube.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 -~----------~----~----~----~------~----~------~--~---