FAQ
Hello guys,

I'm creating a module to manage redis, and facing just a little problem
with that.
I have the following init.pp

class redis {
   include redis::install
   include redis::service
   include redis::params # redis:: params also import
                           # redis::config and
                           # redis::monitoring
}

My params class receive some parameters from a define called redisInstance:

class redis::params {
   define redisInstance ($redis_port = 6379, $redis_host = "127.0.0.1",
$slaveof = false, $master_port = false) {
     include redis::config, redis::monitoring
   }
}

Into redisInstance I have two includes to both, configure and monitoring
redis, with I do based on the given parameters.
The problem is that I'm not able to create a second instance just like this:

   redis::params::redisInstance {
       "redis_6379": redis_port => "6379", redis_host =>
"192.168.100.97", slaveof => "127.0.0.1", master_port => "6872";
       "redis_6380": redis_port => "6380", redis_host =>
"192.168.100.98", slaveof => "127.0.0.1", master_port => "6880";
   }

Finally, the part which should configure multiple instances is on config.pp
and is the following:

   file { "/etc/redis/redis_${redis_port}.conf":
     ensure => file,
     content => template("redis/config/redis.conf.erb"),
     mode => 0644,
     notify => Class["redis::service"];
   }

My question is, why the "define" redisInstance cannot create multiple
instances when I use the "include" directive, but when I call the "file"
directive into the define it create as many instances as I want ?
For example, If I use the include directive and call de define as the
following:
redis::params::redisInstance {
       "redis_6379": redis_port => "6379", redis_host =>
"192.168.100.97", slaveof => "127.0.0.1", master_port => "6872";
       "redis_6380": redis_port => "6380", redis_host =>
"192.168.100.98", slaveof => "127.0.0.1", master_port => "6880";
   }
It just creats a single instance(6379) and not the second one(6380).

--
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+unsubscribe@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.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Jcbollinger at Sep 18, 2013 at 1:49 pm

    On Tuesday, September 17, 2013 6:36:54 PM UTC-5, Charles Mean wrote:
    My question is, why the "define" redisInstance cannot create multiple
    instances when I use the "include" directive, but when I call the "file"
    directive into the define it create as many instances as I want ?
    For example, If I use the include directive and call de define as the
    following:
    redis::params::redisInstance {
    "redis_6379": redis_port => "6379", redis_host =>
    "192.168.100.97", slaveof => "127.0.0.1", master_port => "6872";
    "redis_6380": redis_port => "6380", redis_host =>
    "192.168.100.98", slaveof => "127.0.0.1", master_port => "6880";
    }
    It just creats a single instance(6379) and not the second one(6380).

    It is a fundamental Puppet concept that classes are singletons. That means
    assigning the same class to a node multiple times (e.g. via 'include')
    doesn't mean anything more than assigning it once. This turns out to be
    very useful.

    Defined types, on the other hand, are resource types, very much analogous
    to built-in types such as File. Like any other resource type, you can
    declare multiple instances of a defined type, and each is distinct from the
    others.


    John

    --
    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+unsubscribe@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.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedSep 17, '13 at 11:36p
activeSep 18, '13 at 1:49p
posts2
users2
websitepuppetlabs.com

2 users in discussion

Charles Mean: 1 post Jcbollinger: 1 post

People

Translate

site design / logo © 2021 Grokbase