From 4802a721b96a0fac4a694bddf10f037698432d04 Mon Sep 17 00:00:00 2001 From: jordiprats Date: Mon, 21 Aug 2017 06:55:36 +0200 Subject: [PATCH 1/5] afegit requirepass --- CHANGELOG.md | 4 ++++ README.md | 1 + manifests/instance.pp | 1 + metadata.json | 2 +- templates/redisconf.erb | 4 ++++ 5 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fb98011..ba891a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## 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..5587ebe 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, diff --git a/manifests/instance.pp b/manifests/instance.pp index b1fb7dd..0d3bfe8 100644 --- a/manifests/instance.pp +++ b/manifests/instance.pp @@ -13,6 +13,7 @@ $unixsocket = undef, $unixsocketperm = '700', $listen_tcp = true, + $password = undef, ) { Exec { diff --git a/metadata.json b/metadata.json index e85bc33..6ab2c4d 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "eyp-redis", - "version": "0.1.1", + "version": "0.1.2", "author": "eyp", "summary": "multi instance redis", "license": "Apache-2.0", diff --git a/templates/redisconf.erb b/templates/redisconf.erb index 1252e75..300c189 100644 --- a/templates/redisconf.erb +++ b/templates/redisconf.erb @@ -3,12 +3,16 @@ daemonize yes 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 %> From 37857f1a6031e81ff8cfb5122be06a5d1122f346 Mon Sep 17 00:00:00 2001 From: jordiprats Date: Mon, 21 Aug 2017 19:49:41 +0200 Subject: [PATCH 2/5] ubuntu 16 --- CHANGELOG.md | 4 ++++ README.md | 1 + manifests/params.pp | 5 +++++ metadata.json | 2 +- 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba891a6..977a80c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## 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 diff --git a/README.md b/README.md index 5587ebe..7497e58 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,7 @@ Tested on: * CentOS 6 * CentOS 7 * Ubuntu 14.04 +* Ubuntu 16.04 ## Development 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 6ab2c4d..f90d4b7 100644 --- a/metadata.json +++ b/metadata.json @@ -35,7 +35,7 @@ }, { "operatingsystem": "Ubuntu", - "operatingsystemrelease": [ "14.04" ] + "operatingsystemrelease": [ "14.04", "16.04" ] } ], "requirements": [ From 34553beae3e90cd67ee2add795b3e0b0f091c3b8 Mon Sep 17 00:00:00 2001 From: jordiprats Date: Mon, 21 Aug 2017 19:50:47 +0200 Subject: [PATCH 3/5] canvi ver --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index f90d4b7..01519d6 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "eyp-redis", - "version": "0.1.2", + "version": "0.1.3", "author": "eyp", "summary": "multi instance redis", "license": "Apache-2.0", From 9fce943f1c5be165cbf1ad1243564ad822b6906b Mon Sep 17 00:00:00 2001 From: jordiprats Date: Mon, 21 Aug 2017 20:05:36 +0200 Subject: [PATCH 4/5] daemonize --- CHANGELOG.md | 4 ++ manifests/instance.pp | 87 +++++++++++++++++++++-------------------- metadata.json | 2 +- templates/redisconf.erb | 2 +- 4 files changed, 51 insertions(+), 44 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 977a80c..06d6472 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## 0.1.4 + +* added **daemonize** option to **redis::instance** + ## 0.1.3 * Ubuntu 16.04 support diff --git a/manifests/instance.pp b/manifests/instance.pp index 0d3bfe8..1e9e94f 100644 --- a/manifests/instance.pp +++ b/manifests/instance.pp @@ -14,6 +14,7 @@ $unixsocketperm = '700', $listen_tcp = true, $password = undef, + $daemonize = true, ) { Exec { @@ -44,57 +45,59 @@ content => template("${module_name}/redisconf.erb"), } - 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, + } } - } + } } - } diff --git a/metadata.json b/metadata.json index 01519d6..1ce381d 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "eyp-redis", - "version": "0.1.3", + "version": "0.1.4", "author": "eyp", "summary": "multi instance redis", "license": "Apache-2.0", diff --git a/templates/redisconf.erb b/templates/redisconf.erb index 300c189..19c46e6 100644 --- a/templates/redisconf.erb +++ b/templates/redisconf.erb @@ -1,6 +1,6 @@ # puppet managed file -daemonize yes +daemonize <%= scope.function_bool2yesno([@daemonize]) %> pidfile /var/run/redis-<%= @redis_instancename %>/redis.pid From 624672384cbfabc6bd134231c4eb3490c84fa849 Mon Sep 17 00:00:00 2001 From: jordiprats Date: Mon, 21 Aug 2017 21:51:29 +0200 Subject: [PATCH 5/5] bugfix --- CHANGELOG.md | 4 ++++ manifests/instance.pp | 9 +++++---- metadata.json | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 06d6472..f4e8273 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## 0.1.5 + +* bugfix **redis::instance** service notifications with **daemonize** set to false + ## 0.1.4 * added **daemonize** option to **redis::instance** diff --git a/manifests/instance.pp b/manifests/instance.pp index 1e9e94f..51b3363 100644 --- a/manifests/instance.pp +++ b/manifests/instance.pp @@ -41,9 +41,9 @@ 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($daemonize) { @@ -93,11 +93,12 @@ if($manage_service) { service { "redis-${name}": - ensure => $ensure, - enable => $enable, + ensure => $ensure, + enable => $enable, + subscribe => File["/etc/redis/redis-${redis_instancename}.conf"], } } - } + } } } diff --git a/metadata.json b/metadata.json index 1ce381d..b8d1511 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "eyp-redis", - "version": "0.1.4", + "version": "0.1.5", "author": "eyp", "summary": "multi instance redis", "license": "Apache-2.0",