From 67cc128b48c394b5de0ecd2644a1f30e87a5b21f Mon Sep 17 00:00:00 2001 From: Nick Howell Date: Tue, 26 May 2020 15:45:54 +0100 Subject: [PATCH] Add support for Windows Server 2016 and 2019 Core editions (#255) * use native expand-archive in Powershell 5 * correct version_file directory I think this should be `$filebeat::install_dir` not `$install_folder` since (from context) it refers to the directory created by extracting the archive * put literal quotes around the path because it has spaces in it * Revert "correct version_file directory" This reverts commit 2474c4cd2f4d76f44e4a3a2707d7734d680ae177. * maintain some backward compatability for Windows versions pre-PowerShell5 * Add Server 2016 and Server 2019 to list of supported Operating Systems --- manifests/install/windows.pp | 14 +++++++++++++- metadata.json | 4 +++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/manifests/install/windows.pp b/manifests/install/windows.pp index 7b83145..0740309 100644 --- a/manifests/install/windows.pp +++ b/manifests/install/windows.pp @@ -37,8 +37,20 @@ proxy_server => $filebeat::proxy_address, } + # Core editions of Windows Server do not have a shell as such, so use the Shell.Application COM object doesn't work. + # Expand-Archive is a native powershell cmdlet which ships with Powershell 5, which in turn ships with Windows 10 and + # Windows Server 2016 and newer. + if ((versioncmp($::operatingsystemrelease, '2016') > 0) or (versioncmp($::operatingsystemrelease, '10') == 0)) + { + $unzip_command = "Expand-Archive ${zip_file} \"${filebeat::install_dir}\"" + } + else + { + $unzip_command = "\$sh=New-Object -COM Shell.Application;\$sh.namespace((Convert-Path '${filebeat::install_dir}')).Copyhere(\$sh.namespace((Convert-Path '${zip_file}')).items(), 16)" # lint:ignore:140chars + } + exec { "unzip ${filename}": - command => "\$sh=New-Object -COM Shell.Application;\$sh.namespace((Convert-Path '${filebeat::install_dir}')).Copyhere(\$sh.namespace((Convert-Path '${zip_file}')).items(), 16)", # lint:ignore:140chars + command => $unzip_command, creates => $version_file, require => [ File[$filebeat::install_dir], diff --git a/metadata.json b/metadata.json index 5343152..7b28567 100644 --- a/metadata.json +++ b/metadata.json @@ -87,7 +87,9 @@ "operatingsystem": "windows", "operatingsystemrelease": [ "2012", - "2012 R2" + "2012 R2", + "2016", + "2019" ] }, {