# service attributes based off hiera - is this bone headed?

I would like modify service attributes based on a hiera lookup. So far I have tried the following and get an Invalid value "$foo::params::foo_ensure" Valid values are stopped and running." If this is a terrible way to do this, then what would you suggest?  class foo::params {$manage_foo = hiera('foo::active', false)

if $manage_foo {$foo_enable = true
$foo_ensure = 'running' } else {$foo_enable = false
$foo_ensure = 'stopped' } }   class foo { include foo::params service {'foo': ensure => '$foo::params::foo_ensure',
enable    => '$foo::params::foo_enable', }  Many thanks from a puppet rookie! edit retag close merge delete ## 2 Answers Sort by » oldest newest most voted To flesh out lavaman's answer, you would want to switch from using string literals to directly using the variables you are referencing. class foo { include foo::params service {'foo': ensure =>$foo::params::foo_ensure,
enable    => \$foo::params::foo_enable,
}


If you use the above, you should be correctly using the value of the variable.

more

1

You guys rock! Thank you both for taking the time to clear this up for me.

( 2016-03-18 08:57:42 -0500 )edit

Your service resource is using string literals. If you want to use variable values, don't quote them.

more