GithubHelp home page GithubHelp logo

echocat / puppet-redis Goto Github PK

View Code? Open in Web Editor NEW
24.0 9.0 85.0 258 KB

Puppet module to install and configure redis service from internet sources

License: Other

Ruby 5.63% Puppet 30.87% Shell 16.63% HTML 46.87%
puppet redis echocat

puppet-redis's Introduction

redis

Table of Contents

  1. Overview - What is the redis module?
  2. Setup - The basics of getting started with redis
  3. Usage - The class and defined types available for configuration
  4. Limitations - OS compatibility, etc.
  5. Contributing to the redis module

Overview

This module installs and makes basic configs for multiple redis instances on the same node. It installs redis via REPO or from source. (http://redis.io/) It also can configure the monitoring server Sentinel.

Puppet Forge Build Status Puppet Forge Downloads

Setup

What redis affects:

  • packages/configuration to compile and install redis from source
  • services/configuration files to run multiple redis and sentinels

Beginning with redis

To just compile and install redis binaries. As default the latest stable release will be used.

  class { 'redis::install': }

To install a specific redis version use the following parameters. Most of the time you will only need redis_version.

  class { 'redis::install':
    redis_version     => '2.8.8',
    redis_build_dir   => '/opt',
    redis_install_dir => '/usr/bin'
  }

To install redis from package use the following parameters. You will need redis_version and redis_package.

  class { 'redis::install':
    redis_version  => '2.8.18-1.el6.remi',
    redis_package  => true,
  }

Run multiple instances on same host

As example run two redis instances on port 6379 and 6380.

node 'redis.my.domain' {

  # install latest stable build.
  class { 'redis::install': }

  redis::server {
    'instance1':
      redis_memory    => '1g',
      redis_ip        => '0.0.0.0',
      redis_port      => 6379,
      redis_mempolicy => 'allkeys-lru',
      redis_timeout   => 0,
      redis_nr_dbs    => 16,
      redis_loglevel  => 'notice',
      running         => true,
      enabled         => true
  }

  redis::server {
    'secondRedis':
      redis_memory    => '112m',
      redis_ip        => '0.0.0.0',
      redis_port      => 6380,
      redis_mempolicy => 'allkeys-lru',
      redis_timeout   => 0,
      redis_nr_dbs    => 2,
      redis_loglevel  => 'warning',
      running         => true,
      enabled         => true
  }
}

Run highly available on different hosts

As example of running a high availability cluster with authentication enabled.

node 'redis-master.my.domain' {

  # install latest stable build.
  class { 'redis::install': }

  redis::server {
    'master':
      redis_memory               => '1g',
      redis_ip                   => '0.0.0.0',
      redis_port                 => 6379,
      running                    => true,
      enabled                    => true,
      requirepass                => 'some_really_long_random_password',
      client_output_buffer_limit => {
        'normal' => '0 0 0',
        'slave'  => '500000000 300000000 60',
      },
  }
}

node 'redis-slave.my.domain' {

  # install latest stable build.
  class { 'redis::install': }

  redis::server {
    'slave':
      redis_memory    => '1g',
      redis_ip        => '0.0.0.0',
      redis_port      => 6379,
      running         => true,
      enabled         => true,
      requirepass     => 'some_really_long_random_password',
      slaveof         => 'redis-master.my.domain 6379',
      masterauth      => 'some_really_long_random_password',
  }
}

Create a cluster-enable instance

Please note that right now you can only create cluster-enabled instances but you cannot configure a Redis Cluster only with this module. You should still use redis-trib.rb from Redis source distribution or configure it by hand with redis cluster commands. Moreover, the cluster mode will be enabled only for Redis >= 3.0

A simple example of a cluster-enabled instance, with a timeout of 5 seconds to detect if another node is dead.

node 'redis-cluster.my.domain' {

  # install latest stable build.
  class { 'redis::install': }

  redis::server {
    'cluster-instance':
      redis_memory         => '1g',
      redis_ip             => '0.0.0.0',
      redis_port           => 6379,
      running              => true,
      enabled              => true,
      cluster_enabled      => true,
      cluster_node_timeout => '5000',
  }
}

Example using Hiera

redis::install::redis_package: true
redis::install::redis_version: '2:2.8.17-1+deb8u1'
redis::servers:
  'name_server':
    requirepass: 'strongpass'
    enabled: true
    redis_ip: '0.0.0.0'
    redis_port: '6800'
    redis_log_dir: '/var/log/redis/'

Setting up sentinel with two monitors

You can create multiple sentinels on one node. But most of the time you will want to create a sentinel with one or more monitors configured.

node 'sentinel.my.domain' {

  # install latest stable build.
  class { 'redis::install': redis_version => '2.8.8' }

  redis::sentinel {'clusters':
    monitors => {
      'mymaster' => {
        master_host             => '127.0.0.1',
        master_port             => 6378,
        quorum                  => 2,
        down_after_milliseconds => 30000,
        parallel-syncs          => 1,
        failover_timeout        => 180000
      },
      'securetRedisCluster' => {
        master_host             => '10.20.30.1',
        master_port             => 6379,
        quorum                  => 2,
        down_after_milliseconds => 30000,
        parallel-syncs          => 5,
        failover_timeout        => 180000,
        auth-pass => 'secret_Password',
        notification-script => '/tmp/notify.sh',
        client-reconfig-script => '/tmp/reconfig.sh'
      }
    }
  }

Usage

Classes and Defined Types

This module compiles and installs redis with the class redis::install. The redis service(s) are configured with the defined type redis::server.

Class: redis::install

This class downloads, compiles and installs redis. It does not configure any redis services. This is done by defined type redis::server.

Parameters within redis::install:

redis_version

The redis version to be installed. By default, the latest stable build will be installed.

redis_build_dir

Default is '/opt/' (string) The dir to store redis source code. This will result in a directoy like '/opt/redis-2.8.8/'

redis_install_dir

Default is '/usr/bin' (string). The dir to which the newly built redis binaries are copied.

redis_user

Redis system user. Default: undef (string) Default 'undef' results to 'root' as redis system user

Some redis install packages create the redis system user by default (at least SLES and Ubuntu provide redis install packages). Normally the log directory and the pid directory are created also by the redis install package. Therefor, these values must be adjusted too.

redis_group

Redis system group. Default: undef (string) Default 'undef' results to 'root' as redis system group

download_base

Url where to find the source tar.gz. Default value is 'http://download.redis.io/releases'

Defined Type: redis::server

Used to configure redis instances. You can setup multiple redis servers on the same node. See the setup examples.

**Parameters within redis::server

redis_name

Name of Redis instance. Default: call name of the function. The name is used to create the init script(s), which follows the pattern redis-server_${redis_name}

redis_memory

Default is '100mb' (string). Sets amount of memory used. eg. 100mb or 4g.

redis_ip

Default is '127.0.0.1' (string). Listen IP of redis.

redis_port

Listen port of Redis. Default: 6379

redis_usesocket

To enable unixsocket options. Default: false

redis_socket

Unix socket to use. Default: /tmp/redis.sock

redis_socketperm

Permission of socket file. Default: 755

redis_mempolicy

Algorithm used to manage keys. See Redis docs for possible values. Default: allkeys-lru

redis_memsamples

Number of samples to use for LRU policies. Default: 3

redis_timeout

Default: 0

redis_nr_dbs

Number of databases provided by redis. Default: 1

redis_dbfilename

Name of database dump file. Default: dump.rdb

redis_dir

Default is '/var/lib' (string) Path for persistent data. Path is <redis_dir>/redis_<redis_name>/.

redis_pid_dir

Default is '/var/run' (string). Path for pidfile. Full pidfile path is <redis_pid_dir>/redis_<redis_name>.pid.

redis_log_dir

Default is '/var/log' (string). Path for log. Full log path is <redis_log_dir>/redis_<redis_name>.log.

redis_loglevel

Loglevel of Redis. Default: 'notice' (string)

running

Configure if Redis should be running or not. Default: true (boolean)

enabled

Configure if Redis is started at boot. Default: true (boolean)

requirepass

Supply a password if you want authentication with Redis. Default: undef (string)

maxclients

Max clients of Redis instance. Default: undef (number)

appendfsync_on_rewrite

Configure the no-appendfsync-on-rewrite variable. Set to yes to enable the option. Defaults off. Default: false (boolean)

redis_disable_commands

List of commands to disable on the server. Default: []

aof_rewrite_percentage

Configure the percentage size difference between the last aof filesize and the newest to trigger a rewrite. Default 100

aof_rewrite_minsize

Configure the minimum size in mb of the aof file to trigger size comparisons for rewriting. Default: 64

redis_appendfsync

Configure the value for when an fsync should happen. Values are either everysec, always, or no. Default: everysec

redis_append_enable

Enable or disable the appendonly file option. Default: false (boolean)

redis_enabled_append_file

Enable custom append file. Default: false (boolean)

redis_append_file

Define the path for the append file. Optional. Default: undef

save

Configure Redis save snapshotting. Example: [[900, 1], [300, 10]]. Default: []

force_rewrite

Boolean. Default: false

Configure if the redis config is overwritten by puppet followed by a restart. Since redis automatically rewrite their config since version 2.8 setting this to true will trigger a redis restart on each puppet run with redis 2.8 or later.

client_output_buffer_limit

Hash containing 3 possible classes as keys (normal, slave, pubsub) and with the values set to the hard limit, soft limit and seconds. Default: empty

manage_logrotate

Configure logrotate rules for redis server. Default: true

High Availability Options
slaveof

Configure Redis Master on a slave. Default: undef (string)

masterauth

Password used when connecting to a master server which requires authentication. Default: undef (string)

slave_server_stale_data

Configure Redis slave to server stale data. Default: true (boolean)

slave_read_only

Configure Redis slave to be in read-only mode. Default: true (boolean)

repl_timeout

Configure Redis slave replication timeout in seconds. Default: 60 (number)

repl_backlog_size

Configure Redis slave backlog size in bytes. Default: undef

repl_ping_slave_period

Configure Redis replication ping slave period in seconds. Default: 10 (number)

Cluster Options
cluster_enabled

Enable Redis Cluster. Supported only in Redis 3.x. Default: false

cluster_node_timeout

Timeout in ms to declare a node as failed.

cluster_slave_validity_factor

Configure slave validity factor. Please read the Redis documentation to learn more about this parameter.

cluster_migration_barrier

Slaves migrate to orphaned masters only if there are still at least this given number of other working slaves for their old master.

cluster_require_full_coverage

By default Redis Cluster nodes stop accepting queries if they detect there is at least an hash slot uncovered.

Defined Type: redis::sentinel

Used to configure sentinel instances. You can setup multiple sentinel servers on the same node. And you can configure multiple monitors within a sentinel. See the setup examples.

**Parameters within redis::sentinel

sentinel_name

Name of Redis instance. Default: call name of the function. The name is used to create the init script(s), which follows the pattern redis-sentinel_${sentinel_name}

sentinel_ip

Listen IP of sentinel. Default: 6379

sentinel_port

Listen port of sentinel. Default: 6379

sentinel_log_dir

Default is '/var/log' (string). Path for log. Full log path is sentinel_log_dir/sentinel_sentinel_name.log.

sentinel_pid_dir

Default is '/var/run' (string). Path for pid file. Full pid file path is sentinel_pid_dir/sentinel_sentinel_name.pid.

sentinel_run_dir

Default: /var/run/redis (string) Since sentinels automatically rewrite their config since version 2.8 the puppet managed config will be copied to this directory and than sentinel will start with this copy.

monitors

Default is

{
  'mymaster' => {
    master_host             => '127.0.0.1',
    master_port             => 6379,
    quorum                  => 2,
    down_after_milliseconds => 30000,
    parallel-syncs          => 1,
    failover_timeout        => 180000,
    ### optional
    auth-pass => 'secret_Password',
    notification-script => '/var/redis/notify.sh',
    client-reconfig-script => '/var/redis/reconfig.sh'
  },
}

Hashmap of monitors.

running

Configure if Redis should be running or not. Default: true (boolean)

enabled

Configure if Redis is started at boot. Default: true (boolean)

force_rewrite

Boolean. Default: false

Configure if the sentinels config is overwritten by puppet followed by a sentinel restart. Since sentinels automatically rewrite their config since version 2.8 setting this to true will trigger a sentinel restart on each puppet run with redis 2.8 or later.

manage_logrotate

Configure logrotate rules for redis server. Default: true

Limitations

This module is tested on CentOS 6.5 and Debian 7 (Wheezy) and should also run without problems on

  • RHEL/CentOS/Scientific 6+
  • Debian 6+
  • Ubunutu 10.04 and newer
  • SLES 11 SP3

Limitation on SLES:

  • Installation from source is not tested
  • Redis sentinel configuration/management is not tested

Contributing

Echocat modules are open projects. So if you want to make this module even better, you can contribute to this module on Github.

puppet-redis's People

Contributors

barruumrex avatar billmoritz avatar bleuchtang avatar bovy89 avatar buzzdeee avatar cdenneen avatar derdanne avatar dwerder avatar hskwirblies avatar huandu avatar infraded avatar jlindquist-godaddy avatar joekohlsdorf avatar joshbeard avatar lampapetrol avatar matthiaswiesner avatar mwillson2 avatar obliadp avatar pbrit avatar pulyaevskiy avatar pwx21 avatar quixoten avatar rubyisbeautiful avatar tomeklaskarzewski avatar vchan-cylance avatar vide avatar voroniys avatar zbstof avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

puppet-redis's Issues

Compile Error - Validation of Exec[Make dir /opt] failed

Getting the following on it { should compile } in my tests

Failure/Error: it { should compile }
error during compilation: Validation of Exec[Make dir /opt] failed: 'mkdir -p /opt' is not qualified and no path was specified. Please qualify the command or specify a path.

I also had to specifically call in 'epel-release' in order to get it to do anything, should this be installed by your module?

class { '::redis::install':
    redis_version     => $redis_version,
    redis_build_dir   => '/opt',
    redis_install_dir => '/usr/bin',
    require           => Package['epel-release'],
  }

Any suggestions?

port to Foreman

i use the foreman to manage my infra , i tryed port creating a class over ther module to can show on the foreman , but i got issues fist , i create a 2 class one for master and other for slave server , but they are instaling both files in all server , can you help me ?

Unit redis.service failed to load: No such file or directory

Manifest:

class { 'redis::install': }

redis::server {
    'master':
        requirepass => 'default',
}
[vagrant@localhost ~]$ sudo service redis status
Redirecting to /bin/systemctl status  redis.service
redis.service
   Loaded: not-found (Reason: No such file or directory)
   Active: inactive (dead)

[vagrant@localhost ~]$ sudo service redis start
Redirecting to /bin/systemctl start  redis.service
Failed to issue method call: Unit redis.service failed to load: No such file or directory.
[vagrant@localhost ~]$

After successful installation, redis does not start/cannot be started.

Ubuntu installation doesn't work

Error: Could not update: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold --force-yes install redis=2.8.4-2' returned 100: Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package redis

it should be "redis-server".

P.

redis::server thinks that OracleLinux 6 has systemd

I just started using this module, so this may be answered somewhere else that I have found yet. But, in the case that this hasn't been documented yet, here's what's happening to me:

Environment:

  • $::operatingsystem => OracleLinux
  • $::operatingsystemmajrelease => 6
  • Puppet version => 4.10.10
  • mod 'dwerder-redis', '2.1.0'

Manifest where I'm using your module:

  class {'redis::install':
    redis_build_dir   => '/opt',
    redis_user        => 'apache',
    redis_group       => 'webadmin',
  }
  redis::server {'webapps':
    redis_memory    => '512mb',
    redis_ip        => '127.0.0.1',
    redis_port      => 6379,
    redis_nr_dbs    => 16,
    running         => true,
    enabled         => true,
  }

Error message being presented:
Error: Could not set 'file' on ensure: No such file or directory @ dir_s_mkdir - /usr/lib/systemd/system/redis-server_webapps.service20180403-41151-wnw22o.lock at /etc/puppetlabs/code/environments/pg_alter_redis/modules/redis/manifests/server.pp:235

I looked into the code in this repository at manifests/server.pp, and line 235 is inside a file declaration for $service_file. That variable, along with $has_systemd, gets defined in a case block in lines 200-223. The relevant section:

    'Fedora', 'RedHat', 'CentOS', 'OEL', 'OracleLinux', 'Amazon', 'Scientific': {
      if versioncmp($::operatingsystemmajrelease, '7') >= 0 {
        $has_systemd = true
        $service_file = "/usr/lib/systemd/system/redis-server_${redis_name}.service"
      }
    }

So, to my untrained eye, it appears that the OracleLinux 6 VM is being interpreted by this case statement to have a major version of 7 and thus $has_systemd is getting set to true and then it's trying to create $service_file when it shouldn't.

Do you have any insight on what might be happening, or how to resolve it? Thanks!

sentinel conf error with multiple monitors and optional params

Hi,
multiple sentinel monitors and optional params (like auth-pass), generate this configuration:

# monitor master_instance_1
sentinel monitor master_instance_1 127.0.0.1  6379 2
sentinel down-after-milliseconds master_instance_1 60000
sentinel parallel-syncs master_instance_1 1
sentinel failover-timeout master_instance_1 180000
sentinel auth-pass master_instance_1 superstrongpassword1# monitor master_instance_2
sentinel monitor master_instance_2 127.0.0.1  6380 2
sentinel down-after-milliseconds master_instance_2 60000
sentinel parallel-syncs master_instance_2 1
sentinel failover-timeout master_instance_2 180000
sentinel auth-pass master_instance_2 superstrongpassword2# monitor master_instance_3
sentinel monitor master_instance_3 127.0.0.1  6381 2
sentinel down-after-milliseconds master_instance_3 60000
sentinel parallel-syncs master_instance_3 1
sentinel failover-timeout master_instance_3 180000

instead of this one:

# monitor master_instance_1
sentinel monitor master_instance_1 127.0.0.1  6379 2
sentinel down-after-milliseconds master_instance_1 60000
sentinel parallel-syncs master_instance_1 1
sentinel failover-timeout master_instance_1 180000
sentinel auth-pass master_instance_1 superstrongpassword1

# monitor master_instance_2
sentinel monitor master_instance_2 127.0.0.1  6380 2
sentinel down-after-milliseconds master_instance_2 60000
sentinel parallel-syncs master_instance_2 1
sentinel failover-timeout master_instance_2 180000
sentinel auth-pass master_instance_2 superstrongpassword2

# monitor master_instance_3
sentinel monitor master_instance_3 127.0.0.1  6381 2
sentinel down-after-milliseconds master_instance_3 60000
sentinel parallel-syncs master_instance_3 1
sentinel failover-timeout master_instance_3 180000

Sentinel service cannot start.

Module version: 1.9.0
Puppet version: not relevant

Update-rc.d fails on Debian Squeeze with munin-node package installed

Hi,

we encountered an issue today while having munin-node package installed on Debian Squeeze. The Problem is, that update-rc.d fins a loop and stops adding the redis sysvinit scripts. The Issue looks like this:

err: /Stage[main]//Node[redisserver]/Redis::Server[production]/Service[redis-server_production]/enable: change from false to true failed: Execution of '/usr/sbin/update-rc.d redis-server_production defaults' returned 1: update-rc.d: using dependency based boot sequencing
insserv: warning: script 'redis-server_production' missing LSB tags and overrides
insserv: warning: script 'redis-server_staging' missing LSB tags and overrides
insserv: There is a loop between service munin-node and redis-server_production if stopped
insserv: loop involving service redis-server_production at depth 2
insserv: loop involving service munin-node at depth 1
insserv: Stopping redis-server_production depends on munin-node and therefore on system facility $all' which can not be true! insserv: Stopping redis-server_staging depends on munin-node and therefore on system facility$all' which can not be true!
insserv: exiting now without changing boot order!
update-rc.d: error: insserv rejected the script header

I was able to fix this by adding a proper INIT INFO part at the begin of the init-script. You can see my manual fix here: https://github.com/martinseener/puppet-redis/blob/master/templates/etc/init.d/debian_redis-server.erb.

If you like this fix, i can create a PR for you. Otherwise add it yourself or just close this issue. The fix i made works perfectly by the way.

Server Not Starting

The puppet module is properly installing redis on my box but the redis::server configuration isn't getting set anywhere and the server isn't starting up. Is there something wrong with my configuration below? I'd prefer not to have to set init.d and conf files through puppet if this module can handle that setup for me.

node 'redis.my.server' {
     class { 'redis::install':
           redis_version => '2.8.8',
     }

     redis::server {
        'master':
            redis_name      => 'master',
            redis_memory    => '1g',
            redis_ip        => '0.0.0.0',
            redis_port      => 6379,
            running         => true,
            enabled         => true,
     }
}

CentOS 6: /var/run/redis directory not created

Using a manifest like this:

  redis::server { "${env}-redis-${port}" :
    redis_memory => $memory,
    redis_ip     => $ip,
    redis_port   => $port,
    requirepass  => $password,
    running      => true,
    enabled      => true,
    redis_nr_dbs => 2
  }

On CentOS 6, the /var/run/redis directory is not created and the puppet agent run fails when it can't copy the /etc/redis.conf to that that directory. I fixed it by putting the following at the top of my manifest:

file { '/var/run/redis' :
    ensure => 'directory',
  }

redis-check-dump doesn't exists in redis 3.2

looks like redis-check-dump should be option:
Error: /Stage[main]/Redis::Install/Redis::Installbinary[redis-check-dump]/File[/usr/bin/redis-check-dump]: Could not evaluate: Could not retrieve information from environment production source(s) file:/opt/redis/redis/redis-check-dump

Add support for binding to NUMA

Support numactl in the systemd unit file, example:

diff --git a/templates/systemd/redis.service.erb b/templates/systemd/redis.service.erb
index caa55b6..bd84f27 100644
--- a/templates/systemd/redis.service.erb
+++ b/templates/systemd/redis.service.erb
@@ -5,10 +5,15 @@ After=network.target
 [Service]
 ExecStartPre=/bin/mkdir -p <%= @redis_run_dir %>
 ExecStartPre=/bin/cp -u <%= @conf_file %> <%= @redis_run_dir %>/<%= @conf_file_name %>
+<% if @numactl_enable -%>
+ExecStart=/usr/bin/numactl --cpubind=<%= @numactl_node %> --membind=<%= @numactl_node 
 %> /usr/bin/redis-server <%= @redis_run_dir %>/<%= @conf_file_name %> --daemonize no
+<% else %>
 ExecStart=/usr/bin/redis-server <%= @redis_run_dir %>/<%= @conf_file_name %> --daemonize no
+<% end -%>
 ExecStop=/usr/bin/redis-cli -p <%= @redis_port %> shutdown
 User=<%= @redis_user or 'root' %>
 Group=<%= @redis_group or 'root' %>

+
 [Install]
 WantedBy=multi-user.target

Add support for setting niceness

Support niceness in the systemd unit file, example:

diff --git a/templates/systemd/redis.service.erb b/templates/systemd/redis.service.erb
index caa55b6..1fce7b8 100644
--- a/templates/systemd/redis.service.erb
+++ b/templates/systemd/redis.service.erb
@@ -9,6 +9,7 @@ ExecStart=/usr/bin/redis-server <%= @redis_run_dir %>/<%= @conf_file_name %> --d
 ExecStop=/usr/bin/redis-cli -p <%= @redis_port %> shutdown
 User=<%= @redis_user or 'root' %>
 Group=<%= @redis_group or 'root' %>
+Nice=<%= @niceness or 0 %>

 [Install]
 WantedBy=multi-user.target

Failed to start on CentOS 7.2 after update to 1.8.0

After updating module to 1.8.0 I can't run redis on my CentOS 7.2. It doesn't even create log files. The only thing I have is log from systemctl status:
Apr 07 11:17:05 vagrant02.dev.pl systemd[1]: Failed to start Redis persistent key-value database server.

The machine is created with Vagrant using box puppetlabs/centos-7.2-64-puppet

This is my redis.pp:
https://gist.github.com/bkibilko/9c7914195d9b1c28c8e0a191ed3b5133

... and variables from hiera:
https://gist.github.com/bkibilko/14986c03a7b88a2d78a35fe70b25006f

After downgrading to 1.7.0 it works fine.

Centos6.4 redis 3.2 can not work

Hi, thank you great modules.

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Cannot reassign variable service_file at /etc/puppet/environments/production/modules/redis/manifests/server.pp:228 on node vm_13_72_centos
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

First:

node 'vm_13_72_centos' {

  class { 'redis::install':
    redis_version     => '3.2.1',
    redis_build_dir   => '/opt',
    redis_install_dir => '/usr/bin'
  }

can be work !

Step2: add instance

  redis::server {
    'testing':
      redis_memory    => '12m',
      redis_ip        => '10.135.13.72',
      redis_port      => 6379,
      redis_mempolicy => 'allkeys-lru',
      redis_timeout   => 0,
      redis_nr_dbs    => 16,
      redis_loglevel  => 'notice',
      running         => true,
      enabled         => true
  }

can not work .

puppet 2.7

Dependency Failures

Provisioning gives several dependency errors despite having stdlib 4.6.0 installed. Shouldn't these be automatically installed by the puppet module?

Installation:

puppet module install --force --target-dir /usr/share/puppet/modules dwerder/redis

Puppet declaration:

class { 'redis::install':
redis_version => '3.0.2',
}

Errors:

==> dev: Warning: /Stage[main]/Redis::Install/Anchor[redis::prepare_build]: Skipping because of failed dependencies
==> dev: Warning: /Stage[main]/Redis::Install/Exec[redis::compile]: Skipping because of failed dependencies
==> dev: Warning: /Stage[main]/Redis::Install/File[/opt/redis]: Skipping because of failed dependencies
==> dev: Warning: /Stage[main]/Redis::Install/Anchor[redis::install]: Skipping because of failed dependencies
==> dev: Warning: /Stage[main]/Redis::Install/Redis::Installbinary[redis-cli]/File[/usr/bin/redis-cli]: Skipping because of failed dependencies
==> dev: Warning: /Stage[main]/Redis::Install/Redis::Installbinary[redis-check-aof]/File[/usr/bin/redis-check-aof]: Skipping because of failed dependencies
==> dev: Warning: /Stage[main]/Redis::Install/Redis::Installbinary[redis-sentinel]/File[/usr/bin/redis-sentinel]: Skipping because of failed dependencies
==> dev: Warning: /Stage[main]/Redis::Install/Redis::Installbinary[redis-server]/File[/usr/bin/redis-server]: Skipping because of failed dependencies
==> dev: Warning: /Stage[main]/Redis::Install/Redis::Installbinary[redis-check-dump]/File[/usr/bin/redis-check-dump]: Skipping because of failed dependencies
==> dev: Warning: /Stage[main]/Redis::Install/Redis::Installbinary[redis-benchmark]/File[/usr/bin/redis-benchmark]: Skipping because of failed dependencies

ensure_packages requires an Array (Ubunut 14.04)

I'm using this to provision a Vagrant box on Ubuntu 14.04. This error kept appearing:

==> default: Error: ensure_packages(): Requires array given (String) at /tmp/vagrant-puppet/modules-25122be7f814d9df3db6ebc5babb457c/redis/manifests/install.pp:67 on node vagrant-ubuntu-trusty-64

I was able to fix this by changing line 67 in manifests/install.pp:

67: ensure_packages('build-essential') 

to

67: ensure_packages(['build-essential'])

Missing newline in Sentinel template causes syntax error in config

There is a missing newline in the Sentinel template where monitors are setup (https://github.com/echocat/puppet-redis/blob/master/templates/etc/sentinel.conf.erb#L26-L37). When multiple monitors are setup, this leads to a syntax error in the config and a failure for Sentinel to start up properly. See snipped below for what the final output looks like with 2 sentinels configured

# monitor cache
sentinel monitor cache 10.32.155.112  6379 1
sentinel down-after-milliseconds cache 5000
sentinel parallel-syncs cache 1
sentinel failover-timeout cache 30000
sentinel auth-pass cache <removed># monitor jobs   <<< Syntax error
sentinel monitor jobs 10.32.155.112  6381 1
sentinel down-after-milliseconds jobs 5000
sentinel parallel-syncs jobs 1
sentinel failover-timeout jobs 30000
sentinel auth-pass jobs <removed>

I will have a PR ready shortly that should address this easily enough by adding a line break at the end of the loop

Unit is not loaded properly: Bad message

Hello, after installing I got the message like in the subject.
Also

systemctl status redis-server_master.service
โ— redis-server_master.service
   Loaded: error (Reason: Bad message)
   Active: inactive (dead)

Feb 21 16:02:55 vmredisuk1 systemd[1]: [/usr/lib/systemd/system/redis-server_master.service:19] Invalid section header '[ "$NETWORKING" = "no" ] && exit 0'
Feb 21 16:05:13 vmredisuk1 systemd[1]: [/usr/lib/systemd/system/redis-server_master.service:13] Assignment outside of section. Ignoring.
Feb 21 16:05:13 vmredisuk1 systemd[1]: [/usr/lib/systemd/system/redis-server_master.service:16] Assignment outside of section. Ignoring.
Feb 21 16:05:13 vmredisuk1 systemd[1]: [/usr/lib/systemd/system/redis-server_master.service:19] Invalid section header '[ "$NETWORKING" = "no" ] && exit 0'
Feb 21 16:07:21 vmredisuk1 systemd[1]: [/usr/lib/systemd/system/redis-server_master.service:13] Assignment outside of section. Ignoring.
Feb 21 16:07:21 vmredisuk1 systemd[1]: [/usr/lib/systemd/system/redis-server_master.service:16] Assignment outside of section. Ignoring.
Feb 21 16:07:21 vmredisuk1 systemd[1]: [/usr/lib/systemd/system/redis-server_master.service:19] Invalid section header '[ "$NETWORKING" = "no" ] && exit 0'
Feb 21 16:07:28 vmredisuk1 systemd[1]: [/usr/lib/systemd/system/redis-server_master.service:13] Assignment outside of section. Ignoring.
Feb 21 16:07:28 vmredisuk1 systemd[1]: [/usr/lib/systemd/system/redis-server_master.service:16] Assignment outside of section. Ignoring.
Feb 21 16:07:28 vmredisuk1 systemd[1]: [/usr/lib/systemd/system/redis-server_master.service:19] Invalid section header '[ "$NETWORKING" = "no" ] && exit 0'

I have CentOS Linux release 7.3.1611 and Puppet 3.8.7

Add support for yum options

Hello,

I'm getting the redis rpm from the remi repo which is disabled by default. In order to install from this repo yum needs the additional option --enablerepo=remi. I've created a branch that allows yum options to be passed in via a class parameter for such a situation. If you think this would be a good option I can create a PR.

https://github.com/rmacduff/puppet-redis/tree/add_yum_options

BTW, by far this is the best redis module out there! It's made installing and configuring redis for my testing really easy.

-Ross

Systemctl unable to start redis-server: Can't open the log file: Permission denied

Hi there,

I am using 1.9.0 version of this puppet-redis module to install and start Redis 3.2.3 server on CentOS 7 with puppet 3.8.7. The error shown below is logged to journalctl when puppet tries to start redis-server via systemd as root user (service config is shown at the bottom). I do not get any errors and redis-server starts up fine when I run /usr/bin/redis-server /var/run/redis/redis_redis1.conf --daemonize no as root.

Similar issues have been reported by others.

Any ideas on how to fix this?

systemd[1]: Starting Redis redis_redis1 database server...
systemd[1]: Started Redis redis_redis1 database server.
redis-server[30824]: *** FATAL CONFIG FILE ERROR ***
redis-server[30824]: Reading the configuration file, at line 52
redis-server[30824]: >>> 'logfile /var/log/redis/redis_redis1.log'
redis-server[30824]: Can't open the log file: Permission denied
systemd[1]: redis-server_redis1.service: main process exited, code=exited, status=1/FAILURE
>> cat /usr/lib/systemd/system/redis-server_redis1.service
[Unit]
Description=Redis redis_redis1 database server
After=network.target

[Service]
ExecStartPre=/bin/mkdir -p /var/run/redis
ExecStartPre=/bin/cp -u /etc/redis_redis1.conf /var/run/redis/redis_redis1.conf
ExecStart=/usr/bin/redis-server /var/run/redis/redis_redis1.conf --daemonize no
ExecStop=/usr/bin/redis-cli -p 6800 shutdown
User=root
Group=root

[Install]
WantedBy=multi-user.target
ls -lah /var/log/redis/redis_redis1.log
-rw-rw-r--. 1 redis redis 51K Sep 25 01:27 /var/log/redis/redis_redis1.log

Duplicate declaration: Exec[systemd_service_{name}_preset]

On CentOS 7, there is potential for a duplicate Exec declaration when setting up the systemd script if both server and sentinel live on the same server and share the same name.

This results in duplicate declaration error:

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Evaluation Error: Error while evaluating a Resource Statement, Duplicate declaration: Exec[systemd_service_ola_preset] is already declared in file /etc/puppet/environments/ola/modules/redis/manifests/server.pp:180; cannot redeclare at /etc/puppet/environments/ola/modules/redis/manifests/sentinel.pp:103 at /etc/puppet/environments/ola/modules/redis/manifests/sentinel.pp:103:5 on node a2dlolaredis01.cloud.iad2.gdg
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

Example:

redis::servers:
  'ola':
    requirepass: <somepass>
    running: true
    enabled: true
    redis_ip: '0.0.0.0'
    redis_port: '6379'
    redis_memory: '4g'
redis::sentinel { 'ola':
    running       => true,
    enabled       => true,
    sentinel_ip   => '0.0.0.0',
    sentinel_port => 26379,
    monitors      => {
      'ola' => {
        master_host             => '10.26.85.58',
        master_port             => 6379,
        quorum                  => 2,
        down_after_milliseconds => 10000,
        parallel-syncs          => 1,
        failover_timeout        => 60000,
        auth-pass               => <somepass>
      }
    }
  }

See:
https://github.com/echocat/puppet-redis/blob/master/manifests/server.pp#L211
https://github.com/echocat/puppet-redis/blob/master/manifests/sentinel.pp#L113

with custom instance but default one keeps running

Hello,

I try to use your Puppet module on Debian 7 running Puppet 3.4. My tests use Vagrant.
I want to use the Debian packaged Redis version, and to configure my redis server to listen to all IPs, so I use the following code:

class { 'redis::install':
    redis_version   => '2:2.8.17-1~bpo70+1+b1',
    redis_package   => true,
}
redis::server {
    'master':
        redis_ip    => '0.0.0.0',
        redis_port  => 6400,
        running     => true,
        enabled     => true,
}

I thought the init.d file for the default server (/etc/init.d/redis-server) would be remove which is not the case, and in fact in my machine only the default redis server is running not my configured instance

# netstat -utpln
Proto Recv-Q Send-Q Adresse locale          Adresse distante        Etat        PID/Program name
tcp        0      0 127.0.0.1:6379          0.0.0.0:*               LISTEN      2080/redis-server 1

I changed the port to 6400 to see if 2 instances will run, but it's not the case, even if I have 2 init files (one redis-server, one redis-server_master)

If I try to launch /etc/init.d/redis-server_master it won't work. If I stop the default one, I can start it.

I may have missed something in the documentation and my code may be wrong somewhere.
Could you tell me how I can:

  • not have the default server run, maybe even not have its init file?
  • have my configured one runs, and be 'monitored' by Puppet?

Thanks.

Should be using ensure_packages when installing packages

==> default: Error: Duplicate declaration: Package[make] is already declared in file /tmp/vagrant-puppet-3/modules-0/redis/manifests/install.pp:42; cannot redeclare at /tmp/vagrant-puppet-3/modules-0/nodejs/manifests/install.pp:149 on node localhost
==> default: Error: Duplicate declaration: Package[make] is already declared in file /tmp/vagrant-puppet-3/modules-0/redis/manifests/install.pp:42; cannot redeclare at /tmp/vagrant-puppet-3/modules-0/nodejs/manifests/install.pp:149 on node localhost

Consider using https://github.com/puppetlabs/puppetlabs-stdlib/blob/master/lib/puppet/parser/functions/ensure_packages.rb or manually checking that packages are not already installed.

Dependency to puppetlabs-stdlib is missing

==> default: Debug: Runtime environment: puppet_version=3.7.2, ruby_version=2.0.0, run_mode=user, default_encoding=UTF-8
==> default: Debug: importing '/tmp/vagrant-puppet-3/modules-0/redis/manifests/init.pp' in environment production
==> default: Debug: importing '/tmp/vagrant-puppet-3/modules-0/redis/manifests/install.pp' in environment production
==> default: Debug: Automatically imported redis::install from redis/install into production
==> default: Debug: importing '/tmp/vagrant-puppet-3/modules-0/redis/manifests/params.pp' in environment production
==> default: Debug: Automatically imported redis::params from redis/params into production
==> default: Debug: hiera(): Hiera YAML backend starting
==> default: Debug: hiera(): Looking up redis::install::redis_version in YAML backend
==> default: Debug: hiera(): Looking for data source common
==> default: Debug: hiera(): Cannot find datafile /var/lib/hiera/common.yaml, skipping
==> default: Debug: hiera(): Looking up redis::install::redis_build_dir in YAML backend
==> default: Debug: hiera(): Looking for data source common
==> default: Debug: hiera(): Cannot find datafile /var/lib/hiera/common.yaml, skipping
==> default: Debug: hiera(): Looking up redis::install::redis_install_dir in YAML backend
==> default: Debug: hiera(): Looking for data source common
==> default: Debug: hiera(): Cannot find datafile /var/lib/hiera/common.yaml, skipping
==> default: Debug: hiera(): Looking up redis::install::redis_package in YAML backend
==> default: Debug: hiera(): Looking for data source common
==> default: Debug: hiera(): Cannot find datafile /var/lib/hiera/common.yaml, skipping
==> default: Warning: Config file /etc/puppet/hiera.yaml not found, using Hiera defaults
==> default: Debug: Executing '/bin/rpm --version'
==> default: Debug: Executing '/bin/rpm -ql rpm'
==> default: Debug: Executing '/bin/rpm --version'
==> default: Error: Puppet::Parser::AST::Resource failed with error ArgumentError: Invalid resource type anchor at /tmp/vagrant-puppet-3/modules-0/redis/manifests/install.pp:93 on node localhost
==> default: Wrapped exception:
==> default: Invalid resource type anchor
==> default: Error: Puppet::Parser::AST::Resource failed with error ArgumentError: Invalid resource type anchor at /tmp/vagrant-puppet-3/modules-0/redis/manifests/install.pp:93 on node localhost
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.

Using with https://vagrantcloud.com/puppetlabs/boxes/centos-7.0-64-puppet

Typos

manifests/server.pp:199 and 203
$::operatingsystemmajrelease is a string and may not be compared to an integer.

templates/systemd/sentinel.service.erb:2
"sentinel_name" needs to be "@sentinel_name"

Redis 2.8.19 does not understand "cluster-require-full-coverage"

Sentinel configuration issues

Two issues spot here:

1.) The sentinel config template "templates/etc/sentinel.conf.erb" should refer to the monitor variables as follow:
@monitors.sort.each do |name, rule| %>

2.) In the case of using sentinel, then the redis config file should allow sentinel to manage:
File["/etc/redis_${redis_name}.conf"] { replace => false, }

redis-check-dump was renamed to redis-check-rdb in redis version 3.2

There is new version of redis which causes the module to fail on installation:

Error: /Stage[main]/Redis::Install/Redis::Installbinary[redis-check-dump]/File[/usr/bin/redis-check-dump]: Could not evaluate: Could not retrieve information from environment vagrant source(s) file:/opt/redis/redis-check-dump

Duplicate declaration on build-essential

Hi there,
Still relatively new to puppet, I seem to have a little issue with puppet-reddis :

Error: Evaluation Error: Error while evaluating a Function Call, 
Duplicate declaration: Package[build-essential] is already declared in file /local/puppet/modules/common/manifests/virtual_packages.pp:3; cannot redeclare at /local/puppet/modules/redis/manifests/install.pp:67 at /local/puppet/modules/redis/manifests/install.pp:67:9 on node XXXX

Version of puppet

/opt/puppetlabs/puppet/bin/puppet --version
2017-03-27 08:30:33.725348 WARN  puppetlabs.facter - locale environment variables were bad; continuing with LANG=C LC_ALL=C
4.9.4

Version of Linux

lsb_release -d
Description:	Ubuntu 16.04.2 LTS

It seems that these lines are causing the troubles :

'Debian', 'Ubuntu' : {
        ensure_packages('build-essential')
        Package['build-essential'] -> Anchor['redis::prepare_build']
      }

spec test fails to compile

I saw issue #36 and I have the same problem. I looked at your spec test and I don't see $::path defined there. How are your tests passing?

Also, isn't it best practice to use a File resource or ensure_resource were used instead of exec?

file { 'redis build directory' : 
  path => $redis_build_dir,
  ensure => 'directory',
}

or

ensure_resource('file', "${redis_build_dir}", { 'ensure' => 'present' })

Systemd (Debian Jessie) not starting instances automatically

I've got:
redis::server {
'ta-app':
redis_memory => '2g',
redis_ip => '10.130.46.184',
redis_port => '6379',
redis_mempolicy => 'allkeys-lru',
redis_timeout => 0,
redis_nr_dbs => 16,
redis_loglevel => 'notice',
running => true,
enabled => true,
....

This should start, however, it doesn't, when running the agent with debugging enabled:
Debug: Executing '/usr/sbin/service redis-server_ta-app start'
Error: Could not start Service[redis-server_ta-app]: Execution of '/usr/sbin/service redis-server_ta-app start' returned 6: Failed to start redis-server_ta-app.service: Unit redis-server_ta-app.service failed to load: No such file or directory.
Wrapped exception:
Execution of '/usr/sbin/service redis-server_ta-app start' returned 6: Failed to start redis-server_ta-app.service: Unit redis-server_ta-app.service failed to load: No such file or directory.
Error: /Stage[main]/Main/Node[ta-application-01]/Redis::Server[ta-app]/Service[redis-server_ta-app]/ensure: change from stopped to running failed: Could not start Service[redis-server_ta-app]: Execution of '/usr/sbin/service redis-server_ta-app start' returned 6: Failed to start redis-server_ta-app.service: Unit redis-server_ta-app.service failed to load: No such file or directory.
Debug: Executing '/usr/sbin/service redis-server_ta-app status'

This could be solved by letting the systemctl do an enable command when first installing / preparing:

systemctl enable redis-server_ta-app
Synchronizing state for redis-server_ta-app.service with sysvinit using update-rc.d...
Executing /usr/sbin/update-rc.d redis-server_ta-app defaults
insserv: warning: script 'redis-server_ta-app' missing LSB tags and overrides
Executing /usr/sbin/update-rc.d redis-server_ta-app enable
update-rc.d: error: redis-server_ta-app Default-Start contains no runlevels, aborting.

/etc/init.d/redis-server_ta-app start
[ ok ] Starting redis-server_ta-app (via systemctl): redis-server_ta-app.service.

Would it be possible to update this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.