Ask Your Question
0

Pass params to base class

asked 2013-03-24 16:08:07 -0600

1nd1go gravatar image

Hi!

I have a module with following structure (taken from github.com/thomasvandoren/puppet-redis/blob/master/manifests/init.pp):

class redis::params {
  $version = '2.4.3',
  $redis_port = '6379',
}

class redis (
  $version = $redis::params:version,
) inherits redis::params { ... }

I want to override redis_port in declaration, something like this:

class {'redis' :
  version => '2.6.1',
  redis_port => '6380',
}

But this gives me an error

Invalid parameter redis_port

as well as if I declare it like redis::params::redis_port = '6380'

Could you please help me with that?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2013-03-24 16:51:49 -0600

jonn gravatar image

Looking at the module, it seems like you'll need to instantiate the redis::instance class if you want a second Redis instance running on a different port. There's an example on the main page of the repo which demonstrates how:

 class { 'redis':
   version            => '2.4.17',
 }
 redis::instance { 'redis-6900':
   redis_port         => '6900',
   redis_bind_address => '10.1.2.3',
   redis_password     => hiera('redis_password'),
   redis_max_memory   => '1gb',
 }

If you want to change the port for the default instance that is created by the redis class itself, you could always just modify the redis::params class to suit your needs.

edit flag offensive delete link more

Comments

Thanks for answer. Two redis instances is not an option. If I understood correctly, second solution you propose is to modify the code? Well, it is not a good way ...(more)

1nd1go gravatar image1nd1go ( 2013-03-25 02:56:56 -0600 )edit
1

The problem is that the redis class hasn't been written to accept a redis_port parameter, so there's currently no way to override it, so far as I can ...(more)

jonn gravatar imagejonn ( 2013-03-25 03:34:29 -0600 )edit

Ok, that sounds reasonable. But still I wonder what's the point of inheritance from parametrized ::params class if you can't change params? Or why would one mix package ...(more)

1nd1go gravatar image1nd1go ( 2013-03-25 04:12:59 -0600 )edit

ah, well that's one for the module author :) If there's no functional reason why Redis has to run its first instance on that port, then I agree that ...(more)

jonn gravatar imagejonn ( 2013-03-25 06:55:54 -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

Stats

Asked: 2013-03-24 16:08:07 -0600

Seen: 284 times

Last updated: Mar 24 '13