Skip to content

Commit 2bea0fe

Browse files
author
Ciprian Badescu
committed
(MODULES-9846) fix install using cached catalog
In case a cached catalog requesting puppet agent installation is applied, the install script executes msi install and service restart each time is run. With this correction, the puppet agent package version is checked against aio_agent_version fact and install continues only if there is no match.
1 parent d1c5634 commit 2bea0fe

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

manifests/install/windows.pp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@
6161
-PuppetStartType '${_agent_startup_mode}' \
6262
-InstallArgs '${_install_options}' \
6363
${_move_dll_workaround}",
64+
unless => "${::system32}\\WindowsPowerShell\\v1.0\\powershell.exe \
65+
-ExecutionPolicy Bypass \
66+
-NoProfile \
67+
-NoLogo \
68+
-NonInteractive \
69+
-Command {\$CurrentVersion = [string](facter.bat -p aio_agent_version); \
70+
if (\$CurrentVersion -eq '${puppet_agent::_expected_package_version}') { \
71+
exit 0; \
72+
} \
73+
exit 1; }.Invoke()",
6474
path => $::path,
6575
require => [
6676
Puppet_agent_upgrade_error['puppet_agent_upgrade_failure.log'],

spec/classes/puppet_agent_windows_install_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,17 @@
7373
end
7474
end
7575

76+
context 'package_version =>' do
77+
describe '5.6.7' do
78+
let(:params) { global_params.merge(
79+
{:package_version => '5.6.7'})
80+
}
81+
it {
82+
is_expected.to contain_exec('install_puppet.ps1').with_unless(/\-Command {\$CurrentVersion = \[string\]\(facter.bat \-p aio_agent_version\);/)
83+
is_expected.to contain_exec('install_puppet.ps1').with_unless(/\-Command.*if \(\$CurrentVersion \-eq '5\.6\.7'\) { +exit 0; *} *exit 1; }\.Invoke\(\)/)
84+
}
85+
end
86+
end
7687
context 'install_options =>' do
7788
describe 'OPTION1=value1 OPTION2=value2' do
7889
let(:params) { global_params.merge(

0 commit comments

Comments
 (0)