Puppet Class: datadog_agent::windows
- Inherits:
- datadog_agent::params
- Defined in:
- manifests/windows.pp
Overview
Class: datadog_agent::windows
This class contains the DataDog agent installation mechanism for Windows
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'manifests/windows.pp', line 5
class datadog_agent::windows (
Integer $agent_major_version = $datadog_agent::params::default_agent_major_version,
String $agent_version = $datadog_agent::params::agent_version,
Optional[String] $agent_repo_uri = undef,
String $msi_location = 'C:/Windows/temp',
String $api_key = $datadog_agent::api_key,
String $hostname = $datadog_agent::host,
Array $tags = $datadog_agent::tags,
String $tags_join = join($tags,','),
String $tags_quote_wrap = "\"${tags_join}\"",
Enum['present', 'absent'] $ensure = 'present',
Boolean $npm_install = false,
Optional[String] $ddagentuser_name = undef,
Optional[String] $ddagentuser_password = undef,
) inherits datadog_agent::params {
$msi_full_path = "${msi_location}/datadog-agent-${agent_major_version}-${agent_version}.amd64.msi"
if ($agent_repo_uri != undef) {
$baseurl = $agent_repo_uri
} else {
$baseurl = 'https://s3.amazonaws.com/ddagent-windows-stable/'
}
if $agent_version == 'latest' {
$msi_source = "${baseurl}datadog-agent-${agent_major_version}-latest.amd64.msi"
} else {
$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 deemed unacceptable for installation, please specify a version other than 6.14.0 or 6.14.1')
}
file { 'installer':
path => $msi_full_path,
source => $msi_source,
provider => 'windows',
}
$unless_cmd = @("ACCEPTABLE"/$L)
\$denylist = '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 (\$denylist.Contains(\$hexhash)) { Exit 1 } else { Exit 0 }
| ACCEPTABLE
exec { 'assert-acceptable-msi':,
command => 'Exit 1',
unless => $unless_cmd,
provider => 'powershell',
logoutput => 'on_failure',
require => File['installer'],
notify => Package[$datadog_agent::params::package_name],
}
if $agent_version == 'latest' {
$ensure_version = 'installed'
} else {
# While artifacts contain X.Y.Z in their name, their installed Windows versions are actually X.Y.Z.1
$ensure_version = "${agent_version}.1"
}
$hostname_option = $hostname ? { '' => {}, default => { 'HOSTNAME' => $hostname } }
$npm_install_option = $npm_install ? { false => {}, true => { 'ADDLOCAL' => 'MainApplication,NPM' } }
$ddagentuser_name_option = $ddagentuser_name ? { undef => {}, default => { 'DDAGENTUSER_NAME' => $ddagentuser_name } }
$ddagentuser_password_option = ($ddagentuser_name != undef and $ddagentuser_password != undef) ? { true => { 'DDAGENTUSER_PASSWORD' => $ddagentuser_password }, false => {} }
package { $datadog_agent::params::package_name:
ensure => $ensure_version,
provider => 'windows',
source => $msi_full_path,
install_options => ['/norestart', { 'APIKEY' => $api_key, 'TAGS' => $tags_quote_wrap } + $npm_install_option + $hostname_option + $ddagentuser_name_option + $ddagentuser_password_option],
}
} 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'],
subscribe => Exec['datadog_6_14_fix'],
}
}
}
|