From 4ca062b1ff38b72ceb95d1cd390e6ff08b0b9607 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Bavelier?= <97530782+tbavelier@users.noreply.github.com> Date: Fri, 5 Sep 2025 16:16:13 +0200 Subject: [PATCH 1/4] Use Agent 7.64.3 fixed version and explicitly cast to Integer to avoid eval error (#865) --- environments/etc/manifests/site.pp | 2 ++ manifests/redhat.pp | 2 +- manifests/suse.pp | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/environments/etc/manifests/site.pp b/environments/etc/manifests/site.pp index dc594938..f2efa320 100644 --- a/environments/etc/manifests/site.pp +++ b/environments/etc/manifests/site.pp @@ -1,6 +1,8 @@ node default { class { 'datadog_agent': api_key => 'somenonnullapikeythats32charlong', + # Pin the Agent version to 7.64.3 to avoid breaking changes in postint for kitchen tests + agent_version => '7.64.3', agent_extra_options => { use_http => true, }, diff --git a/manifests/redhat.pp b/manifests/redhat.pp index 6bab9e16..b806bb5b 100644 --- a/manifests/redhat.pp +++ b/manifests/redhat.pp @@ -19,7 +19,7 @@ ] #In this regex, version '1:6.15.0~rc.1-1' would match as $1='1:', $2='6', $3='15', $4='0', $5='~rc.1', $6='1' if $agent_version =~ /([0-9]+:)?([0-9]+)\.([0-9]+)\.([0-9]+)((?:~|-)[^0-9\s-]+[^-\s]*)?(?:-([0-9]+))?/ or $agent_version == 'latest' { - if $agent_major_version >= 6 and ($agent_version == 'latest' or 0 + $3 > 35) { + if $agent_major_version >= 6 and ($agent_version == 'latest' or Integer($3, 10) > 35) { $keys = $all_keys[0,3] } else { $keys = $all_keys diff --git a/manifests/suse.pp b/manifests/suse.pp index 90d78f46..57a3b9f2 100644 --- a/manifests/suse.pp +++ b/manifests/suse.pp @@ -19,7 +19,7 @@ ] #In this regex, version '1:6.15.0~rc.1-1' would match as $1='1:', $2='6', $3='15', $4='0', $5='~rc.1', $6='1' if $agent_version =~ /([0-9]+:)?([0-9]+)\.([0-9]+)\.([0-9]+)((?:~|-)[^0-9\s-]+[^-\s]*)?(?:-([0-9]+))?/ or $agent_version == 'latest' { - if $agent_major_version >= 6 and ($agent_version == 'latest' or 0 + $3 > 35) { + if $agent_major_version >= 6 and ($agent_version == 'latest' or Integer($3, 10) > 35) { $keys_to_use = $all_keys[0,3] } else { $keys_to_use = $all_keys From 37e5a88913967896a7d2cf59b3cb7709cc36d750 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Bavelier?= <97530782+tbavelier@users.noreply.github.com> Date: Mon, 8 Sep 2025 10:36:18 +0200 Subject: [PATCH 2/4] [AGENTONB-2490] Support `remote_updates` through embedded installer (#866) * do not manage Agent with deprecated deb/rpm installer * Ensure Agent service is not running if experiment is running --- lib/facter/datadog_agent_exp_active.rb | 18 ++ manifests/init.pp | 299 +++++++++++-------------- manifests/redhat_installer.pp | 32 +-- manifests/suse_installer.pp | 32 +-- manifests/ubuntu_installer.pp | 36 +-- 5 files changed, 147 insertions(+), 270 deletions(-) create mode 100644 lib/facter/datadog_agent_exp_active.rb diff --git a/lib/facter/datadog_agent_exp_active.rb b/lib/facter/datadog_agent_exp_active.rb new file mode 100644 index 00000000..99699fd7 --- /dev/null +++ b/lib/facter/datadog_agent_exp_active.rb @@ -0,0 +1,18 @@ +Facter.add(:datadog_agent_exp_active) do + confine kernel: 'Linux' + setcode do + active = false + + # Determine via service manager when available + if Facter::Util::Resolution.which('systemctl') + active = system('systemctl is-active --quiet datadog-agent-exp') + elsif Facter::Util::Resolution.which('service') + active = system('service datadog-agent-exp status >/dev/null 2>&1') + elsif Facter::Util::Resolution.which('pgrep') + # Fallback: look for the experiment agent binary as the running command (exact path prefix) + active = system('pgrep -f "^/opt/datadog-packages/datadog-agent/experiment/bin/agent/agent( |$)" >/dev/null 2>&1') + end + + active + end +end diff --git a/manifests/init.pp b/manifests/init.pp index b402b30b..27d7364f 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -439,194 +439,101 @@ default: { $_loglevel = 'INFO' } } - if $datadog_installer_enabled { - # If instrumentation is enabled and the libraries are not set, default to pinned latest versions - # Else, if user wants to install libraries without enabling instrumentation, use the provided libraries - if $apm_instrumentation_enabled and ! $apm_instrumentation_libraries { - $apm_instrumentation_libraries_str = join(['java:1', 'python:2', 'js:5', 'dotnet:3', 'ruby:2'], ',') - } elsif $apm_instrumentation_libraries { - $apm_instrumentation_libraries_str = join($apm_instrumentation_libraries, ',') - } else { - $apm_instrumentation_libraries_str = '' - } - # Agent version handling: the installer expects DD_AGENT_MINOR_VERSION to include the patch version. - # $_agent_minor_version is the minor version without the patch version. - # We need to add the patch version to the minor version to get the full version. - # If minor and patch version were not extracted (e.g. user is simply providing agent_major_version), we use an empty string for the minor version. - if $_agent_minor_version != undef and $_agent_patch_version != undef { - $_agent_minor_version_full = "${_agent_minor_version}.${_agent_patch_version}" - } else { - $_agent_minor_version_full = '' - } + # Install agent + if $manage_install { case $facts['os']['name'] { - 'Ubuntu','Debian','Raspbian': { - class { 'datadog_agent::ubuntu_installer': - api_key => $api_key, - datadog_site => $datadog_site, - agent_major_version => $_agent_major_version, - agent_minor_version => $_agent_minor_version_full, - manage_agent_install => $manage_install, - installer_repo_uri => $agent_repo_uri, - release => $apt_release, - skip_apt_key_trusting => $skip_apt_key_trusting, - apm_instrumentation_enabled => $apm_instrumentation_enabled, - apm_instrumentation_libraries_str => $apm_instrumentation_libraries_str, - remote_updates => $remote_updates, - remote_policies => $remote_policies, + 'Ubuntu','Debian','Raspbian' : { + if $use_apt_backup_keyserver != undef or $apt_backup_keyserver != undef or $apt_keyserver != undef { + notify { 'apt keyserver arguments deprecation': + message => '$use_apt_backup_keyserver, $apt_backup_keyserver and $apt_keyserver are deprecated since version 3.13.0', + loglevel => 'warning', + } } - } - 'RedHat','CentOS','Fedora','Amazon','Scientific','OracleLinux','AlmaLinux','Rocky' : { - class { 'datadog_agent::redhat_installer': - api_key => $api_key, - datadog_site => $datadog_site, - agent_major_version => $_agent_major_version, - agent_minor_version => $_agent_minor_version_full, - installer_repo_uri => $agent_repo_uri, - rpm_repo_gpgcheck => $rpm_repo_gpgcheck, - apm_instrumentation_enabled => $apm_instrumentation_enabled, - apm_instrumentation_libraries_str => $apm_instrumentation_libraries_str, - remote_updates => $remote_updates, - remote_policies => $remote_policies, + class { 'datadog_agent::ubuntu': + agent_major_version => $_agent_major_version, + agent_version => $agent_full_version, + agent_flavor => $agent_flavor, + agent_repo_uri => $agent_repo_uri, + release => $apt_release, + skip_apt_key_trusting => $skip_apt_key_trusting, } } - 'OpenSuSE', 'SLES' : { - class { 'datadog_agent::suse_installer': - api_key => $api_key, - datadog_site => $datadog_site, - agent_major_version => $_agent_major_version, - agent_minor_version => $_agent_minor_version_full, - installer_repo_uri => $agent_repo_uri, - rpm_repo_gpgcheck => $rpm_repo_gpgcheck, - apm_instrumentation_enabled => $apm_instrumentation_enabled, - apm_instrumentation_libraries_str => $apm_instrumentation_libraries_str, - remote_updates => $remote_updates, - remote_policies => $remote_policies, + 'RedHat','CentOS','Fedora','Amazon','Scientific','OracleLinux','AlmaLinux','Rocky' : { + class { 'datadog_agent::redhat': + agent_major_version => $_agent_major_version, + agent_flavor => $agent_flavor, + agent_repo_uri => $agent_repo_uri, + manage_repo => $manage_repo, + agent_version => $agent_full_version, + rpm_repo_gpgcheck => $rpm_repo_gpgcheck, } } - default: { fail("Class[datadog_agent::installer]: Unsupported operatingsystem: ${facts['os']['name']}") } - } - } - - # If the agent is managed by the installer, we don't need to manage the agent installation - $_agent_managed_by_installer = ($datadog_installer_enabled and $remote_updates) - - # Install agent - if ! $_agent_managed_by_installer { - if $manage_install { - case $facts['os']['name'] { - 'Ubuntu','Debian','Raspbian' : { - if $use_apt_backup_keyserver != undef or $apt_backup_keyserver != undef or $apt_keyserver != undef { - notify { 'apt keyserver arguments deprecation': - message => '$use_apt_backup_keyserver, $apt_backup_keyserver and $apt_keyserver are deprecated since version 3.13.0', - loglevel => 'warning', - } - } - class { 'datadog_agent::ubuntu': - agent_major_version => $_agent_major_version, - agent_version => $agent_full_version, - agent_flavor => $agent_flavor, - agent_repo_uri => $agent_repo_uri, - release => $apt_release, - skip_apt_key_trusting => $skip_apt_key_trusting, - } - } - 'RedHat','CentOS','Fedora','Amazon','Scientific','OracleLinux','AlmaLinux','Rocky' : { - class { 'datadog_agent::redhat': - agent_major_version => $_agent_major_version, - agent_flavor => $agent_flavor, - agent_repo_uri => $agent_repo_uri, - manage_repo => $manage_repo, - agent_version => $agent_full_version, - rpm_repo_gpgcheck => $rpm_repo_gpgcheck, - } + 'Windows' : { + class { 'datadog_agent::windows' : + agent_major_version => $_agent_major_version, + agent_repo_uri => $agent_repo_uri, + agent_version => $agent_full_version, + msi_location => $win_msi_location, + api_key => $api_key, + hostname => $host, + tags => $local_tags, + ensure => $win_ensure, + npm_install => $windows_npm_install, + ddagentuser_name => $windows_ddagentuser_name, + ddagentuser_password => $windows_ddagentuser_password, } - 'Windows' : { - class { 'datadog_agent::windows' : - agent_major_version => $_agent_major_version, - agent_repo_uri => $agent_repo_uri, - agent_version => $agent_full_version, - msi_location => $win_msi_location, - api_key => $api_key, - hostname => $host, - tags => $local_tags, - ensure => $win_ensure, - npm_install => $windows_npm_install, - ddagentuser_name => $windows_ddagentuser_name, - ddagentuser_password => $windows_ddagentuser_password, - } - if ($win_ensure == absent) { - return() #Config files will remain unchanged on uninstall - } + if ($win_ensure == absent) { + return() #Config files will remain unchanged on uninstall } - 'OpenSuSE', 'SLES' : { - class { 'datadog_agent::suse' : - agent_major_version => $_agent_major_version, - agent_flavor => $agent_flavor, - agent_repo_uri => $agent_repo_uri, - agent_version => $agent_full_version, - rpm_repo_gpgcheck => $rpm_repo_gpgcheck, - } - } - default: { fail("Class[datadog_agent]: Unsupported operatingsystem: ${facts['os']['name']}") } } - } else { - if ! defined(Package[$agent_flavor]) { - package { $agent_flavor: - ensure => present, - source => 'Agent installation not managed by Puppet, make sure the Agent is installed beforehand.', + 'OpenSuSE', 'SLES' : { + class { 'datadog_agent::suse' : + agent_major_version => $_agent_major_version, + agent_flavor => $agent_flavor, + agent_repo_uri => $agent_repo_uri, + agent_version => $agent_full_version, + rpm_repo_gpgcheck => $rpm_repo_gpgcheck, } } + default: { fail("Class[datadog_agent]: Unsupported operatingsystem: ${facts['os']['name']}") } + } + } else { + if ! defined(Package[$agent_flavor]) { + package { $agent_flavor: + ensure => present, + source => 'Agent installation not managed by Puppet, make sure the Agent is installed beforehand.', + } } } # Declare service - if ! $_agent_managed_by_installer { - class { 'datadog_agent::service' : - agent_flavor => $agent_flavor, - service_ensure => $service_ensure, - service_enable => $service_enable, - service_provider => $service_provider, - } - if ($facts['os']['name'] != 'Windows') { - if ($dd_groups) { - user { $dd_user: - groups => $dd_groups, - notify => Service[$datadog_agent::params::service_name], - } - } + if ($facts['os']['name'] != 'Windows' and $facts['datadog_agent_exp_active'] == true) { + $_service_ensure = 'stopped' + } else { + $_service_ensure = $service_ensure + } - # required by reports even in agent5 scenario - file { '/etc/datadog-agent': - ensure => directory, - owner => $dd_user, - group => $dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$agent_flavor], + class { 'datadog_agent::service' : + agent_flavor => $agent_flavor, + service_ensure => $_service_ensure, + service_enable => $service_enable, + service_provider => $service_provider, + } + if ($facts['os']['name'] != 'Windows') { + if ($dd_groups) { + user { $dd_user: + groups => $dd_groups, + notify => Service[$datadog_agent::params::service_name], } } - } else { - class { 'datadog_agent::service' : - # Declare service for agent managed by installer with installer flavor - agent_flavor => 'datadog-installer', - service_ensure => $service_ensure, - service_enable => $service_enable, - service_provider => $service_provider, - } - if ($facts['os']['name'] != 'Windows') { - if ($dd_groups) { - user { $dd_user: - groups => $dd_groups, - notify => Service[$datadog_agent::params::service_name], - } - } - # required to manage config and install info files even with installer - file { '/etc/datadog-agent': - ensure => directory, - owner => $dd_user, - group => $dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package['datadog-installer'], - } + + # required by reports even in agent5 scenario + file { '/etc/datadog-agent': + ensure => directory, + owner => $dd_user, + group => $dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$agent_flavor], } } @@ -751,10 +658,7 @@ force => $conf_dir_purge, owner => $dd_user, group => $dd_group, - } - - if ! $_agent_managed_by_installer { - File[$_conf_dir] ~> Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $_local_tags = datadog_agent::tag6($local_tags, false, undef) @@ -851,4 +755,51 @@ } create_resources('datadog_agent::integration', $local_integrations) + + # Install the deprecated RPM/DEB installer if APM instrumentation is enabled + if $datadog_installer_enabled { + # If instrumentation is enabled and the libraries are not set, default to pinned latest versions + # Else, if user wants to install libraries without enabling instrumentation, use the provided libraries + if $apm_instrumentation_enabled and ! $apm_instrumentation_libraries { + $apm_instrumentation_libraries_str = join(['java:1', 'python:2', 'js:5', 'dotnet:3', 'ruby:2'], ',') + } elsif $apm_instrumentation_libraries { + $apm_instrumentation_libraries_str = join($apm_instrumentation_libraries, ',') + } else { + $apm_instrumentation_libraries_str = '' + } + case $facts['os']['name'] { + 'Ubuntu','Debian','Raspbian': { + class { 'datadog_agent::ubuntu_installer': + api_key => $api_key, + datadog_site => $datadog_site, + installer_repo_uri => $agent_repo_uri, + release => $apt_release, + skip_apt_key_trusting => $skip_apt_key_trusting, + apm_instrumentation_enabled => $apm_instrumentation_enabled, + apm_instrumentation_libraries_str => $apm_instrumentation_libraries_str, + } + } + 'RedHat','CentOS','Fedora','Amazon','Scientific','OracleLinux','AlmaLinux','Rocky' : { + class { 'datadog_agent::redhat_installer': + api_key => $api_key, + datadog_site => $datadog_site, + installer_repo_uri => $agent_repo_uri, + rpm_repo_gpgcheck => $rpm_repo_gpgcheck, + apm_instrumentation_enabled => $apm_instrumentation_enabled, + apm_instrumentation_libraries_str => $apm_instrumentation_libraries_str, + } + } + 'OpenSuSE', 'SLES' : { + class { 'datadog_agent::suse_installer': + api_key => $api_key, + datadog_site => $datadog_site, + installer_repo_uri => $agent_repo_uri, + rpm_repo_gpgcheck => $rpm_repo_gpgcheck, + apm_instrumentation_enabled => $apm_instrumentation_enabled, + apm_instrumentation_libraries_str => $apm_instrumentation_libraries_str, + } + } + default: { fail("Class[datadog_agent::installer]: Unsupported operatingsystem: ${facts['os']['name']}") } + } + } } diff --git a/manifests/redhat_installer.pp b/manifests/redhat_installer.pp index bc8e6b99..1281d72a 100644 --- a/manifests/redhat_installer.pp +++ b/manifests/redhat_installer.pp @@ -3,26 +3,18 @@ # # @param api_key String:Your DataDog API Key. # @param datadog_site String: The site of the Datadog intake to send Agent data to. Defaults to 'datadoghq.com'. -# @param agent_major_version Integer: The major version of the Datadog agent to install. Defaults to 7. -# @param agent_minor_version Optional[String]: The minor version of the Datadog agent to install. # @param installer_repo_uri Optional[String]: The URI of the installer repository. # @param rpm_repo_gpgcheck Optional[Boolean]: Whether to check the GPG signature of the repository. # @param apm_instrumentation_enabled Optional[Enum['host', 'docker', 'all']]: Enable APM instrumentation for the specified environment (host, docker, or all). # @param apm_instrumentation_libraries_str Optional[String]: APM instrumentation libraries as a comma-separated string. -# @param remote_updates Boolean: Whether to enable Agent remote updates. Default: false. -# @param remote_policies Boolean: Whether to enable Agent remote policies. Default: false. # class datadog_agent::redhat_installer ( String $api_key = 'your_API_key', String $datadog_site = $datadog_agent::params::datadog_site, - Integer $agent_major_version = $datadog_agent::params::default_agent_major_version, - Optional[String] $agent_minor_version = undef, Optional[String] $installer_repo_uri = undef, Optional[Boolean] $rpm_repo_gpgcheck = undef, Optional[Enum['host', 'docker', 'all']] $apm_instrumentation_enabled = undef, Optional[String] $apm_instrumentation_libraries_str = undef, - Boolean $remote_updates = $datadog_agent::params::remote_updates, - Boolean $remote_policies = $datadog_agent::params::remote_policies, ) inherits datadog_agent::params { # Generate installer trace ID as a random 64-bit integer (Puppet does not support 128-bit integers) # Note: we cannot use fqdn_rand as the seed is dependent on the node, meaning the same trace ID would be generated on each run (for the same node) @@ -107,29 +99,12 @@ environment => [ "DD_SITE=${datadog_site}", "DD_API_KEY=${api_key}", - "DD_AGENT_MAJOR_VERSION=${agent_major_version}", - "DD_AGENT_MINOR_VERSION=${agent_minor_version}", - "DD_REMOTE_UPDATES=${remote_updates}", - "DD_REMOTE_POLICIES=${remote_policies}", "DD_APM_INSTRUMENTATION_ENABLED=${apm_instrumentation_enabled}", "DD_APM_INSTRUMENTATION_LIBRARIES=${apm_instrumentation_libraries_str}", ], require => Package['datadog-installer'], } - # Check if installer owns the Datadog Agent package - exec { - 'Check if installer owns the Datadog Agent package': - command => '/usr/bin/datadog-installer is-installed datadog-agent', - environment => [ - "DD_SITE=${datadog_site}", - "DD_API_KEY=${api_key}", - ], - # We allow 0, 10 (package not installed) - returns => [0, 10], - require => Exec['Bootstrap the installer'], - } - # Check if installer owns APM libraries if $apm_instrumentation_libraries_str != '' { $apm_instrumentation_libraries_str.split(',').each |$library| { @@ -153,15 +128,10 @@ require => Exec['Bootstrap the installer'], } - if $remote_updates { - $packages_to_install = "datadog-agent,${apm_instrumentation_libraries_str}" - } else { - $packages_to_install = $apm_instrumentation_libraries_str - } class { 'datadog_agent::installer_telemetry': api_key => $api_key, datadog_site => $datadog_site, - packages_to_install => $packages_to_install, + packages_to_install => $apm_instrumentation_libraries_str, require => Exec['End timer'], } } diff --git a/manifests/suse_installer.pp b/manifests/suse_installer.pp index 2773d8ed..9a5bd465 100644 --- a/manifests/suse_installer.pp +++ b/manifests/suse_installer.pp @@ -3,26 +3,18 @@ # # @param api_key String:Your DataDog API Key. # @param datadog_site String: The site of the Datadog intake to send Agent data to. Defaults to 'datadoghq.com'. -# @param agent_major_version Integer: The major version of the Datadog agent to install. Defaults to 7. -# @param agent_minor_version Optional[String]: The minor version of the Datadog agent to install. # @param installer_repo_uri Optional[String]: The URI of the installer repository. # @param rpm_repo_gpgcheck Optional[Boolean]: Whether to check the GPG signature of the repository. # @param apm_instrumentation_enabled Optional[Enum['host', 'docker', 'all']]: Enable APM instrumentation for the specified environment (host, docker, or all). # @param apm_instrumentation_libraries_str Optional[String]: APM instrumentation libraries as a comma-separated string. -# @param remote_updates Boolean: Whether to enable Agent remote updates. Default: false. -# @param remote_policies Boolean: Whether to enable Agent remote policies. Default: false. # class datadog_agent::suse_installer ( String $api_key = 'your_API_key', String $datadog_site = $datadog_agent::params::datadog_site, - Integer $agent_major_version = $datadog_agent::params::default_agent_major_version, - Optional[String] $agent_minor_version = undef, Optional[String] $installer_repo_uri = undef, Optional[Boolean] $rpm_repo_gpgcheck = undef, Optional[Enum['host', 'docker', 'all']] $apm_instrumentation_enabled = undef, Optional[String] $apm_instrumentation_libraries_str = undef, - Boolean $remote_updates = $datadog_agent::params::remote_updates, - Boolean $remote_policies = $datadog_agent::params::remote_policies, ) inherits datadog_agent::params { # Generate installer trace ID as a random 64-bit integer (Puppet does not support 128-bit integers) # Note: we cannot use fqdn_rand as the seed is dependent on the node, meaning the same trace ID would be generated on each run (for the same node) @@ -120,29 +112,12 @@ environment => [ "DD_SITE=${datadog_site}", "DD_API_KEY=${api_key}", - "DD_AGENT_MAJOR_VERSION=${agent_major_version}", - "DD_AGENT_MINOR_VERSION=${agent_minor_version}", - "DD_REMOTE_UPDATES=${remote_updates}", - "DD_REMOTE_POLICIES=${remote_policies}", "DD_APM_INSTRUMENTATION_ENABLED=${apm_instrumentation_enabled}", "DD_APM_INSTRUMENTATION_LIBRARIES=${apm_instrumentation_libraries_str}", ], require => Package['datadog-installer'], } - # Check if installer owns the Datadog Agent package - exec { - 'Check if installer owns the Datadog Agent package': - command => '/usr/bin/datadog-installer is-installed datadog-agent', - environment => [ - "DD_SITE=${datadog_site}", - "DD_API_KEY=${api_key}", - ], - # We allow 0, 10 (package not installed) - returns => [0, 10], - require => Exec['Bootstrap the installer'], - } - # Check if installer owns APM libraries if $apm_instrumentation_libraries_str != '' { $apm_instrumentation_libraries_str.split(',').each |$library| { @@ -166,15 +141,10 @@ require => Exec['Bootstrap the installer'], } - if $remote_updates { - $packages_to_install = "datadog-agent,${apm_instrumentation_libraries_str}" - } else { - $packages_to_install = $apm_instrumentation_libraries_str - } class { 'datadog_agent::installer_telemetry': api_key => $api_key, datadog_site => $datadog_site, - packages_to_install => $packages_to_install, + packages_to_install => $apm_instrumentation_libraries_str, require => Exec['End timer'], } } diff --git a/manifests/ubuntu_installer.pp b/manifests/ubuntu_installer.pp index 6f22c797..3e4e3926 100644 --- a/manifests/ubuntu_installer.pp +++ b/manifests/ubuntu_installer.pp @@ -3,26 +3,18 @@ # # @param api_key String:Your DataDog API Key. # @param datadog_site String: The site of the Datadog intake to send Agent data to. Defaults to 'datadoghq.com'. -# @param agent_major_version Integer: The major version of the Datadog agent to install. Defaults to 7. -# @param agent_minor_version Optional[String]: The minor version of the Datadog agent to install. # @param installer_repo_uri Optional[String]: The URI of the installer repository. # @param release String: The distribution channel to be used for the APT repo. Eg: 'stable' or 'beta'. Default: stable. # @param skip_apt_key_trusting Boolean: Skip trusting the apt key. Default is false. -# @param manage_agent_install Boolean: Whether Puppet should manage the regular Agent installation. Default is true (inherited from $manage_install). # @param apt_trusted_d_keyring String: The path to the trusted keyring file. # @param apt_usr_share_keyring String: The path to the keyring file in /usr/share. # @param apt_default_keys Hash[String, String]: A hash of default APT keys and their URLs. # @param apm_instrumentation_enabled Optional[Enum['host', 'docker', 'all']]: Enable APM instrumentation for the specified environment (host, docker, or all). # @param apm_instrumentation_libraries_str Optional[String]: APM instrumentation libraries as a comma-separated string. -# @param remote_updates Boolean: Whether to enable Agent remote updates. Default: false. -# @param remote_policies Boolean: Whether to enable Agent remote policies. Default: false. # class datadog_agent::ubuntu_installer ( String $api_key = 'your_API_key', String $datadog_site = $datadog_agent::params::datadog_site, - Integer $agent_major_version = $datadog_agent::params::default_agent_major_version, - Optional[String] $agent_minor_version = undef, - Boolean $manage_agent_install = true, Optional[String] $installer_repo_uri = undef, String $release = $datadog_agent::params::apt_default_release, Boolean $skip_apt_key_trusting = false, @@ -43,8 +35,6 @@ }, Optional[Enum['host', 'docker', 'all']] $apm_instrumentation_enabled = undef, Optional[String] $apm_instrumentation_libraries_str = undef, - Boolean $remote_updates = $datadog_agent::params::remote_updates, - Boolean $remote_policies = $datadog_agent::params::remote_policies, ) inherits datadog_agent::params { # Generate installer trace ID as a random 64-bit integer (Puppet does not support 128-bit integers) # Note: we cannot use fqdn_rand as the seed is dependent on the node, meaning the same trace ID would be generated on each run (for the same node) @@ -65,7 +55,7 @@ } # Do not re-install keys as it is already managed in `ubuntu.pp` - if ! $manage_agent_install { + if ! $datadog_agent::manage_install { if !$skip_apt_key_trusting { stdlib::ensure_packages(['gnupg']) @@ -135,29 +125,12 @@ environment => [ "DD_SITE=${datadog_site}", "DD_API_KEY=${api_key}", - "DD_AGENT_MAJOR_VERSION=${agent_major_version}", - "DD_AGENT_MINOR_VERSION=${agent_minor_version}", - "DD_REMOTE_UPDATES=${remote_updates}", - "DD_REMOTE_POLICIES=${remote_policies}", "DD_APM_INSTRUMENTATION_ENABLED=${apm_instrumentation_enabled}", "DD_APM_INSTRUMENTATION_LIBRARIES=${apm_instrumentation_libraries_str}", ], require => Package['datadog-installer'], } - # Check if installer owns the Datadog Agent package - exec { - 'Check if installer owns the Datadog Agent package': - command => '/usr/bin/datadog-installer is-installed datadog-agent', - environment => [ - "DD_SITE=${datadog_site}", - "DD_API_KEY=${api_key}", - ], - # We allow 0, 10 (package not installed) - returns => [0, 10], - require => Exec['Bootstrap the installer'], - } - # Check if installer owns APM libraries if $apm_instrumentation_libraries_str != '' { $apm_instrumentation_libraries_str.split(',').each |$library| { @@ -181,15 +154,10 @@ require => Exec['Bootstrap the installer'], } - if $remote_updates { - $packages_to_install = "datadog-agent,${apm_instrumentation_libraries_str}" - } else { - $packages_to_install = $apm_instrumentation_libraries_str - } class { 'datadog_agent::installer_telemetry': api_key => $api_key, datadog_site => $datadog_site, - packages_to_install => $packages_to_install, + packages_to_install => $apm_instrumentation_libraries_str, require => Exec['End timer'], } } From 29fd4405b03d66d4ea492aaad743787f58986a21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Bavelier?= <97530782+tbavelier@users.noreply.github.com> Date: Mon, 8 Sep 2025 16:59:18 +0200 Subject: [PATCH 3/4] Include libyaml-dev to fix psych dependency (#868) * Include libyaml-dev to fix psych dependency * install libyaml-dev repository --- kitchen.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/kitchen.yml b/kitchen.yml index 9e6b2301..805e8ba6 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -22,7 +22,7 @@ platforms: - wget https://apt.puppet.com/puppet8-release-noble.deb - dpkg -i puppet8-release-noble.deb #installs the puppet-agent repo - apt-get update - - apt-get install -y puppet-agent rubygems ruby-dev make gcc + - apt-get install -y puppet-agent rubygems ruby-dev make gcc libyaml-dev - ln -s /opt/puppetlabs/bin/puppet /usr/bin/puppet - mkdir /home/kitchen/puppet @@ -42,7 +42,7 @@ platforms: - wget https://apt.puppet.com/puppet8-release-jammy.deb - dpkg -i puppet8-release-jammy.deb #installs the puppet-agent repo - apt-get update - - apt-get install -y puppet-agent rubygems ruby-dev make gcc + - apt-get install -y puppet-agent rubygems ruby-dev make gcc libyaml-dev - ln -s /opt/puppetlabs/bin/puppet /usr/bin/puppet - mkdir /home/kitchen/puppet -p @@ -62,7 +62,7 @@ platforms: - wget https://apt.puppet.com/puppet7-release-focal.deb - dpkg -i puppet7-release-focal.deb #installs the puppet-agent repo - apt-get update - - apt-get install -y puppet-agent rubygems ruby-dev + - apt-get install -y puppet-agent rubygems ruby-dev libyaml-dev - ln -s /opt/puppetlabs/bin/puppet /usr/bin/puppet - mkdir /home/kitchen/puppet @@ -89,6 +89,9 @@ platforms: - rpm -Uvh https://yum.puppet.com/puppet8-release-el-9.noarch.rpm #installs the puppet-agent repo - yum install -y puppet-agent-8.10.0 rubygems ruby-devel procps-ng - dnf group install -y "Development Tools" + - dnf install -y dnf-plugins-core + - dnf config-manager --set-enabled crb + - dnf install -y libyaml-devel - ln -s /opt/puppetlabs/bin/puppet /usr/bin/puppet - mkdir /home/kitchen/puppet -p @@ -117,6 +120,9 @@ platforms: - rpm -Uvh https://yum.puppet.com/puppet8-release-el-9.noarch.rpm #installs the puppet-agent repo - yum install -y puppet-agent-8.10.0 rubygems ruby-devel procps-ng - dnf group install -y "Development Tools" --nobest + - dnf install -y dnf-plugins-core + - dnf config-manager --set-enabled crb + - dnf install -y libyaml-devel - ln -s /opt/puppetlabs/bin/puppet /usr/bin/puppet - mkdir /home/kitchen/puppet -p From 6fa4781273e16791e896c3f132917db72676d691 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Bavelier?= <97530782+tbavelier@users.noreply.github.com> Date: Mon, 8 Sep 2025 17:46:34 +0200 Subject: [PATCH 4/4] [Release] 4.1.0 (#867) * [Release] 4.1.0 * Update changelog with test fix PR --- CHANGELOG.md | 7 +++++++ metadata.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b7d1930e..63c015f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ Changes +# 4.1.0 / 2025-09-08 + +* [FEATURE] Support Remote Agent updates with Fleet Automation ([#866]). +* [CHORE] Fix CI Kitchen tests by including `libyaml-dev` installation required by `psych` sub-dependency ([#868]). + # 4.0.3 / 2025-04-14 * [BUGFIX] Handle Windows Agent pinned version above 7.46 ([#860]). @@ -999,6 +1004,8 @@ Please read the [docs]() for more details. [#852]: https://github.com/DataDog/puppet-datadog-agent/issues/852 [#856]: https://github.com/DataDog/puppet-datadog-agent/issues/856 [#860]: https://github.com/DataDog/puppet-datadog-agent/issues/860 +[#866]: https://github.com/DataDog/puppet-datadog-agent/issues/866 +[#867]: https://github.com/DataDog/puppet-datadog-agent/issues/868 [@Aramack]: https://github.com/Aramack [@BIAndrews]: https://github.com/BIAndrews [@ChannoneArif-nbcuni]: https://github.com/ChannoneArif-nbcuni diff --git a/metadata.json b/metadata.json index 2ba12644..84fb1615 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "datadog-datadog_agent", - "version": "4.0.3", + "version": "4.1.0", "author": "James Turnbull , Rob Terhaar , Jaime Fullaondo , Albert Vaca ", "summary": "Install the Datadog monitoring agent and report Puppet runs to Datadog", "license": "Apache-2.0",