Hi,

You shouldn't be trying with a variable. Here's what you should
probably be doing instead :

/etc/puppet/modules/sensor/manifests/listner.pp
define sensor::listner ( $config = 'this is the generic default' ) {
    notify { $config : }
}

/etc/puppet/manifests/site.pp
Sensor::Listener { config => 'asdf' }
node 'dev' {
   sensor::listner {"test_sensor":}
}

This would show 'asdf' for all of your nodes, since the default would
be set inside site.pp, thus inherited globally.

Matthias

Ole Morten Grodås <grod...@gmail.com> wrote:

> How can I use a variable for setting a default parameter in a defined
> type? The example below illustrates my problem, the $config parameter
> ends up being "undef" while I was expecting it to have the "asdf"
> value. Any comments or suggestions would be appreciated
> 
> 
> /etc/puppet/modules/sensor/manifests/listner.pp
> $myvar="asdf"
> define sensor::listner ( $config = $myvar ) {
>     notify { $config : }
> }
> 
> 
> /etc/puppet/manifests/site.pp
> node 'dev' {
>    sensor::listner {"test_sensor":}
> }
> 
> 
> root@dev:/home/ole# puppet agent --test
> Info: Retrieving plugin
> Info: Caching catalog for dev
> Info: Applying configuration version '1366464824'
> Notice: undef
> Notice: 
> /Stage[main]//Node[dev]/Sensor::Listner[test_sensor]/Notify[undef]/message: 
> defined 'message' as 'undef'
> Notice: Finished catalog run in 0.02 seconds
> 
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to