Ask Your Question

problem with loouk when default should be an array

asked 2017-05-15 11:44:10 -0600

pabolitox gravatar image


puppet --version 4.9.4

I need to configure a resource that will take a value from an array in hiera. I would like to implement a default value with a lookup in case this value is not configured:

resource in class called cron.pp

class yumcron::cron inherits yumcron {
cron { 'yum-cron':
      command => 'yum -y update',
      user    => 'root',
      hour    => [1,3,4,6,7],
      minute  => '0',
      month   => "$cron_month",

and in init.pp for class yumcron

$cron_month = lookup({ name => 'yumcron::cron:cron_month', default_value => "[1,6]" }),

It won't work as the default seems not an array? the output is:

[root@perif1 ~]# puppet agent -tv --environment=temp
Info: Using configured environment 'temp'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Info: Caching catalog for perif1
Error: Failed to apply catalog: Parameter month failed on Cron[yum-cron]: [1,6] is not a valid month at /etc/puppetlabs/code/environments/temp/modules/yumcron/manifests/cron.pp:22
[root@perif1 ~]#

Can anyone please help me here?

Regards Pablo

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-05-16 11:38:52 -0600

smarlow gravatar image

Your example is very nearly correct. You just need to remove the quotes around "[1,6]", since that makes it a string rather than an array. So, for example:

$cron_month = lookup({ name => 'yumcron::cron:cron_month', default_value => [1,6] })

should work correctly.

edit flag offensive delete link more


you are right smarlow! thanks a million for the help :)

pabolitox gravatar imagepabolitox ( 2017-05-16 15:53:16 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2017-05-15 11:37:47 -0600

Seen: 38 times

Last updated: May 16 '17