|
17 | 17 | ) inherits datadog_agent::params { |
18 | 18 |
|
19 | 19 | $msi_full_path = "${msi_location}/datadog-agent-6-${agent_version}.amd64.msi" |
| 20 | + $msi_source = "${baseurl}ddagent-cli-${agent_version}.msi" |
20 | 21 |
|
21 | 22 | if $ensure == 'present' { |
| 23 | + if ($agent_version in ['6.14.0', '6.14.1']) { |
| 24 | + fail('The specified agent version has been blacklisted, please specify a version other than 6.14.0 or 6.14.1') |
| 25 | + } |
| 26 | + |
| 27 | + file { 'installer': |
| 28 | + path => $msi_full_path, |
| 29 | + source => $msi_source, |
| 30 | + provider => 'windows', |
| 31 | + } |
22 | 32 |
|
23 | | - exec { 'downloadmsi': # Using exec instead of file so we can specify an onlyif condition |
24 | | - command => "Invoke-WebRequest ${baseurl} -outfile ${msi_full_path}", |
25 | | - onlyif => "if ((Get-Package \"${datadog_agent::params::package_name}\") -or (test-path ${msi_full_path})) { exit 1 }", |
26 | | - provider => powershell, |
27 | | - notify => Package[$datadog_agent::params::package_name] |
| 33 | + exec { 'validate': |
| 34 | + 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 }", |
| 35 | + provider => 'powershell', |
| 36 | + logoutput => 'on_failure', |
| 37 | + require => File['installer'], |
| 38 | + notify => Package[$datadog_agent::params::package_name] |
28 | 39 | } |
29 | 40 |
|
30 | 41 | package { $datadog_agent::params::package_name: |
31 | 42 | ensure => installed, |
32 | 43 | provider => 'windows', |
33 | 44 | source => $msi_full_path, |
34 | | - install_options => ['/quiet', {'APIKEY' => $api_key, 'HOSTNAME' => $hostname, 'TAGS' => $tags}] |
| 45 | + install_options => ['/norestart', {'APIKEY' => $api_key, 'HOSTNAME' => $hostname, 'TAGS' => $tags}] |
35 | 46 | } |
36 | 47 |
|
37 | 48 | service { $service_name: |
|
40 | 51 | require => Package[$datadog_agent::params::package_name] |
41 | 52 | } |
42 | 53 | } else { |
| 54 | + exec { 'datadog_6_14_fix': |
| 55 | + 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", |
| 56 | + provider => 'powershell', |
| 57 | + } |
43 | 58 |
|
44 | 59 | package { $datadog_agent::params::package_name: |
45 | 60 | ensure => absent, |
46 | 61 | provider => 'windows', |
47 | | - uninstall_options => ['/quiet'] |
| 62 | + uninstall_options => ['/quiet'], |
| 63 | + subscribe => Exec['datadog_6_14_fix'], |
48 | 64 | } |
49 | 65 |
|
50 | 66 | } |
|
0 commit comments