windows staging module - don't download installer if not needed

asked 2016-02-18 12:25:40 -0600

Below is a class to install an app on a Windows server. The staging module downloads the installer whether the package is already installed on the server or not. How can I make it so that it only downloads it if the package does not exist?

Thanks, David

class snare::windows { notify { 'Snare module run': } $logtarget = hiera('logtarget') $buildserver = hiera('buildserver')

include staging staging::file { 'SnareForWindows-MultiArch.exe': source => "http://${build_server}/software/snare/SnareForWindows-4.0.1.2-MultiArch.exe", target => 'c:/windows/temp/SnareForWindows-MultiArch.exe', } Exec <| title == 'c:/windows/temp/SnareForWindows-MultiArch.exe' |> { cwd => undef, }

$snaredesiredversion = '4.0.1.2' $snarepackagename = "Snare version ${snaredesiredversion}" if $::snareversion and $snaredesiredversion != $::snareversion { exec{ '"C:\Program Files\Snare\unins000.exe" /SILENT': before => Package[$snarepackagename], } }

package { $snarepackagename: ensure => present, source => 'c:/windows/temp/SnareForWindows-MultiArch.exe', install_options => ['/VERYSILENT'], require => Staging::File['SnareForWindows-MultiArch.exe'], }

}

edit retag flag offensive close merge delete