Skip to content

Commit

Permalink
the redis_version fact isn't always accurate on the first Puppet run.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tmclaugh authored and Tom McLaughlin committed Aug 18, 2014
1 parent 84b4c41 commit b1ad409
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
13 changes: 13 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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{
Expand Down
8 changes: 4 additions & 4 deletions templates/redis.conf.erb
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b1ad409

Please sign in to comment.