Skip to content

Commit

Permalink
(GH-646) Map windows MSI file versions to OS versions
Browse files Browse the repository at this point in the history
The OS expects version numbers to be dotted, e.g. 0.29.0.11, whereas the
file paths have a hyphen denoting the release component.  This patch
maps the file version ID to the package version ID to allow the catalog
to converge.
  • Loading branch information
jeffmccune committed Jun 29, 2017
1 parent a4cc1b3 commit d928ca6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
13 changes: 10 additions & 3 deletions manifests/package.pp
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,20 @@
'windows': {
$repo_require = undef

$pkg_version = $::sensu::version
$pkg_url_version = $pkg_version ? {
# $pkg_version is passed to Package[sensu] { ensure }. The Windows MSI
# provider translates hyphens to dots, e.g. '0.29.0-11' maps to
# '0.29.0.11' on the system. This mapping is necessary to converge.
$pkg_version = template('sensu/sensu-windows-package-version.erb')
# The version used to construct the download URL.
$pkg_url_version = $::sensu::version ? {
'installed' => 'latest',
default => $pkg_version,
default => $::sensu::version,
}
# The title used for consistent relationships in the Puppet catalog
$pkg_title = 'sensu'
# The name used by the provider to compare to Windows Add/Remove programs.
$pkg_name = 'Sensu'
# Where the MSI is downloaded to and installed from.
$pkg_source = "C:\\Windows\\Temp\\sensu-${pkg_url_version}.msi"
$pkg_require = "Remote_file[${pkg_title}]"

Expand Down
12 changes: 12 additions & 0 deletions spec/classes/sensu_package_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,18 @@
it { should contain_remote_file('sensu').with(
source: 'https://repositories.sensuapp.org/msi/2012r2/sensu-0.29.0-11-x64.msi',
) }
# The MSI provider will keep re-installing the package unless the
# version is translated into dotted form. e.g. 'Notice:
# /Stage[main]/Sensu::Package/Package[sensu]/ensure: ensure changed
# '0.29.0.11' to '0.29.0-11'
it 'translates 0.29.0-11 to 0.29.0.11' do
should contain_package('sensu').with(ensure: '0.29.0.11')
end
# The MSI provider checks Add/Remove programs. Package[sensu] is
# registered as "Sensu" so the name parameter must match.
it 'uses name "Sensu" to match Add/Remove Programs' do
should contain_package('sensu').with(name: 'Sensu')
end
end

context 'with windows_pkg_url specified' do
Expand Down
1 change: 1 addition & 0 deletions templates/sensu-windows-package-version.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= scope.lookupvar('sensu::version').gsub('-', '.') -%>

0 comments on commit d928ca6

Please sign in to comment.