• Stars
    star
    297
  • Rank 140,075 (Top 3 %)
  • Language
    HTML
  • License
    Apache License 2.0
  • Created over 12 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Development repository for the redisio cookbook

Redisio Cookbook

Cookbook Version Build Status OpenCollective OpenCollective License

Please read the changelog when upgrading from the 1.x series to the 2.x series

Description

Website:: https://github.com/sous-chefs/redisio

Installs and configures Redis server instances

Maintainers

This cookbook is maintained by the Sous Chefs. The Sous Chefs are a community of Chef cookbook maintainers working together to maintain important cookbooks. If you’d like to know more please visit sous-chefs.org or come chat with us on the Chef Community Slack in #sous-chefs.

Requirements

This cookbook builds redis from source or install it from packages, so it should work on any architecture for the supported distributions. Init scripts are installed into /etc/init.d/

It depends on the ulimit cookbook: https://github.com/bmhatfield/chef-ulimit and the build-essentials cookbook: https://github.com/chef-cookbooks/build-essential

Platforms

  • Debian, Ubuntu
  • CentOS, Red Hat, Fedora, Scientific Linux
  • FreeBSD

Testing

This cookbook is tested with Delivery's local mode run under Chef-DK and Test Kitchen

  • delivery local all
  • kitchen test

Tested on:

  • Centos 6
  • Centos 7
  • Debian 8
  • Fedora 28
  • Ubuntu 16.04

Usage

The redisio cookbook contains LWRP for installing, configuring and managing redis and redis_sentinel.

The install recipe can build, compile and install redis from sources or install from packages. The configure recipe will configure redis and set up service resources. These resources will be named for the port of the redis server, unless a "name" attribute was specified. Example names would be: service["redis6379"] or service["redismaster"] if the name attribute was "master". NOTE: currently installation from source is not supported for FreeBSD

The most common use case for the redisio cookbook is to use the default recipe, followed by the enable recipe.

Another common use case is to use the default, and then call the service resources created by it from another cookbook.

It is important to note that changing the configuration options of redis does not make them take effect on the next chef run. Due to how redis works, you cannot reload a configuration without restarting the redis service. Redis does not offer a reload option, in order to have new options be used redis must be stopped and started.

You should make sure to set the ulimit for the user you want to run redis as to be higher than the max connections you allow. NOTE: setting ulimit is not supported on FreeBSD since the ulimit cookbook doesn't support FreeBSD

The disable recipe just stops redis and removes it from run levels.

The cookbook also contains a recipe to allow for the installation of the redis ruby gem.

Redis-sentinel will write configuration and state data back into its configuration file. This creates obvious problems when that config is managed by chef. By default, this cookbook will create the config file once, and then leave a breadcrumb that will guard against the file from being updated again.

Recipes

  • configure - This recipe is used to configure redis.
  • default - This is used to install the pre-requisites for building redis, and to make the LWRPs available
  • disable - This recipe can be used to disable the redis service and remove it from runlevels
  • enable - This recipe can be used to enable the redis services and add it to runlevels
  • install - This recipe is used to install redis.
  • redis_gem - This recipe can be used to install the redis ruby gem
  • sentinel - This recipe can be used to install and configure sentinel
  • sentinel_enable - This recipe can be used to enable the sentinel service(s)
  • disable_os_default - This recipe can be used to disable the default OS redis init script

Role File Examples

Install redis and set up an instance with default settings on default port, and start the service through a role file

run_list *%w[
  recipe[redisio]
  recipe[redisio::enable]
]

default_attributes({})
Install redis with packages and set up an instance with default settings on default port, and start the service through a role file
run_list *%w[
  recipe[redisio]
  recipe[redisio::enable]
]

default_attributes({
  'redisio' => {
    package_install: true
    version:
  }
})
Install redis, give the instance a name, and use a unix socket
run_list *%w[
  recipe[redisio]
  recipe[redisio::enable]
]

default_attributes({
  'redisio' => {
    'servers' => [
      {'name' => 'master', 'port' => '6379', 'unixsocket' => '/tmp/redis.sock', 'unixsocketperm' => '755'},
    ]
  }
})
Install redis and pull the password from an encrypted data bag
run_list *%w[
  recipe[redisio]
  recipe[redisio::enable]
]

default_attributes({
  'redisio' => {
    'servers' => [
      {'data_bag_name' => 'redis', 'data_bag_item' => 'auth', 'data_bag_key' => 'password'},
    ]
  }
})
Data Bag
{
    "id": "auth",
    "password": "abcdefghijklmnopqrstuvwxyz"
}
Install redis and set up two instances on the same server, on different ports, with one slaved to the other through a role file
run_list *%w[
  recipe[redisio]
  recipe[redisio::enable]
]

default_attributes({
  'redisio' => {
    'servers' => [
      {'port' => '6379'},
      {'port' => '6380', 'slaveof' => { 'address' => '127.0.0.1', 'port' => '6379' }}
    ]
  }
})
Install redis and set up two instances, on the same server, on different ports, with the default data directory changed to /mnt/redis, and the second instance named
run_list *%w[
  recipe[redisio]
  recipe[redisio::enable]
]

default_attributes({
  'redisio' => {
    'default_settings' => {'datadir' => '/mnt/redis'},
    'servers' => [{'port' => '6379'}, {'port' => '6380', 'name' => "MyInstance"}]
  }
})
Install redis and set up three instances on the same server, changing the default data directory to /mnt/redis, each instance will use a different backup type, and one instance will use a different data dir
run_list *%w[
  recipe[redisio]
  recipe[redisio::enable]
]

default_attributes({
  'redisio' => {
    'default_settings' => { 'datadir' => '/mnt/redis/'},
    'servers' => [
      {'port' => '6379','backuptype' => 'aof'},
      {'port' => '6380','backuptype' => 'both'},
      {'port' => '6381','backuptype' => 'rdb', 'datadir' => '/mnt/redis6381'}
    ]
  }
})
Install redis 2.4.11 (lower than the default version) and turn safe install off, for the event where redis is already installed This will use the default settings. Keep in mind the redis version will not actually be updated until you restart the service (either through the LWRP or manually)
run_list *%w[
  recipe[redisio]
  recipe[redisio::enable]
]

default_attributes({
  'redisio' => {
    'safe_install' => false,
    'version'      => '2.4.11'
  }
})
Install a single redis-sentinel to listen for a master on localhost and default port number
run_list *%w[
  recipe[redisio::sentinel]
  recipe[redisio::sentinel_enable]
]

Install redis and set up two instances, on the same server, on different ports, the second instance configuration file will be overwriten by chef

run_list *%w[
  recipe[redisio]
  recipe[redisio::enable]
]

default_attributes({
  'redisio' => {
    'servers' => [{'port' => '6379'}, {'port' => '6380', 'breadcrumb' => false}]
  }
})

LWRP Examples

Instead of using my provided recipes, you can simply depend on the redisio cookbook in your metadata and use the LWRP's yourself. I will show a few examples of ways to use the LWRPS, detailed breakdown of options are below in the resources/providers section

Install Resource

It is important to note that this call has certain expectations for example, it expects the redis package to be in the format `redis-VERSION.tar.gz'.

redisio_install "redis-installation" do
  version '2.6.9'
  download_url 'http://redis.googlecode.com/files/redis-2.6.9.tar.gz'
  safe_install false
  install_dir '/usr/local/'
end

Configure Resource

The servers resource expects an array of hashes where each hash is required to contain at a key-value pair of 'port' => 'port numbers'.

redisio_configure "redis-servers" do
  version '2.6.9'
  default_settings node['redisio']['default_settings']
  servers node['redisio']['servers']
  base_piddir node['redisio']['base_piddir']
end

Sentinel Resource

The sentinel resource installs and configures all of your redis_sentinels defined in sentinel_instances

Using the sentinel resources:

redisio_sentinel "redis-sentinels" do
  version '2.6.9'
  sentinel_defaults node['redisio']['sentinel_defaults']
  sentinels sentinel_instances
  base_piddir node['redisio']['base_piddir']
end

Attributes

Configuration options, each option corresponds to the same-named configuration option in the redis configuration file; default values listed

  • redisio['mirror'] - mirror server with path to download redis package, default is http://download.redis.io/releases/
  • redisio['base_name'] - the base name of the redis package to be downloaded (the part before the version), default is 'redis-'
  • redisio['artifact_type'] - the file extension of the package. currently only .tar.gz and .tgz are supported, default is 'tar.gz'
  • redisio['version'] - the version number of redis to install (also appended to the base_name for downloading), default is '2.8.17'
  • redisio['safe_install'] - prevents redis from installing itself if another version of redis is installed, default is true
  • redisio['base_piddir'] - This is the directory that redis pidfile directories and pidfiles will be placed in. Since redis can run as non root, it needs to have proper permissions to the directory to create its pid. Since each instance can run as a different user, these directories will all be nested inside this base one.
  • redisio['bypass_setup'] - This attribute allows users to prevent the default recipe from calling the install and configure recipes.
  • redisio['job_control'] - This deteremines what job control type will be used. Currently supports 'initd' or 'upstart' options. Defaults to 'initd'.

Default settings is a hash of default settings to be applied to to ALL instances. These can be overridden for each individual server in the servers attribute. If you are going to set logfile to a specific file, make sure to set syslog-enabled to no.

  • redisio['default_settings'] - { 'redis-option' => 'option setting' }

Available options and their defaults

'user'                    => 'redis' - the user to own the redis datadir, redis will also run under this user
'group'                   => 'redis' - the group to own the redis datadir
'permissions'             => '0644' - the unix permissions applied to the server config file
'homedir'                 => Home directory of the user. Varies on distribution, check attributes file
'shell'                   => Users shell. Varies on distribution, check attributes file
'systemuser'              => true - Sets up the instances user as a system user
'ulimit'                  => 0 - 0 is a special value causing the ulimit to be maxconnections +32.  Set to nil or false to disable setting ulimits
'configdir'               => '/etc/redis' - configuration directory
'name'                    => nil, Allows you to name the server with something other than port.  Useful if you want to use unix sockets
'tcpbacklog'              => '511',
'address'                 => nil, Can accept a single string or an array. When using an array, the FIRST value will be used by the init script for connecting to redis
'databases'               => '16',
'backuptype'              => 'rdb',
'datadir'                 => '/var/lib/redis',
'unixsocket'              => nil - The location of the unix socket to use,
'unixsocketperm'          => nil - The permissions of the unix socket,
'timeout'                 => '0',
'keepalive'               => '0',
'loglevel'                => 'notice',
'logfile'                 => nil,
'syslogenabled'           => 'yes',
'syslogfacility'          => 'local0',
'shutdown_save'           => false,
'save'                    => nil, # Defaults to ['900 1','300 10','60 10000'] inside of template.  Needed due to lack of hash subtraction
'stopwritesonbgsaveerror' => 'yes',
'rdbcompression'          => 'yes',
'rdbchecksum'             => 'yes',
'dbfilename'              => nil,
'slaveof'                 => nil,
'masterauth'              => nil,
'slaveservestaledata'     => 'yes',
'slavereadonly'           => 'yes',
'repldisklesssync'        => 'no', # Requires redis 2.8.18+
'repldisklesssyncdelay'   => '5', # Requires redis 2.8.18+
'replpingslaveperiod'     => '10',
'repltimeout'             => '60',
'repldisabletcpnodelay    => 'no',
'slavepriority'           => '100',
'requirepass'             => nil,
'rename_commands'         => nil, or a hash where each key is a redis command and the value is the command's new name.
'maxclients'              => 10000,
'maxmemory'               => nil,
'maxmemorypolicy'         => nil,
'maxmemorysamples'        => nil,
'appendfilename'          => nil,
'appendfsync'             => 'everysec',
'noappendfsynconrewrite'  => 'no',
'aofrewritepercentage'    => '100',
'aofrewriteminsize'       => '64mb',
'luatimelimit'            => '5000',
'slowloglogslowerthan'    => '10000',
'slowlogmaxlen'           => '1024',
'notifykeyspaceevents'    => '',
'hashmaxziplistentries'   => '512',
'hashmaxziplistvalue'     => '64',
'listmaxziplistentries'   => '512',
'listmaxziplistvalue'     => '64',
'setmaxintsetentries'     => '512',
'zsetmaxziplistentries'   => '128',
'zsetmaxziplistvalue'     => '64',
'hllsparsemaxbytes'       => '3000',
'activerehasing'          => 'yes',
'clientoutputbufferlimit' => [
  %w(normal 0 0 0),
  %w(slave 256mb 64mb 60),
  %w(pubsub 32mb 8mb 60)
],
'hz'                         => '10',
'aofrewriteincrementalfsync' => 'yes',
'clusterenabled'             => 'no',
'clusterconfigfile'          => nil, # Defaults to redis instance name inside of template if cluster is enabled.
'clusternodetimeout'         => 5000,
'includes'                   => nil,
'breadcrumb'                 => true # Defaults to create breadcrumb lock-file.
  • redisio['servers'] - An array where each item is a set of key value pairs for redis instance specific settings. The only required option is 'port'. These settings will override the options in 'default_settings', if it is left nil it will default to [{'port' => '6379'}]. If set to [] (empty array), no instances will be created.

The redis_gem recipe will also allow you to install the redis ruby gem, these are attributes related to that, and are in the redis_gem attributes file.

  • redisio['gem']['name'] - the name of the gem to install, defaults to 'redis'
  • redisio['gem']['version'] - the version of the gem to install. if it is nil, the latest available version will be installed.

The sentinel recipe's use their own attribute file.

  • redisio['sentinel_defaults'] - { 'sentinel-option' => 'option setting' }
'user'                    => 'redis',
'configdir'               => '/etc/redis',
'sentinel_bind'           => nil,
'sentinel_port'           => 26379,
'monitor'                 => nil,
'down-after-milliseconds' => 30000,
'can-failover'            => 'yes',
'parallel-syncs'          => 1,
'failover-timeout'        => 900000,
'loglevel'                => 'notice',
'logfile'                 => nil,
'syslogenabled'           => 'yes',
'syslogfacility'          => 'local0',
'quorum_count'            => 2,
'protected-mode'          => nil,
  • redisio['redisio']['sentinel']['manage_config'] - Should the cookbook manage the redis and redis sentinel config files. This is best set to false when using redis_sentinel as it will write state into both configuration files.

  • redisio['redisio']['sentinels'] - Array of sentinels to configure on the node. These settings will override the options in 'sentinel_defaults', if it is left nil it will default to [{'port' => '26379', 'name' => 'mycluster', 'master_ip' => '127.0.0.1', 'master_port' => 6379}]. If set to [] (empty array), no instances will be created.

You may also pass an array of masters to monitor like so:

[{
  'sentinel_port' => '26379',
  'name' => 'mycluster_sentinel',
  'masters' => [
    { 'master_name' => 'master6379', 'master_ip' => '127.0.0.1', 'master_port' => 6379 },
    { 'master_name' => 'master6380', 'master_ip' => '127.0.0.1', 'master_port' => 6380 }
  ]

}]

Resources/Providers

install

Actions:

  • run - perform the install (default)
  • nothing - do nothing

Attribute Parameters

  • version - the version of redis to download / install
  • download_url - the URL plus filename of the redis package to install
  • download_dir - the directory to store the downloaded package
  • artifact_type - the file extension of the package
  • base_name - the name of the package minus the extension and version number
  • safe_install - a true or false value which determines if a version of redis will be installed if one already exists, defaults to true

This resource expects the following naming conventions:

package file should be in the format base_nameVersion_number.artifact_type

package file after extraction should be inside of the directory base_nameVersion_number

install "redis" do
  action [:run,:nothing]
end

configure

Actions:

  • run - perform the configure (default)
  • nothing - do nothing

Attribute Parameters

  • version - the version of redis to download / install
  • base_piddir - directory where pid files will be created
  • user - the user to run redis as, and to own the redis files
  • group - the group to own the redis files
  • default_settings - a hash of the default redis server settings
  • servers - an array of hashes containing server configurations overrides (port is the only required)
configure "redis" do
  action [:run,:nothing]
end

Contributors

This project exists thanks to all the people who contribute.

Backers

Thank you to all our backers!

https://opencollective.com/sous-chefs#backers

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website.

https://opencollective.com/sous-chefs/sponsor/0/website https://opencollective.com/sous-chefs/sponsor/1/website https://opencollective.com/sous-chefs/sponsor/2/website https://opencollective.com/sous-chefs/sponsor/3/website https://opencollective.com/sous-chefs/sponsor/4/website https://opencollective.com/sous-chefs/sponsor/5/website https://opencollective.com/sous-chefs/sponsor/6/website https://opencollective.com/sous-chefs/sponsor/7/website https://opencollective.com/sous-chefs/sponsor/8/website https://opencollective.com/sous-chefs/sponsor/9/website

More Repositories

1

docker

Development repository for the docker cookbook
Ruby
1,348
star
2

elasticsearch

Development repository for the elasticsearch cookbook
Ruby
882
star
3

aws

Development repository for the aws cookbook
Ruby
594
star
4

nginx

Development repository for the nginx cookbook
Ruby
551
star
5

rvm

Development repository for the rvm cookbook
Ruby
516
star
6

php

Development repository for the php cookbook
HTML
445
star
7

jenkins

Development repository for the jenkins cookbook
Ruby
424
star
8

java

Development repository for the java cookbook
Ruby
397
star
9

postgresql

Development repository for the postgresql cookbook
Ruby
357
star
10

mysql

Development repository for the mysql cookbook
Ruby
336
star
11

ruby_rbenv

Development repository for the ruby_rbenv cookbook
Ruby
332
star
12

apache2

Development repository for the apache2 cookbook
Ruby
282
star
13

nodejs

Development repository for the nodejs cookbook
Ruby
228
star
14

apt

Development repository for the apt cookbook
Ruby
203
star
15

consul

Development repository for the consul cookbook
Ruby
191
star
16

haproxy

Development repository for the haproxy cookbook
Ruby
156
star
17

graphite

Development repository for the graphite cookbook
Ruby
154
star
18

homebrew

Development repository for the homebrew cookbook
Ruby
151
star
19

users

Development repository for the users cookbook
Ruby
138
star
20

nagios

Development repository for the nagios cookbook
Ruby
125
star
21

ruby_build

Development repository for the ruby_build cookbook
Ruby
123
star
22

git

Development repository for the git cookbook
Ruby
123
star
23

logrotate

Development repository for the logrotate cookbook
Ruby
122
star
24

percona

Development repository for the percona cookbook
Ruby
117
star
25

openssh

Development repository for the openssh cookbook
Ruby
114
star
26

powershell

Development repository for the powershell cookbook
Ruby
110
star
27

postfix

Development repository for the postfix cookbook
Ruby
103
star
28

tomcat

Development repository for the tomcat cookbook
Ruby
99
star
29

openvpn

Development repository for the openvpn cookbook
Ruby
98
star
30

ark

Development repository for the ark cookbook
Ruby
98
star
31

line

Development repository for the line cookbook
Ruby
97
star
32

firewall

Development repository for the firewall cookbook
Ruby
95
star
33

yum

Development repository for the yum cookbook
Ruby
95
star
34

kafka

Development repository for the kafka cookbook
Ruby
91
star
35

erlang

Development repository for the erlang cookbook
Ruby
87
star
36

sublimechef

A Sublime Text 2 Package for authoring Chef related files
84
star
37

iis

Development repository for the iis cookbook
Ruby
82
star
38

etcd

Development repository for the etcd cookbook
Ruby
79
star
39

cron

Development repository for the cron cookbook
Ruby
77
star
40

grafana

Development repository for the grafana cookbook
Ruby
76
star
41

chef-splunk

Development repository for the chef-splunk cookbook
Ruby
76
star
42

sc-mongodb

Development repository for the sc-mongodb cookbook
Ruby
75
star
43

certificate

Development repository for the certificate cookbook
Ruby
73
star
44

ntp

Development repository for the ntp cookbook
Ruby
68
star
45

rsyslog

Development repository for the rsyslog cookbook
Ruby
65
star
46

sql_server

Development repository for the sql_server cookbook
Ruby
63
star
47

fail2ban

Development repository for the fail2ban cookbook
Ruby
58
star
48

selinux

Development repository for the selinux cookbook
Ruby
58
star
49

windows_ad

Development repository for the windows_ad cookbook
Ruby
58
star
50

vagrant

Development repository for the vagrant cookbook
Ruby
57
star
51

varnish

Development repository for the varnish cookbook
Ruby
56
star
52

lvm

Development repository for the lvm cookbook
Ruby
56
star
53

perl

Development repository for the perl cookbook
Ruby
52
star
54

golang

Development repository for the golang cookbook
Ruby
50
star
55

memcached

Development repository for the memcached cookbook
Ruby
49
star
56

mariadb

Development repository for the mariadb cookbook
Ruby
48
star
57

hashicorp-vault

Development repository for the hashicorp-vault cookbook
Ruby
46
star
58

rundeck

Development repository for the rundeck cookbook
Ruby
46
star
59

ossec

Development repository for the ossec cookbook
Ruby
44
star
60

ufw

Development repository for the ufw cookbook
Ruby
44
star
61

confluence

Development repository for the confluence cookbook
Ruby
43
star
62

openldap

Development repository for the openldap cookbook
Ruby
42
star
63

nfs

Development repository for the nfs cookbook
Ruby
40
star
64

kubernetes

Development repository for the kubernetes cookbook
Ruby
39
star
65

vim

Development repository for the vim cookbook
Ruby
38
star
66

maven

Development repository for the maven cookbook
Ruby
36
star
67

bind

Development repository for the bind cookbook
Ruby
36
star
68

passenger_apache2

Development repository for the passenger_apache2 cookbook
Ruby
36
star
69

keepalived

Development repository for the keepalived cookbook
Ruby
33
star
70

aptly

Development repository for the aptly cookbook
Ruby
31
star
71

samba

Development repository for the samba cookbook
Ruby
30
star
72

resolver

Development repository for the resolver cookbook
Ruby
28
star
73

squid

Development repository for the squid cookbook
Ruby
28
star
74

snort

Development repository for the snort cookbook
Ruby
27
star
75

pyenv

Development repository for the pyenv cookbook
Ruby
27
star
76

freebsd

Development repository for the freebsd cookbook
Ruby
27
star
77

dhcp

Development repository for the dhcp cookbook
Ruby
27
star
78

nrpe

Development repository for the nrpe cookbook
Ruby
25
star
79

rsync

Development repository for the rsync cookbook
Ruby
24
star
80

github

Development repository for the github cookbook
Ruby
24
star
81

filesystem

Development repository for the filesystem cookbook
Ruby
24
star
82

yum-epel

Development repository for the yum-epel cookbook
Ruby
23
star
83

network_interfaces

Development repository for the network_interfaces cookbook
Ruby
23
star
84

drbd

Development repository for the drbd cookbook
Ruby
19
star
85

djbdns

Development repository for the djbdns cookbook
Ruby
19
star
86

sssd_ldap

Development repository for the sssd_ldap cookbook
Ruby
18
star
87

dpkg_autostart

Development repository for the dpkg_autostart cookbook
Ruby
18
star
88

packagecloud

Development repository for the packagecloud cookbook
Ruby
17
star
89

webpi

Development repository for the webpi cookbook
Ruby
17
star
90

gems

Development repository for the gems cookbook
Ruby
17
star
91

language-chef

Development repository for the language-chef plugin for the Atom text editor
JavaScript
17
star
92

elixir

Development repository for the elixir cookbook
Ruby
17
star
93

htpasswd

Development repository for the htpasswd cookbook
Ruby
15
star
94

stunnel

Development repository for the stunnel cookbook
Ruby
14
star
95

apparmor

Development repository for the apparmor cookbook
Ruby
14
star
96

smartmontools

Development repository for the smartmontools cookbook
HTML
13
star
97

transmission

Development repository for the transmission cookbook
Ruby
13
star
98

gpg

Development repository for the gpg cookbook
Ruby
12
star
99

wix

Development repository for the wix cookbook
Ruby
12
star
100

tftp

Development repository for the tftp cookbook
Ruby
11
star