From 3e96a8e09d063f14542b93f14f741216bfb4fa38 Mon Sep 17 00:00:00 2001 From: prachetas Date: Tue, 10 Nov 2015 12:51:10 -0500 Subject: [PATCH 1/3] Makes Redis installation optional in Sentinel setup --- manifests/sentinel.pp | 1 + 1 file changed, 1 insertion(+) diff --git a/manifests/sentinel.pp b/manifests/sentinel.pp index fa9c3ed..fe340f7 100644 --- a/manifests/sentinel.pp +++ b/manifests/sentinel.pp @@ -47,6 +47,7 @@ $service_restart = true, $manage_upstart_scripts = true, $package_name = undef, + $package_ensure = 'present', ) { include redis::sentinel_params From 7137d7c340bef322e3a0505c98af4363a1dd455c Mon Sep 17 00:00:00 2001 From: prachetas Date: Tue, 10 Nov 2015 13:39:48 -0500 Subject: [PATCH 2/3] Runs sentinel conf file copy exec as root instead of redis --- manifests/sentinel.pp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/manifests/sentinel.pp b/manifests/sentinel.pp index fe340f7..8616050 100644 --- a/manifests/sentinel.pp +++ b/manifests/sentinel.pp @@ -124,9 +124,7 @@ exec { "cp ${conf_sentinel_orig} ${conf_sentinel}": path => '/bin:/usr/bin:/sbin:/usr/sbin', refreshonly => true, - user => redis, - group => redis, - notify => Service['sentinel'], + notify => Service['sentinel'], require => File[$conf_sentinel], } From ffa228b0c279bc1d4251032ccf9f902518bb2f5b Mon Sep 17 00:00:00 2001 From: prachetas Date: Tue, 10 Nov 2015 13:51:20 -0500 Subject: [PATCH 3/3] Adds bind parameter to sentinel config --- manifests/sentinel.pp | 1 + templates/sentinel.conf.erb | 15 +++++++++++---- tests/sentinel.pp | 1 + 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/manifests/sentinel.pp b/manifests/sentinel.pp index 8616050..6761811 100644 --- a/manifests/sentinel.pp +++ b/manifests/sentinel.pp @@ -39,6 +39,7 @@ # Copyright 2013 Felipe Salum, unless otherwise noted. # class redis::sentinel ( + $conf_bind = '0.0.0.0', $conf_port = '26379', $conf_daemonize = 'yes', $sentinel_confs = [], diff --git a/templates/sentinel.conf.erb b/templates/sentinel.conf.erb index a7f3d73..3f1503a 100644 --- a/templates/sentinel.conf.erb +++ b/templates/sentinel.conf.erb @@ -14,6 +14,14 @@ pidfile <%= @conf_pidfile_real %> port <%= @conf_port %> <%- end -%> +# If you want you can bind a single interface, if the bind option is not +# specified all the interfaces will listen for incoming connections. +# +# bind 127.0.0.1 +<%- if @conf_bind -%> +bind <%= @conf_bind %> +<%- end -%> + # Specify the log file name. Also 'stdout' can be used to force # Redis to log on the standard output. Note that if you use standard # output for logging but daemonize, logs will be sent to /dev/null @@ -134,7 +142,7 @@ sentinel <%= key %> <%= master %> <%= @sentinel_confs[master][key] %> # NOTIFICATION SCRIPT # # sentinel notification-script -# +# # Call the specified notification script for any sentinel event that is # generated in the WARNING level (for instance -sdown, -odown, and so forth). # This script should notify the system administrator via email, SMS, or any @@ -158,14 +166,14 @@ sentinel <%= key %> <%= master %> <%= @sentinel_confs[master][key] %> # When the master changed because of a failover a script can be called in # order to perform application-specific tasks to notify the clients that the # configuration has changed and the master is at a different address. -# +# # The following arguments are passed to the script: # # # # is currently always "failover" # is either "leader" or "observer" -# +# # The arguments from-ip, from-port, to-ip, to-port are used to communicate # the old address of the master and the new address of the elected slave # (now a master). @@ -175,4 +183,3 @@ sentinel <%= key %> <%= master %> <%= @sentinel_confs[master][key] %> # Example: # # sentinel client-reconfig-script mymaster /var/redis/reconfig.sh - diff --git a/tests/sentinel.pp b/tests/sentinel.pp index 8f4ee53..0c207eb 100644 --- a/tests/sentinel.pp +++ b/tests/sentinel.pp @@ -18,6 +18,7 @@ } class { 'redis::sentinel': + conf_bind => '127.0.0.1', conf_port => '26379', sentinel_confs => { 'mymaster' => {