Skip to content

Commit

Permalink
Add support for Windows Server 2016 and 2019 Core editions (#255)
Browse files Browse the repository at this point in the history
* 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 2474c4c.

* maintain some backward compatability for Windows versions pre-PowerShell5

* Add Server 2016 and Server 2019 to list of supported Operating Systems
  • Loading branch information
njhowell authored May 26, 2020
1 parent 21737e7 commit 67cc128
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
14 changes: 13 additions & 1 deletion manifests/install/windows.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
4 changes: 3 additions & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@
"operatingsystem": "windows",
"operatingsystemrelease": [
"2012",
"2012 R2"
"2012 R2",
"2016",
"2019"
]
},
{
Expand Down

0 comments on commit 67cc128

Please sign in to comment.