From 2bea0fe4819e60902691f4454d57fe063a1842b7 Mon Sep 17 00:00:00 2001 From: Ciprian Badescu Date: Thu, 12 Sep 2019 16:35:25 +0300 Subject: [PATCH] (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. --- manifests/install/windows.pp | 10 ++++++++++ spec/classes/puppet_agent_windows_install_spec.rb | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/manifests/install/windows.pp b/manifests/install/windows.pp index 3505e2e98..1db2bf689 100644 --- a/manifests/install/windows.pp +++ b/manifests/install/windows.pp @@ -61,6 +61,16 @@ -PuppetStartType '${_agent_startup_mode}' \ -InstallArgs '${_install_options}' \ ${_move_dll_workaround}", + unless => "${::system32}\\WindowsPowerShell\\v1.0\\powershell.exe \ + -ExecutionPolicy Bypass \ + -NoProfile \ + -NoLogo \ + -NonInteractive \ + -Command {\$CurrentVersion = [string](facter.bat -p aio_agent_version); \ + if (\$CurrentVersion -eq '${puppet_agent::_expected_package_version}') { \ + exit 0; \ + } \ + exit 1; }.Invoke()", path => $::path, require => [ Puppet_agent_upgrade_error['puppet_agent_upgrade_failure.log'], diff --git a/spec/classes/puppet_agent_windows_install_spec.rb b/spec/classes/puppet_agent_windows_install_spec.rb index 2fe4e4177..4f9a976d6 100644 --- a/spec/classes/puppet_agent_windows_install_spec.rb +++ b/spec/classes/puppet_agent_windows_install_spec.rb @@ -73,6 +73,17 @@ end end + context 'package_version =>' do + describe '5.6.7' do + let(:params) { global_params.merge( + {:package_version => '5.6.7'}) + } + it { + is_expected.to contain_exec('install_puppet.ps1').with_unless(/\-Command {\$CurrentVersion = \[string\]\(facter.bat \-p aio_agent_version\);/) + is_expected.to contain_exec('install_puppet.ps1').with_unless(/\-Command.*if \(\$CurrentVersion \-eq '5\.6\.7'\) { +exit 0; *} *exit 1; }\.Invoke\(\)/) + } + end + end context 'install_options =>' do describe 'OPTION1=value1 OPTION2=value2' do let(:params) { global_params.merge(