diff --git a/CHANGELOG.md b/CHANGELOG.md index fb98011..f4e8273 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,21 @@ # CHANGELOG +## 0.1.5 + +* bugfix **redis::instance** service notifications with **daemonize** set to false + +## 0.1.4 + +* added **daemonize** option to **redis::instance** + +## 0.1.3 + +* Ubuntu 16.04 support + +## 0.1.2 + +* added **password** to **redis::instance** to be able to set a global password for redis + ## 0.1.1 * added unixsocket, unixsocketperm and listen_tcp to **redis::instance** diff --git a/README.md b/README.md index 5dd709b..7497e58 100644 --- a/README.md +++ b/README.md @@ -100,6 +100,7 @@ redis::instance { 'instance_B': * **datadir**: redis datadir (default: /var/lib/redis-${name}) * **redis_user**: redis username (default: redis) * **redis_group**: redis group (default: redis) + * **password**: optional password for redis (default: undef) * package and service related variables: * **ensure**: = 'running', * **manage_service**: = true, @@ -113,6 +114,7 @@ Tested on: * CentOS 6 * CentOS 7 * Ubuntu 14.04 +* Ubuntu 16.04 ## Development diff --git a/manifests/instance.pp b/manifests/instance.pp index b1fb7dd..51b3363 100644 --- a/manifests/instance.pp +++ b/manifests/instance.pp @@ -13,6 +13,8 @@ $unixsocket = undef, $unixsocketperm = '700', $listen_tcp = true, + $password = undef, + $daemonize = true, ) { Exec { @@ -39,61 +41,64 @@ group => 'root', mode => '0644', require => File['/etc/redis'], - notify => Service["redis-${redis_instancename}"], content => template("${module_name}/redisconf.erb"), } + # notify => Service["redis-${redis_instancename}"], - if($redis::params::systemd) + if($daemonize) { - include systemd + if($redis::params::systemd) + { + include systemd - file { '/usr/bin/redis-shutdown': - ensure => 'present', - owner => 'root', - group => 'root', - mode => '0755', - before => Service["redis-${redis_instancename}"], - content => template("${module_name}/initscripts/RH/shutdownredis.erb"), - } + file { '/usr/bin/redis-shutdown': + ensure => 'present', + owner => 'root', + group => 'root', + mode => '0755', + before => Service["redis-${redis_instancename}"], + content => template("${module_name}/initscripts/RH/shutdownredis.erb"), + } - systemd::service { "redis-${redis_instancename}": - execstart => "${redis::params::redisserver_bin} /etc/redis/redis-${redis_instancename}.conf", - execstop => "/usr/bin/redis-shutdown redis-${redis_instancename}", - type => 'forking', - before => Service["redis-${redis_instancename}"], - pid_file => "/var/run/redis-${redis_instancename}/redis.pid", - user => $redis_user, - group => $redis_group, - runtime_directory => [ "redis-${redis_instancename}" ], - runtime_directory_mode => '0755', + systemd::service { "redis-${redis_instancename}": + execstart => "${redis::params::redisserver_bin} /etc/redis/redis-${redis_instancename}.conf", + execstop => "/usr/bin/redis-shutdown redis-${redis_instancename}", + type => 'forking', + before => Service["redis-${redis_instancename}"], + pid_file => "/var/run/redis-${redis_instancename}/redis.pid", + user => $redis_user, + group => $redis_group, + runtime_directory => [ "redis-${redis_instancename}" ], + runtime_directory_mode => '0755', + } } - } - else - { - file { "/etc/init.d/redis-${name}": - ensure => 'present', - owner => 'root', - group => 'root', - mode => '0755', - before => Service["redis-${redis_instancename}"], - content => template("${module_name}/initscripts/${redis::params::os_flavor}/init.erb"), + else + { + file { "/etc/init.d/redis-${name}": + ensure => 'present', + owner => 'root', + group => 'root', + mode => '0755', + before => Service["redis-${redis_instancename}"], + content => template("${module_name}/initscripts/${redis::params::os_flavor}/init.erb"), + } } - } - $is_docker_container_var=getvar('::eyp_docker_iscontainer') - $is_docker_container=str2bool($is_docker_container_var) + $is_docker_container_var=getvar('::eyp_docker_iscontainer') + $is_docker_container=str2bool($is_docker_container_var) - if( $is_docker_container==false or - $manage_docker_service) - { - if($manage_service) + if( $is_docker_container==false or + $manage_docker_service) { - service { "redis-${name}": - ensure => $ensure, - enable => $enable, + if($manage_service) + { + service { "redis-${name}": + ensure => $ensure, + enable => $enable, + subscribe => File["/etc/redis/redis-${redis_instancename}.conf"], + } } } } - } diff --git a/manifests/params.pp b/manifests/params.pp index 08b7dd9..538e39d 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -43,6 +43,11 @@ $systemd=false $redisserver_bin='/usr/bin/redis-server' } + /^16.*$/: + { + $systemd=true + $redisserver_bin='/usr/bin/redis-server' + } default: { fail("Unsupported Ubuntu version! - ${::operatingsystemrelease}") } } } diff --git a/metadata.json b/metadata.json index e85bc33..b8d1511 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "eyp-redis", - "version": "0.1.1", + "version": "0.1.5", "author": "eyp", "summary": "multi instance redis", "license": "Apache-2.0", @@ -35,7 +35,7 @@ }, { "operatingsystem": "Ubuntu", - "operatingsystemrelease": [ "14.04" ] + "operatingsystemrelease": [ "14.04", "16.04" ] } ], "requirements": [ diff --git a/templates/redisconf.erb b/templates/redisconf.erb index 1252e75..19c46e6 100644 --- a/templates/redisconf.erb +++ b/templates/redisconf.erb @@ -1,14 +1,18 @@ # puppet managed file -daemonize yes +daemonize <%= scope.function_bool2yesno([@daemonize]) %> pidfile /var/run/redis-<%= @redis_instancename %>/redis.pid + <% if @listen_tcp -%> bind <%= @bind %> port <%= @port %> <% else -%> port 0 <% end -%> +<% if defined?(@password) -%> +requirepass "<%= @password %>" +<% end -%> <% if defined?(@unixsocket) -%> unixsocket <%= @unixsocket %>