On Sat, Feb 12, 2011 at 9:06 AM, flex <[email protected]> wrote:
> This is my puppet script:
> modules/redarrow/manifests/add.pp:
> define redarrow::add($type = "file") {
> file { "/etc/redarrow.conf/$name.conf":
> owner => "root",
> group => "root",
> mode => 644,
> source => $type ? {
> "file" => "puppet:///modules/$caller_module_name/redarrow.conf",
> default => undef,
> },
> content => $type ? {
> "template" => template("$caller_module_name/redarrow.erb"),
> default => undef,
> },
> }
> }
> modules/portage/manifests/init.pp:
> redarrow::add {test_portage: }
> Result:
> (/Stage[main]/Portage/Redarrow::Add[test_portage]/File[/etc/redarrow.conf/test_portage.conf])
> Could not evaluate: Error 400 on SERVER: Invalid module name; module names
> must be alphanumeric (plus '-'), not 'redarrow.conf' Could not retrieve file
> metadata for puppet:///modules//redarrow.conf: Error 400 on SERVER: Invalid
> module name; module names must be alphanumeric (plus '-'), not
> 'redarrow.conf' at /home/flex/puppet/modules/redarrow/manifests/add.pp:14
What version of puppet are you using? This is limited to 2.6.x.
> It seems that the variable $caller_module_name is not set, then i found
> another stange thing, i got what i want like this:
> define redarrow::add($module = $name, $type = "file") {
> file { "/etc/redarrow.conf/$name.conf":
> owner => "root",
> group => "root",
> mode => 644,
> source => $type ? {
> "file" => "puppet:///modules/$module/redarrow.conf",
> default => undef,
> },
> content => $type ? {
> "template" => template("$module/redarrow.erb"),
> default => undef,
> },
> }
> }
> the $name in varaible list of the define is not the same as the $name below
> which is the resource name, it is this a bug or a hidden feature?
$name is in scope within {..}. However this is fixed in 5061 which
will be released in 2.6.5 (currently rc2):
http://projects.puppetlabs.com/issues/5061
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.