-
-
Notifications
You must be signed in to change notification settings - Fork 269
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve version handling to avoid multiple puppet runs for some situa…
…tions When an administrator knows the version of collectd that will be used or at least the minimum version available the need for two puppet runs before convergence can be avoided or at least minimised. Instead of using the fact in the templates they now use a class variable set to one of (in priority order): * collectd_real_version (i.e. the fact) * version (the semver matched part of it only) * minimum_version (undef by default) Existing behaviour is preserved except for a corner case where version is set to something specific and collectd is not yet installed. In this case puppet will only take one run and assume the version specified when creating the templates references #162
- Loading branch information
1 parent
07378b4
commit 8c5e8ba
Showing
7 changed files
with
108 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
lib/facter/collectd_version.rb → lib/facter/collectd_real_version.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
require 'spec_helper' | ||
|
||
describe 'test::collectd_version' do | ||
|
||
let :facts do | ||
{:osfamily => 'RedHat'} | ||
end | ||
|
||
it { should compile } | ||
|
||
context 'when no explicit value is specified' do | ||
it { should contain_file('collectd_version.tmp').with_content(/^1\.0$/) } | ||
end | ||
|
||
context 'when minimum_version is specified' do | ||
let :params do | ||
{ | ||
:version => 'installed', | ||
:minimum_version => '5.4', | ||
} | ||
end | ||
it { should contain_file('collectd_version.tmp').with_content(/^5\.4$/) } | ||
end | ||
|
||
context 'when version is explicit and greater than minimum_version' do | ||
let :params do | ||
{ | ||
:version => '5.6.3', | ||
:minimum_version => '5.4', | ||
} | ||
end | ||
it { should contain_file('collectd_version.tmp').with_content(/^5\.6\.3$/) } | ||
end | ||
|
||
context 'when version is explicit and less than minimum_version' do | ||
let :params do | ||
{ | ||
:version => '5.3', | ||
:minimum_version => '5.4', | ||
} | ||
end | ||
it { should contain_file('collectd_version.tmp').with_content(/^5\.3$/) } | ||
end | ||
|
||
context 'when collectd_real_version is available' do | ||
let :facts do | ||
{ | ||
:osfamily => 'Redhat', | ||
:collectd_real_version => '5.6', | ||
} | ||
end | ||
let :params do | ||
{ | ||
:minimum_version => '5.4' | ||
} | ||
end | ||
it { should contain_file('collectd_version.tmp').with_content(/^5\.6$/) } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# class used solely to test the collectd_version expansion in init.pp | ||
# Note that fact collectd_real_version is also used by init.pp | ||
# Write the generated value to a template so we can test it | ||
class test::collectd_version( | ||
$version = undef, | ||
$minimum_version = undef, | ||
) { | ||
class { '::collectd': | ||
version => $version, | ||
minimum_version => $minimum_version, | ||
} | ||
|
||
file { 'collectd_version.tmp': | ||
ensure => file, | ||
path => '/tmp/collectd_version.tmp', | ||
content => template('test/collectd_version.tmp.erb'), | ||
require => Class['Collectd'], | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<%= scope.lookupvar('::collectd::collectd_version') %> |
6 changes: 3 additions & 3 deletions
6
spec/unit/collectd_version_spec.rb → spec/unit/collectd_real_version_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters