Skip to content

Commit

Permalink
Notify services on system probe file updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mx-psi committed Nov 17, 2022
1 parent 91724a9 commit 660a313
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
2 changes: 2 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
$container_collect_all = false
$sysprobe_service_name = 'datadog-agent-sysprobe'
$securityagent_service_name = 'datadog-agent-security'
$win_npm_service_name = 'ddnpm'
$module_metadata = load_module_metadata($module_name)

case $::operatingsystem {
Expand Down Expand Up @@ -64,6 +65,7 @@
$permissions_file = '0664' # otherwise puppet itself won't be able to access the file. Reported
$permissions_protected_file = '0660' # as bug in: https://tickets.puppetlabs.com/browse/PA-2877
$agent_binary = 'C:/Program Files/Datadog/Datadog Agent/embedded/agent.exe'
$sysprobe_service_name = 'datadog-system-probe'
}
default: { fail("Class[datadog_agent]: Unsupported operatingsystem: ${::operatingsystem}") }
}
Expand Down
11 changes: 9 additions & 2 deletions manifests/system_probe.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# This class contains the Datadog agent system probe (NPM) configuration.
# On Windows, install the NPM driver by setting 'windows_npm_install'
# to 'true on the datadog_agent class.
# to 'true on both the datadog_agent class and the system_probe class.
#

class datadog_agent::system_probe(
Expand All @@ -14,6 +14,7 @@
Optional[Hash] $runtime_security_config = undef,

Boolean $service_enable = true,
Boolean $windows_npm_install = false,
String $service_ensure = 'running',
Optional[String] $service_provider = undef,
) inherits datadog_agent::params {
Expand All @@ -33,15 +34,21 @@
}

if $::operatingsystem == 'Windows' {
service { $datadog_agent::params::sysprobe_service_name:
ensure => $service_ensure,
enable => $service_enable,
hasstatus => false,
require => Package[$datadog_agent::params::package_name],
}

file { 'C:/ProgramData/Datadog/system-probe.yaml':
owner => $datadog_agent::params::dd_user,
group => $datadog_agent::params::dd_group,
mode => '0640',
content => template('datadog_agent/system_probe.yaml.erb'),
require => File['C:/ProgramData/Datadog'],
notify => Service[$datadog_agent::params::sysprobe_service_name],
}

} else {

if $service_provider {
Expand Down
10 changes: 10 additions & 0 deletions manifests/windows.pp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@
install_options => ['/norestart', {'APIKEY' => $api_key, 'TAGS' => $tags_quote_wrap} + $npm_install_option + $hostname_option]
}

if $npm_install {
service { $datadog_agent::params::win_npm_service_name:
ensure => $service_ensure,
enable => $service_enable,
hasstatus => false,
require => Package[$datadog_agent::params::package_name],
subscribe => File['C:/ProgramData/Datadog/system-probe.yaml'],
}
}

} 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",
Expand Down

0 comments on commit 660a313

Please sign in to comment.