Vlastimil Holer
2008-Sep-25 18:02 UTC
[Puppet Users] Adding more values into parameters ex post
Hi, I''m trying to follow the Language tutorial (http://reductivelabs.com/ trac/puppet/wiki/LanguageTutorial#classes) and the feature with ''+>'' operator. I would like to reach functionality shown in this example: ----- file { ''/tmp/test1'': ensure => file; ''/tmp/test2'': ensure => file; ''/tmp/test3'': ensure => file, require => File[''/tmp/test1'']; } File[''/tmp/test3''] { require +> File[''/tmp/test2''] } ----- I want to modify ''require'' parametr ex post, but I get only error message: "Parameter ''require'' is already set on File[/tmp/test3] at /tmp/puppet- test/test.pp:8; cannot redefine at /tmp/puppet-test/test.pp:11 on node xyz" If I don''t define first ''require'', it works. I have tried it with: puppet-0.24.5-1.fc9.noarch puppet-0.24.4-1.el5 on Fedora 9 and CentOS 5.2. Can I do it somehow? Thank you for any help, Vlastimil Holer --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Luke Kanies
2008-Sep-26 04:49 UTC
[Puppet Users] Re: Adding more values into parameters ex post
On Sep 25, 2008, at 1:02 PM, Vlastimil Holer wrote:> > Hi, > > I''m trying to follow the Language tutorial (http://reductivelabs.com/ > trac/puppet/wiki/LanguageTutorial#classes) and the feature with ''+>'' > operator. I would like to reach functionality shown in this example: > > ----- > file { > ''/tmp/test1'': > ensure => file; > ''/tmp/test2'': > ensure => file; > ''/tmp/test3'': > ensure => file, > require => File[''/tmp/test1'']; > } > > File[''/tmp/test3''] { require +> File[''/tmp/test2''] } > ----- > > I want to modify ''require'' parametr ex post, but I get only error > message: > "Parameter ''require'' is already set on File[/tmp/test3] at /tmp/ > puppet- > test/test.pp:8; cannot redefine at /tmp/puppet-test/test.pp:11 on node > xyz" > > If I don''t define first ''require'', it works. > > I have tried it with: > puppet-0.24.5-1.fc9.noarch > puppet-0.24.4-1.el5 > on Fedora 9 and CentOS 5.2. > > Can I do it somehow? Thank you for any help,Appending and overriding attributes can only be done in subclasses, not in the same scope that the attribute is set. I''m not actually convinced this makes a ton of sense in the current parser, now that I think of it, though... -- Don''t hit at all if it is honorably possible to avoid hitting; but never hit soft! -- Theodore Roosevelt --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.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 -~----------~----~----~----~------~----~------~--~---
Jeroen van Meeuwen (GMail)
2008-Sep-26 09:45 UTC
[Puppet Users] Re: Adding more values into parameters ex post
Luke Kanies wrote:> Appending and overriding attributes can only be done in subclasses, > not in the same scope that the attribute is set. > > I''m not actually convinced this makes a ton of sense in the current > parser, now that I think of it, though... >FWIW, the following does not appear to work (inside a module called mail, it''s manifests/init.pp): class mail { mailalias { "root": ensure => absent, notify => Exec["newaliases"] } exec { "newaliases": command => "newaliases", refreshonly => true } class aliases inherits mail { define root ( $enable = true, $recipient = [ ] ) { Mailalias["root"] { enable => $enable ? { false => absent, default => present }, recipient +> $recipient } } } } (Note how by default it sets the root mailalias to absent, which is equivalent to the default "#root: marc" line in /etc/aliases) I deliberately used a subclass "mail::aliases" because changing a parameter to a type within the same scope doesn''t work; I wanted to use something like the following to set the root mail alias: node ''node1.domain.tld'' { include mail::aliases mail::aliases::root { "$fqdn": enable => true, recipient => [ "kanarip@kanarip.com" ] } } But it does not appear to work either; the error message is something like "Only subclasses can override ...". Dunno whether this is expected behavour though? Kind regards, Jeroen van Meeuwen -kanarip --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---