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(