Re: [Puppet Users] Create files from array -> Duplicate declaration

280 views
Skip to first unread message

kish

unread,
Oct 10, 2012, 4:21:07 AM10/10/12
to puppet...@googlegroups.com
On Wed, Oct 10, 2012 at 1:23 PM, Patrick
<patrick....@googlemail.com> wrote:
> hello,
>
> i want to create some files with an array:
>
> class files (
> ...
> $type = [ "file1", "file2", "file3", "file4", "file5", "file5" ]
> ) {
>
>
> define rsyslog($owner = root, $group = root, $mode = 644,
> $ensure = present) {
>
> file {"/etc/rsyslog.d/$type.conf":

You could use $name here instead of $type,

> ensure => $ensure,
> owner => $owner,
> group => $group,
> mode => $mode,
> content => template('template.erb'),
> }
> }
> rsyslog { $type: }

Patrick

unread,
Oct 10, 2012, 4:31:59 AM10/10/12
to puppet...@googlegroups.com
Now puppet says  "Cannot reassign variable name..."

Patrick

unread,
Oct 10, 2012, 5:22:38 AM10/10/12
to puppet...@googlegroups.com
Fixed now :)
Just replaced $type (is used by puppet) with $logtype and used $name for the files.

But my last problem ist the template.
I'm using <%= scope.lookupvar('oevd_opendj::logtype') %> and puppet writes  file1file2file3file4
How can i resolve that?

kish

unread,
Oct 10, 2012, 6:25:33 AM10/10/12
to puppet...@googlegroups.com
On Wed, Oct 10, 2012 at 2:52 PM, Patrick
<patrick....@googlemail.com> wrote:
> Fixed now :)
> Just replaced $type (is used by puppet) with $logtype and used $name for the
> files.
>
> But my last problem ist the template.
> I'm using <%= scope.lookupvar('oevd_opendj::logtype') %> and puppet writes
> file1file2file3file4
> How can i resolve that?

You should iterate on logtype.
eg.
<% env_settings.each do |env_setting| -%>
<%= env_setting %>
<% end -%>

That should help.

Patrick

unread,
Oct 10, 2012, 7:14:34 AM10/10/12
to puppet...@googlegroups.com

Thanks.
But i think there is a problem now:
$InputFilename /opt/app/logs/<%= logtype %>

I have to replace <%= logtype %> with the current logtype
eg.
if puppet create the errors.conf file so $InputFilename should be /opt/appt/errors.
scope.lookupvar('oevd_opendj::name') %> does not work.

Patrick

unread,
Oct 10, 2012, 10:07:50 AM10/10/12
to puppet...@googlegroups.com
ok fixed now ;)
Reply all
Reply to author
Forward
0 new messages