Ask Your Question
0

service attributes based off hiera - is this bone headed?

asked 2016-03-17 10:22:28 -0500

abqkawi1000 gravatar image

updated 2016-03-18 08:45:18 -0500

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 flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2016-03-18 00:14:13 -0500

DarylW gravatar image

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.

edit flag offensive delete link more

Comments

1

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

abqkawi1000 gravatar imageabqkawi1000 ( 2016-03-18 08:57:42 -0500 )edit
1

answered 2016-03-17 13:21:20 -0500

lavaman gravatar image

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

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 2016-03-17 10:22:28 -0500

Seen: 56 times

Last updated: Mar 18 '16