I''m trying to exclude uploading a file to certain hosts. In nodes.pp I have: node "x.example.com" inherits basenode { $skip_file = true } In the module''s init.pp I have: file {"/path/to/file": if $skip_file { noop => true } owner => root, . . I get an error: err: Could not retrieve catalog: Could not parse for environment production: Syntax error at ''if''; expected ''}'' at ... Is this a reasonable way of excluding one file from certain hosts? Also, I clearly do not understand the syntax for ''if'' (and it''s very hard to Google "puppet if statement"), so what am I doing incorrectly? 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 -~----------~----~----~----~------~----~------~--~---
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Keith Edmunds wrote:> I''m trying to exclude uploading a file to certain hosts. In nodes.pp I > have: > > node "x.example.com" inherits basenode { > $skip_file = true > } > > In the module''s init.pp I have: > > file {"/path/to/file": > if $skip_file { > noop => true > } > owner => root, > . > . > > I get an error: > > err: Could not retrieve catalog: Could not parse for environment > production: Syntax error at ''if''; expected ''}'' at ... > > Is this a reasonable way of excluding one file from certain hosts? Also, I > clearly do not understand the syntax for ''if'' (and it''s very hard to > Google "puppet if statement"), so what am I doing incorrectly? >You can''t use if/else in a resource. Have a read of: 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 iD8DBQFJx3G49hTGvAxC30ARAj8+AJ9jek7EArJG3apQeDHtzNmCeR7wQgCfXPBv oy9IzCuUv00wz/wsjV8fcf4=7rcV -----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 -~----------~----~----~----~------~----~------~--~---
Hi> node "x.example.com" inherits basenode { > $skip_file = true > } > > In the module''s init.pp I have: > > file {"/path/to/file": > if $skip_file { > noop => true > } > owner => root, > . > . > > I get an error: > > err: Could not retrieve catalog: Could not parse for environment > production: Syntax error at ''if''; expected ''}'' at ... > > Is this a reasonable way of excluding one file from certain hosts? Also, I > clearly do not understand the syntax for ''if'' (and it''s very hard to > Google "puppet if statement"), so what am I doing incorrectly?you can''t use if statements this way. use a selector instead. So something like: file {"/path/to/file": noop => $skip_file ? { true => true, default => false }, owner => root, .... cheers 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 -~----------~----~----~----~------~----~------~--~---
> You can''t use if/else in a resource. > > Have a read of: > > http://reductivelabs.com/trac/puppet/wiki/LanguageTutorial#conditionalsI had actually read that page, and I''ve just read it again. I can''t see any mention of the fact that I can''t use if/else in a resource, but I may have just missed it.> you can''t use if statements this way. use a selector instead. So > something like: > > file {"/path/to/file": > noop => $skip_file ? { > true => true, > default => false > }, > owner => root,Thanks Peter, that''s what I needed. Keith --~--~---------~--~----~------------~-------~--~----~ 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 Keith Edmunds wrote:>> You can''t use if/else in a resource. >> >> Have a read of: >> >> http://reductivelabs.com/trac/puppet/wiki/LanguageTutorial#conditionals > > I had actually read that page, and I''ve just read it again. I can''t see > any mention of the fact that I can''t use if/else in a resource, but I may > have just missed it. >"Puppet currently supports two types of conditionals: in-statement and around statements. Selectors '''''''''''''''''' We call the in-statement conditionals ``selectors``, as they are essentially a select-style operator, which support the use of ``default`` to specify a default value::" But I concur - that''s not overly clear if you don''t know what in-statement means. 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 iD8DBQFJx3rw9hTGvAxC30ARAtFdAKCjXPs/UQDfddwSDc3SWW5PqU5rTgCcDbld FDGOxU1Y1n3oM13gMh8dRCg=ma3w -----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 -~----------~----~----~----~------~----~------~--~---
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Keith Edmunds wrote:> I had actually read that page, and I''ve just read it again. I can''t see > any mention of the fact that I can''t use if/else in a resource, but I may > have just missed it. >Please let me know if this update makes more sense: http://reductivelabs.com/trac/puppet/wiki/LanguageTutorial#conditionals Thanks 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 iD8DBQFJx3vm9hTGvAxC30ARArj9AKDMnRqGTYiXO/KCAeGzrmdmAere+gCfUsoy kGqlcRxIGE/fvoVi0KHAKEI=rCJ3 -----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 -~----------~----~----~----~------~----~------~--~---
> Please let me know if this update makes more sense:It does, and thank you for updating the page. I think it would be further improved by defining what an "in-statement" and an "around statement" are - the latter, particularly, sounds somewhat nebulous. Perhaps, for now, a little emphasis to differentiate the terms from the rest of the sentence: Puppet currently supports two types of conditionals: <i>in-statement</i> (or inside a resource) and <i>around statements</i>. The only in-statement conditional currently is the <i>selector</i>, and there are two around statement conditionals: <i>case</i> and an <i>if/else structure</i>. But thank you again for a quick enhancement to the documentation. Keith --~--~---------~--~----~------------~-------~--~----~ 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 Keith Edmunds wrote:>> Please let me know if this update makes more sense: > > It does, and thank you for updating the page. > > I think it would be further improved by defining what an "in-statement" > and an "around statement" are - the latter, particularly, sounds somewhat > nebulous. > > Perhaps, for now, a little emphasis to differentiate the terms from the > rest of the sentence: > > Puppet currently supports two types of conditionals: <i>in-statement</i> > (or inside a resource) and <i>around statements</i>. The only in-statement > conditional currently is the <i>selector</i>, and there are two around > statement conditionals: <i>case</i> and an <i>if/else structure</i>. > > But thank you again for a quick enhancement to the documentation. >Keith Feel free to jump in and edit yourself! It''s a wiki after all - all help appreciated. Cheers James - -- 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 iD8DBQFJyJ6I9hTGvAxC30ARAosmAJ9zHfrE5B4SJTIrHPs3DdNvN4ofJQCgpMkp NKluMLS5SyYT/QeLJccx9p0=MPBR -----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 -~----------~----~----~----~------~----~------~--~---