Skip to content

Commit c21e93c

Browse files
committed
do not manage Agent with deprecated deb/rpm installer
1 parent cce8020 commit c21e93c

4 files changed

Lines changed: 124 additions & 271 deletions

File tree

manifests/init.pp

Lines changed: 120 additions & 175 deletions
Original file line numberDiff line numberDiff line change
@@ -439,194 +439,95 @@
439439
default: { $_loglevel = 'INFO' }
440440
}
441441

442-
if $datadog_installer_enabled {
443-
# If instrumentation is enabled and the libraries are not set, default to pinned latest versions
444-
# Else, if user wants to install libraries without enabling instrumentation, use the provided libraries
445-
if $apm_instrumentation_enabled and ! $apm_instrumentation_libraries {
446-
$apm_instrumentation_libraries_str = join(['java:1', 'python:2', 'js:5', 'dotnet:3', 'ruby:2'], ',')
447-
} elsif $apm_instrumentation_libraries {
448-
$apm_instrumentation_libraries_str = join($apm_instrumentation_libraries, ',')
449-
} else {
450-
$apm_instrumentation_libraries_str = ''
451-
}
452-
# Agent version handling: the installer expects DD_AGENT_MINOR_VERSION to include the patch version.
453-
# $_agent_minor_version is the minor version without the patch version.
454-
# We need to add the patch version to the minor version to get the full version.
455-
# 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.
456-
if $_agent_minor_version != undef and $_agent_patch_version != undef {
457-
$_agent_minor_version_full = "${_agent_minor_version}.${_agent_patch_version}"
458-
} else {
459-
$_agent_minor_version_full = ''
460-
}
442+
# Install agent
443+
if $manage_install {
461444
case $facts['os']['name'] {
462-
'Ubuntu','Debian','Raspbian': {
463-
class { 'datadog_agent::ubuntu_installer':
464-
api_key => $api_key,
465-
datadog_site => $datadog_site,
466-
agent_major_version => $_agent_major_version,
467-
agent_minor_version => $_agent_minor_version_full,
468-
manage_agent_install => $manage_install,
469-
installer_repo_uri => $agent_repo_uri,
470-
release => $apt_release,
471-
skip_apt_key_trusting => $skip_apt_key_trusting,
472-
apm_instrumentation_enabled => $apm_instrumentation_enabled,
473-
apm_instrumentation_libraries_str => $apm_instrumentation_libraries_str,
474-
remote_updates => $remote_updates,
475-
remote_policies => $remote_policies,
445+
'Ubuntu','Debian','Raspbian' : {
446+
if $use_apt_backup_keyserver != undef or $apt_backup_keyserver != undef or $apt_keyserver != undef {
447+
notify { 'apt keyserver arguments deprecation':
448+
message => '$use_apt_backup_keyserver, $apt_backup_keyserver and $apt_keyserver are deprecated since version 3.13.0',
449+
loglevel => 'warning',
450+
}
476451
}
477-
}
478-
'RedHat','CentOS','Fedora','Amazon','Scientific','OracleLinux','AlmaLinux','Rocky' : {
479-
class { 'datadog_agent::redhat_installer':
480-
api_key => $api_key,
481-
datadog_site => $datadog_site,
482-
agent_major_version => $_agent_major_version,
483-
agent_minor_version => $_agent_minor_version_full,
484-
installer_repo_uri => $agent_repo_uri,
485-
rpm_repo_gpgcheck => $rpm_repo_gpgcheck,
486-
apm_instrumentation_enabled => $apm_instrumentation_enabled,
487-
apm_instrumentation_libraries_str => $apm_instrumentation_libraries_str,
488-
remote_updates => $remote_updates,
489-
remote_policies => $remote_policies,
452+
class { 'datadog_agent::ubuntu':
453+
agent_major_version => $_agent_major_version,
454+
agent_version => $agent_full_version,
455+
agent_flavor => $agent_flavor,
456+
agent_repo_uri => $agent_repo_uri,
457+
release => $apt_release,
458+
skip_apt_key_trusting => $skip_apt_key_trusting,
490459
}
491460
}
492-
'OpenSuSE', 'SLES' : {
493-
class { 'datadog_agent::suse_installer':
494-
api_key => $api_key,
495-
datadog_site => $datadog_site,
496-
agent_major_version => $_agent_major_version,
497-
agent_minor_version => $_agent_minor_version_full,
498-
installer_repo_uri => $agent_repo_uri,
499-
rpm_repo_gpgcheck => $rpm_repo_gpgcheck,
500-
apm_instrumentation_enabled => $apm_instrumentation_enabled,
501-
apm_instrumentation_libraries_str => $apm_instrumentation_libraries_str,
502-
remote_updates => $remote_updates,
503-
remote_policies => $remote_policies,
461+
'RedHat','CentOS','Fedora','Amazon','Scientific','OracleLinux','AlmaLinux','Rocky' : {
462+
class { 'datadog_agent::redhat':
463+
agent_major_version => $_agent_major_version,
464+
agent_flavor => $agent_flavor,
465+
agent_repo_uri => $agent_repo_uri,
466+
manage_repo => $manage_repo,
467+
agent_version => $agent_full_version,
468+
rpm_repo_gpgcheck => $rpm_repo_gpgcheck,
504469
}
505470
}
506-
default: { fail("Class[datadog_agent::installer]: Unsupported operatingsystem: ${facts['os']['name']}") }
507-
}
508-
}
509-
510-
# If the agent is managed by the installer, we don't need to manage the agent installation
511-
$_agent_managed_by_installer = ($datadog_installer_enabled and $remote_updates)
512-
513-
# Install agent
514-
if ! $_agent_managed_by_installer {
515-
if $manage_install {
516-
case $facts['os']['name'] {
517-
'Ubuntu','Debian','Raspbian' : {
518-
if $use_apt_backup_keyserver != undef or $apt_backup_keyserver != undef or $apt_keyserver != undef {
519-
notify { 'apt keyserver arguments deprecation':
520-
message => '$use_apt_backup_keyserver, $apt_backup_keyserver and $apt_keyserver are deprecated since version 3.13.0',
521-
loglevel => 'warning',
522-
}
523-
}
524-
class { 'datadog_agent::ubuntu':
525-
agent_major_version => $_agent_major_version,
526-
agent_version => $agent_full_version,
527-
agent_flavor => $agent_flavor,
528-
agent_repo_uri => $agent_repo_uri,
529-
release => $apt_release,
530-
skip_apt_key_trusting => $skip_apt_key_trusting,
531-
}
532-
}
533-
'RedHat','CentOS','Fedora','Amazon','Scientific','OracleLinux','AlmaLinux','Rocky' : {
534-
class { 'datadog_agent::redhat':
535-
agent_major_version => $_agent_major_version,
536-
agent_flavor => $agent_flavor,
537-
agent_repo_uri => $agent_repo_uri,
538-
manage_repo => $manage_repo,
539-
agent_version => $agent_full_version,
540-
rpm_repo_gpgcheck => $rpm_repo_gpgcheck,
541-
}
471+
'Windows' : {
472+
class { 'datadog_agent::windows' :
473+
agent_major_version => $_agent_major_version,
474+
agent_repo_uri => $agent_repo_uri,
475+
agent_version => $agent_full_version,
476+
msi_location => $win_msi_location,
477+
api_key => $api_key,
478+
hostname => $host,
479+
tags => $local_tags,
480+
ensure => $win_ensure,
481+
npm_install => $windows_npm_install,
482+
ddagentuser_name => $windows_ddagentuser_name,
483+
ddagentuser_password => $windows_ddagentuser_password,
542484
}
543-
'Windows' : {
544-
class { 'datadog_agent::windows' :
545-
agent_major_version => $_agent_major_version,
546-
agent_repo_uri => $agent_repo_uri,
547-
agent_version => $agent_full_version,
548-
msi_location => $win_msi_location,
549-
api_key => $api_key,
550-
hostname => $host,
551-
tags => $local_tags,
552-
ensure => $win_ensure,
553-
npm_install => $windows_npm_install,
554-
ddagentuser_name => $windows_ddagentuser_name,
555-
ddagentuser_password => $windows_ddagentuser_password,
556-
}
557-
if ($win_ensure == absent) {
558-
return() #Config files will remain unchanged on uninstall
559-
}
485+
if ($win_ensure == absent) {
486+
return() #Config files will remain unchanged on uninstall
560487
}
561-
'OpenSuSE', 'SLES' : {
562-
class { 'datadog_agent::suse' :
563-
agent_major_version => $_agent_major_version,
564-
agent_flavor => $agent_flavor,
565-
agent_repo_uri => $agent_repo_uri,
566-
agent_version => $agent_full_version,
567-
rpm_repo_gpgcheck => $rpm_repo_gpgcheck,
568-
}
569-
}
570-
default: { fail("Class[datadog_agent]: Unsupported operatingsystem: ${facts['os']['name']}") }
571488
}
572-
} else {
573-
if ! defined(Package[$agent_flavor]) {
574-
package { $agent_flavor:
575-
ensure => present,
576-
source => 'Agent installation not managed by Puppet, make sure the Agent is installed beforehand.',
489+
'OpenSuSE', 'SLES' : {
490+
class { 'datadog_agent::suse' :
491+
agent_major_version => $_agent_major_version,
492+
agent_flavor => $agent_flavor,
493+
agent_repo_uri => $agent_repo_uri,
494+
agent_version => $agent_full_version,
495+
rpm_repo_gpgcheck => $rpm_repo_gpgcheck,
577496
}
578497
}
498+
default: { fail("Class[datadog_agent]: Unsupported operatingsystem: ${facts['os']['name']}") }
499+
}
500+
} else {
501+
if ! defined(Package[$agent_flavor]) {
502+
package { $agent_flavor:
503+
ensure => present,
504+
source => 'Agent installation not managed by Puppet, make sure the Agent is installed beforehand.',
505+
}
579506
}
580507
}
581508

582509
# Declare service
583-
if ! $_agent_managed_by_installer {
584-
class { 'datadog_agent::service' :
585-
agent_flavor => $agent_flavor,
586-
service_ensure => $service_ensure,
587-
service_enable => $service_enable,
588-
service_provider => $service_provider,
589-
}
590-
if ($facts['os']['name'] != 'Windows') {
591-
if ($dd_groups) {
592-
user { $dd_user:
593-
groups => $dd_groups,
594-
notify => Service[$datadog_agent::params::service_name],
595-
}
596-
}
597-
598-
# required by reports even in agent5 scenario
599-
file { '/etc/datadog-agent':
600-
ensure => directory,
601-
owner => $dd_user,
602-
group => $dd_group,
603-
mode => $datadog_agent::params::permissions_directory,
604-
require => Package[$agent_flavor],
510+
class { 'datadog_agent::service' :
511+
agent_flavor => $agent_flavor,
512+
service_ensure => $service_ensure,
513+
service_enable => $service_enable,
514+
service_provider => $service_provider,
515+
}
516+
if ($facts['os']['name'] != 'Windows') {
517+
if ($dd_groups) {
518+
user { $dd_user:
519+
groups => $dd_groups,
520+
notify => Service[$datadog_agent::params::service_name],
605521
}
606522
}
607-
} else {
608-
class { 'datadog_agent::service' :
609-
# Declare service for agent managed by installer with installer flavor
610-
agent_flavor => 'datadog-installer',
611-
service_ensure => $service_ensure,
612-
service_enable => $service_enable,
613-
service_provider => $service_provider,
614-
}
615-
if ($facts['os']['name'] != 'Windows') {
616-
if ($dd_groups) {
617-
user { $dd_user:
618-
groups => $dd_groups,
619-
notify => Service[$datadog_agent::params::service_name],
620-
}
621-
}
622-
# required to manage config and install info files even with installer
623-
file { '/etc/datadog-agent':
624-
ensure => directory,
625-
owner => $dd_user,
626-
group => $dd_group,
627-
mode => $datadog_agent::params::permissions_directory,
628-
require => Package['datadog-installer'],
629-
}
523+
524+
# required by reports even in agent5 scenario
525+
file { '/etc/datadog-agent':
526+
ensure => directory,
527+
owner => $dd_user,
528+
group => $dd_group,
529+
mode => $datadog_agent::params::permissions_directory,
530+
require => Package[$agent_flavor],
630531
}
631532
}
632533

@@ -751,10 +652,7 @@
751652
force => $conf_dir_purge,
752653
owner => $dd_user,
753654
group => $dd_group,
754-
}
755-
756-
if ! $_agent_managed_by_installer {
757-
File[$_conf_dir] ~> Service[$datadog_agent::params::service_name]
655+
notify => Service[$datadog_agent::params::service_name],
758656
}
759657

760658
$_local_tags = datadog_agent::tag6($local_tags, false, undef)
@@ -851,4 +749,51 @@
851749
}
852750

853751
create_resources('datadog_agent::integration', $local_integrations)
752+
753+
# Install the deprecated RPM/DEB installer if APM instrumentation is enabled
754+
if $datadog_installer_enabled {
755+
# If instrumentation is enabled and the libraries are not set, default to pinned latest versions
756+
# Else, if user wants to install libraries without enabling instrumentation, use the provided libraries
757+
if $apm_instrumentation_enabled and ! $apm_instrumentation_libraries {
758+
$apm_instrumentation_libraries_str = join(['java:1', 'python:2', 'js:5', 'dotnet:3', 'ruby:2'], ',')
759+
} elsif $apm_instrumentation_libraries {
760+
$apm_instrumentation_libraries_str = join($apm_instrumentation_libraries, ',')
761+
} else {
762+
$apm_instrumentation_libraries_str = ''
763+
}
764+
case $facts['os']['name'] {
765+
'Ubuntu','Debian','Raspbian': {
766+
class { 'datadog_agent::ubuntu_installer':
767+
api_key => $api_key,
768+
datadog_site => $datadog_site,
769+
installer_repo_uri => $agent_repo_uri,
770+
release => $apt_release,
771+
skip_apt_key_trusting => $skip_apt_key_trusting,
772+
apm_instrumentation_enabled => $apm_instrumentation_enabled,
773+
apm_instrumentation_libraries_str => $apm_instrumentation_libraries_str,
774+
}
775+
}
776+
'RedHat','CentOS','Fedora','Amazon','Scientific','OracleLinux','AlmaLinux','Rocky' : {
777+
class { 'datadog_agent::redhat_installer':
778+
api_key => $api_key,
779+
datadog_site => $datadog_site,
780+
installer_repo_uri => $agent_repo_uri,
781+
rpm_repo_gpgcheck => $rpm_repo_gpgcheck,
782+
apm_instrumentation_enabled => $apm_instrumentation_enabled,
783+
apm_instrumentation_libraries_str => $apm_instrumentation_libraries_str,
784+
}
785+
}
786+
'OpenSuSE', 'SLES' : {
787+
class { 'datadog_agent::suse_installer':
788+
api_key => $api_key,
789+
datadog_site => $datadog_site,
790+
installer_repo_uri => $agent_repo_uri,
791+
rpm_repo_gpgcheck => $rpm_repo_gpgcheck,
792+
apm_instrumentation_enabled => $apm_instrumentation_enabled,
793+
apm_instrumentation_libraries_str => $apm_instrumentation_libraries_str,
794+
}
795+
}
796+
default: { fail("Class[datadog_agent::installer]: Unsupported operatingsystem: ${facts['os']['name']}") }
797+
}
798+
}
854799
}

0 commit comments

Comments
 (0)