From b1ad4092ca5ead4904f8e160e0b366f05113e622 Mon Sep 17 00:00:00 2001 From: Tom McLaughlin Date: Sun, 17 Aug 2014 21:06:30 -0400 Subject: [PATCH] the redis_version fact isn't always accurate on the first Puppet run. It's calculated at the start of the run which can be problematic when a package repo is introduced during the run containing a newer Redis version or no Redis package was available at the start of the run. In the first case the fact will assume the lower version but during the run after realizing a package repo containing a newer version a file resource just set 'ensure => present' will install the later version and result in a mismateched config file. In the second sccenario redis_version will be nil and result in a blank config file. This change will: - changes the template to use $redis_version_real - if $redis_version_override is set then $redis_version_real will be set to that in order to handle the nil case in the fact. - if $package_version is set to a package version then $redis_version_real will be set from that or use $redis_version --- manifests/init.pp | 13 +++++++++++++ templates/redis.conf.erb | 8 ++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 2466865..110004a 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -99,6 +99,7 @@ $conf_zset_max_ziplist_value = '64', # 2.4+ $package_ensure = 'present', $package_name = undef, + $redis_version_override = undef, $service_enable = true, $service_ensure = 'running', $service_restart = true, @@ -111,6 +112,18 @@ $conf_logrotate = $redis::params::conf_logrotate $service = $redis::params::service + if $redis_version_override { + $redis_version_real = $redis_version_override + } else { + $redis_version_real = $package_ensure ? { + /2\.2\..*/ => '2.2.x', + /2\.4\..*/ => '2.4.x', + /2\.6\..*/ => '2.6.x', + /2\.8\..*/ => '2.8.x', + default => $::redis_version + } + } + if $package_name { $package = $package_name }else{ diff --git a/templates/redis.conf.erb b/templates/redis.conf.erb index 3696590..aec4179 100644 --- a/templates/redis.conf.erb +++ b/templates/redis.conf.erb @@ -1,4 +1,4 @@ -<%- if @redis_version == "2.2.x" -%> +<%- if @redis_version_real == "2.2.x" -%> # MANAGED BY PUPPET # # # Redis 2.2 configuration file example @@ -545,7 +545,7 @@ include <%= include %><%= "\n" -%> <%- end -%> <%- end -%> <%- end -%> -<%- if @redis_version == "2.4.x" -%> +<%- if @redis_version_real == "2.4.x" -%> # MANAGED BY PUPPET # # # Redis 2.4 configuration file example @@ -1174,7 +1174,7 @@ include <%= include %><%= "\n" -%> <%- end -%> <%- end -%> <%- end -%> -<%- if @redis_version == "2.6.x" -%> +<%- if @redis_version_real == "2.6.x" -%> # MANAGED BY PUPPET # # # Redis 2.6 configuration file example @@ -1903,7 +1903,7 @@ include <%= include %><%= "\n" -%> <%- end -%> <%- end -%> <%- end -%> -<%- if @redis_version == "2.8.x" -%> +<%- if @redis_version_real == "2.8.x" -%> # MANAGED BY PUPPET # # # Redis 2.8 configuration file example