using array parameters with inherited parameterized classes

791 views
Skip to first unread message

Shantanu

unread,
Apr 12, 2012, 2:09:45 PM4/12/12
to Puppet Users

I am trying to use an inherited array parameter in a parameterized
class as follows:

<puppet>
class params{
$packages = $operatingsystem ? {
Centos => ['scons','bzip2'],
Ubuntu => ['scons','bzip2'],
# Ubuntu => 'scons',
}
}

class depacks(
$packages = "$params::packages"
) inherits params {

package{ $packages:
ensure => 'present',
}
}

class {"depacks": }
</puppet>


* It's failing with following error:
<error>
err: /Stage[main]/Depacks/Package[sconsbzip2]/ensure: change from
purged to present failed: Execution of '/usr/bin/apt-get -q -y -o
DPkg::Options::=--force-confold install sconsbzip2' returned 100:
Reading package lists...
Building dependency tree...
Reading state information...
E: Couldn't find package sconsbzip2
</error>

* It works fine if I override the inherited array parameter while
calling/evaluating the class:
<puppet>
class {"depacks":
packages => ['scons','bzip2'],
}
</puppet>

I am using Puppet 2.6.14 with Ruby 1.8.7. The error occurs on both
Ubuntu and CentOS systems.

Am I missing something here? Any pointers will be really helpful.

--
Thanks,
Shantanu

Craig Dunn

unread,
Apr 13, 2012, 5:07:36 AM4/13/12
to puppet...@googlegroups.com

> class depacks(
> $packages = "$params::packages"
> ) inherits params {
>
> package{ $packages:

Putting quotes around $params::packages is making $packages a string
rather than an array. Remove the quotes and it should work

Regards
Craig

--
Craig Dunn | http://www.craigdunn.org
Yahoo/Skype: craigrdunn | Twitter: @crayfishX

Shantanu

unread,
Apr 13, 2012, 10:25:25 AM4/13/12
to Puppet Users
On Apr 13, 4:07 am, Craig Dunn <cr...@craigdunn.org> wrote:
> > class depacks(
> >    $packages = "$params::packages"
> > ) inherits params {
>
> >    package{ $packages:
>
> Putting quotes around $params::packages is making $packages a string
> rather than an array.  Remove the quotes and it should work
>


Thanks for pointing it out Craig. It's working now.

--
Shantanu
Reply all
Reply to author
Forward
0 new messages