File tree Expand file tree Collapse file tree 5 files changed +59
-4
lines changed Expand file tree Collapse file tree 5 files changed +59
-4
lines changed Original file line number Diff line number Diff line change @@ -349,11 +349,11 @@ Default value: `undef`
349349
350350##### <a name =" -puppet_agent--version_file_path " ></a >` version_file_path `
351351
352- Data type: ` String `
352+ Data type: ` Stdlib::Absolutepath `
353353
354354The default install path for the VERSION file
355355
356- Default value: ` $facts['os']['family'] ? { 'windows' => "${facts['env_windows_installdir']}\\VERSION", default => '/opt/puppetlabs/puppet/VERSION'`
356+ Default value: ` '/opt/puppetlabs/puppet/VERSION' `
357357
358358##### <a name =" -puppet_agent--skip_if_unavailable " ></a >` skip_if_unavailable `
359359
Original file line number Diff line number Diff line change 1+ Facter . add ( :puppet_runmode ) do
2+ setcode { Puppet . run_mode . name . to_s }
3+ end
Original file line number Diff line number Diff line change 131131 Optional $wait_for_pxp_agent_exit = undef ,
132132 Optional $wait_for_puppet_run = undef ,
133133 Array[Puppet_agent::Config] $config = [],
134- String $version_file_path = $facts[ ' os ' ][ ' family ' ] ? { ' windows ' => " ${facts['env_windows_installdir']} \\ VERSION " , default => ' /opt/puppetlabs/puppet/VERSION' }
134+ Stdlib::Absolutepath $version_file_path = ' /opt/puppetlabs/puppet/VERSION'
135135) inherits puppet_agent::params {
136136 # The configure class uses $puppet_agent::config to manage settings in
137137 # puppet.conf, and will always be present. It does not require management of
167167 # The AIO package version and Puppet version can, on rare occasion, diverge.
168168 # This logic checks for the AIO version of the server, since that's what the package manager cares about.
169169 if $package_version == ' auto' {
170- $master_or_package_version = chomp(file ($version_file_path ))
170+ if $facts [' os' ][' family' ] == ' windows' and $facts [' puppet_runmode' ] == ' user' {
171+ $master_or_package_version = chomp(file (" ${facts['env_windows_installdir']}\\ VERSION" ))
172+ } else {
173+ $master_or_package_version = chomp(file ($version_file_path ))
174+ }
171175 } else {
172176 $master_or_package_version = $package_version
173177 }
Original file line number Diff line number Diff line change 274274 it { is_expected . to contain_package ( 'puppet-agent' ) . with_ensure ( params [ :package_version ] . to_s ) }
275275 end
276276
277+ context 'with auto package version' do
278+ let ( :params ) do
279+ {
280+ manage_repo : false ,
281+ package_version : 'auto'
282+ }
283+ end
284+
285+ context 'with Windows agent' do
286+ let ( :facts ) do
287+ override_facts (
288+ super ( ) ,
289+ os : { family : 'windows' , 'windows' => { 'system32' => 'C:\Windows\System32' } } ,
290+ 'env_windows_installdir' => 'C:\Program Files\Puppet Labs\Puppet' ,
291+ 'puppet_agent_appdata' => 'C:\ProgramData' ,
292+ 'puppet_confdir' => 'C:\ProgramData\PuppetLabs\puppet' ,
293+ 'puppet_runmode' => 'agent' ,
294+ )
295+ end
296+
297+ before :each do
298+ allow ( Puppet ::FileSystem ) . to receive ( :exist? ) . and_call_original
299+ allow ( Puppet ::FileSystem ) . to receive ( :read_preserve_line_endings ) . and_call_original
300+ allow ( Puppet ::FileSystem ) . to receive ( :exist? ) . with ( '/opt/puppetlabs/puppet/VERSION' ) . and_return true
301+ allow ( Puppet ::FileSystem ) . to receive ( :read_preserve_line_endings ) . with ( '/opt/puppetlabs/puppet/VERSION' ) . and_return "7.6.5\n "
302+ end
303+
304+ it { is_expected . to contain_class ( 'puppet_agent::install::windows' ) }
305+ end
306+ end
307+
277308 it { is_expected . to contain_class ( 'puppet_agent::osfamily::redhat' ) }
278309 end
279310
Original file line number Diff line number Diff line change 9494 'source' => "puppet:///pe_packages/#{ pe_version } /windows-#{ tag } /puppet-agent-#{ arch } .msi" ,
9595 )
9696 }
97+
98+ describe 'when applying' do
99+ let ( :facts ) do
100+ override_facts (
101+ super ( ) ,
102+ puppet_runmode : 'user' ,
103+ )
104+ end
105+
106+ it { is_expected . to contain_file ( "#{ appdata } \\ Puppetlabs" ) }
107+ it { is_expected . to contain_file ( "#{ appdata } \\ Puppetlabs\\ packages" ) }
108+ it {
109+ is_expected . to contain_file ( "#{ appdata } \\ Puppetlabs\\ packages\\ puppet-agent-#{ arch } .msi" ) . with (
110+ 'source' => "puppet:///pe_packages/#{ pe_version } /windows-#{ tag } /puppet-agent-#{ arch } .msi" ,
111+ )
112+ }
113+ end
97114 end
98115 end
99116
You can’t perform that action at this time.
0 commit comments