Adding more values into parameters ex post

35 views
Skip to first unread message

Vlastimil Holer

unread,
Sep 25, 2008, 2:02:30 PM9/25/08
to Puppet Users
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

Luke Kanies

unread,
Sep 26, 2008, 12:49:30 AM9/26/08
to puppet...@googlegroups.com

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

Jeroen van Meeuwen (GMail)

unread,
Sep 26, 2008, 5:45:19 AM9/26/08
to puppet...@googlegroups.com
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 => [ "kan...@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

Reply all
Reply to author
Forward
0 new messages