-
Notifications
You must be signed in to change notification settings - Fork 259
[windows] fixes + blacklist #578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
a07720f
1b2cd02
93e1e7e
e1cb79a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,21 +17,31 @@ | |
| ) inherits datadog_agent::params { | ||
|
|
||
| $msi_full_path = "${msi_location}/datadog-agent-6-${agent_version}.amd64.msi" | ||
| $msi_source = "${baseurl}ddagent-cli-${agent_version}.msi" | ||
|
|
||
| if $ensure == 'present' { | ||
| if ($agent_version in ['6.14.0', '6.14.1']) { | ||
| fail("The specified agent version has been blacklisted, please specify a version other than 6.14.0 or 6.14.1") | ||
| } | ||
|
|
||
| file { 'installer': | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The previous behavior was to only download the MSI if it wasn't already installed. Now we are downloading it regardless. Any reason to prefer this?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe I missed something with my testing, but it didn't seem to download regardless. Once the file is in the temp directory I don't think the download was reattempted (ie. this resource doesn't behave like the chef counterpart that always pulls). That said, we can go back to the original code. I made this change because I wanted to use the The one thing that sucks, and I might change in a separate PR, is the fact we keep multiple files lying around, using up more and more disk space in temp over time. It might make sense to make
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't always download, but clearing the temp directory will trigger a download that is not needed if the package is already installed.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tentative fix, yet to be tested: #582 |
||
| path => $msi_full_path, | ||
| source => "${msi_source}", | ||
| provider => 'windows', | ||
| } | ||
|
|
||
| exec { 'downloadmsi': # Using exec instead of file so we can specify an onlyif condition | ||
| command => "Invoke-WebRequest ${baseurl} -outfile ${msi_full_path}", | ||
| onlyif => "if ((Get-Package \"${datadog_agent::params::package_name}\") -or (test-path ${msi_full_path})) { exit 1 }", | ||
| provider => powershell, | ||
| exec { 'validate': | ||
| command => "\$blacklist = '928b00d2f952219732cda9ae0515351b15f9b9c1ea1d546738f9dc0fda70c336','78b2bb2b231bcc185eb73dd367bfb6cb8a5d45ba93a46a7890fd607dc9188194';\$fileStream = [system.io.file]::openread('${msi_full_path}'); \$hasher = [System.Security.Cryptography.HashAlgorithm]::create('sha256'); \$hash = \$hasher.ComputeHash(\$fileStream); \$fileStream.close(); \$fileStream.dispose();\$hexhash = [system.bitconverter]::tostring(\$hash).ToLower().replace('-','');if (\$hexhash -match \$blacklist) { Exit 1 }", | ||
| provider => 'powershell', | ||
| logoutput => 'on_failure', | ||
|
truthbk marked this conversation as resolved.
|
||
| notify => Package[$datadog_agent::params::package_name] | ||
| } | ||
|
|
||
| package { $datadog_agent::params::package_name: | ||
| ensure => installed, | ||
| provider => 'windows', | ||
| source => $msi_full_path, | ||
| install_options => ['/quiet', {'APIKEY' => $api_key, 'HOSTNAME' => $hostname, 'TAGS' => $tags}] | ||
| install_options => ['/norestart', {'APIKEY' => $api_key, 'HOSTNAME' => $hostname, 'TAGS' => $tags}] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👌 |
||
| } | ||
|
|
||
| service { $service_name: | ||
|
|
@@ -40,11 +50,16 @@ | |
| require => Package[$datadog_agent::params::package_name] | ||
| } | ||
| } else { | ||
| exec { 'datadog_6_14_fix': | ||
| command => "((New-Object System.Net.WebClient).DownloadFile('https://s3.amazonaws.com/ddagent-windows-stable/scripts/fix_6_14.ps1', \$env:temp + '\\fix_6_14.ps1')); &\$env:temp\\fix_6_14.ps1", | ||
| provider => 'powershell', | ||
| } | ||
|
|
||
| package { $datadog_agent::params::package_name: | ||
| ensure => absent, | ||
| provider => 'windows', | ||
| uninstall_options => ['/quiet'] | ||
| uninstall_options => ['/quiet'], | ||
| subscribe => Exec['datadog_6_14_fix'], | ||
| } | ||
|
|
||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌