Skip to content

Commit 434f51a

Browse files
committed
Logic to auto-detect agent_major_version
1 parent 03b7c19 commit 434f51a

56 files changed

Lines changed: 75 additions & 64 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

manifests/init.pp

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@
285285
Boolean $sd_jmx_enable = false,
286286
String $consul_token = '',
287287
Integer $cmd_port = 5001,
288-
Integer $agent_major_version = $datadog_agent::params::agent_major_version,
288+
Optional[Integer] $agent_major_version = undef,
289289
Optional[String] $conf_dir = undef,
290290
Boolean $conf_dir_purge = $datadog_agent::params::conf_dir_purge,
291291
$dd_user = $datadog_agent::params::dd_user,
@@ -313,7 +313,18 @@
313313
Optional[String] $agent_version = $datadog_agent::params::agent_version,
314314
) inherits datadog_agent::params {
315315

316-
if $agent_major_version != 5 and $agent_major_version != 6 and $agent_major_version != 7 {
316+
if $agent_version != 'latest' and $agent_version =~ /([0-9]+:)?([0-9]+)\.([0-9]+)\.([0-9]+)([^-\s]+)?(?:-([0-9]+))?/ {
317+
$_agent_major_version = 0 + $2 # Cast to integer
318+
if $agent_major_version != undef and $agent_major_version != $_agent_major_version {
319+
fail('Provided and deduced agent_major_version don\'t match')
320+
}
321+
} elsif $agent_major_version != undef {
322+
$_agent_major_version = $agent_major_version
323+
} else {
324+
$_agent_major_version = $datadog_agent::params::default_agent_major_version
325+
}
326+
327+
if $_agent_major_version != 5 and $_agent_major_version != 6 and $_agent_major_version != 7 {
317328
fail('agent_major_version must be either 5, 6 or 7')
318329
}
319330

@@ -335,7 +346,7 @@
335346
validate_legacy(String, 'validate_re', $_syslog_port, '^\d*$')
336347

337348
if $conf_dir == undef {
338-
if $agent_major_version == 5 {
349+
if $_agent_major_version == 5 {
339350
$_conf_dir = $datadog_agent::params::legacy_conf_dir
340351
} else {
341352
$_conf_dir = $datadog_agent::params::conf_dir
@@ -377,7 +388,7 @@
377388
case $::operatingsystem {
378389
'Ubuntu','Debian' : {
379390
class { 'datadog_agent::ubuntu':
380-
agent_major_version => $agent_major_version,
391+
agent_major_version => $_agent_major_version,
381392
agent_version => $agent_version,
382393
service_ensure => $service_ensure,
383394
service_enable => $service_enable,
@@ -390,7 +401,7 @@
390401
}
391402
'RedHat','CentOS','Fedora','Amazon','Scientific','OracleLinux' : {
392403
class { 'datadog_agent::redhat':
393-
agent_major_version => $agent_major_version,
404+
agent_major_version => $_agent_major_version,
394405
agent_repo_uri => $agent_repo_uri,
395406
manage_repo => $manage_repo,
396407
agent_version => $agent_version,
@@ -401,7 +412,7 @@
401412
}
402413
'Windows' : {
403414
class { 'datadog_agent::windows' :
404-
agent_major_version => $agent_major_version,
415+
agent_major_version => $_agent_major_version,
405416
agent_repo_uri => $agent_repo_uri,
406417
agent_version => $agent_version,
407418
service_ensure => $service_ensure,
@@ -438,7 +449,7 @@
438449
}
439450
}
440451

441-
if $agent_major_version == 5 {
452+
if $_agent_major_version == 5 {
442453

443454
if ($::operatingsystem == 'Windows') {
444455
fail('Installation of agent 5 with puppet is not supported on Windows')

manifests/integration.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
include datadog_agent
99

10-
if $::datadog_agent::agent_major_version > 5 {
10+
if $::datadog_agent::_agent_major_version > 5 {
1111
$dst = "${datadog_agent::params::conf_dir}/${integration}.d/conf.yaml"
1212
file { "${datadog_agent::params::conf_dir}/${integration}.d":
1313
ensure => directory,

manifests/integrations/activemq_xml.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
include datadog_agent
5656

5757
$legacy_dst = "${datadog_agent::params::legacy_conf_dir}/activemq_xml.yaml"
58-
if $::datadog_agent::agent_major_version > 5 {
58+
if $::datadog_agent::_agent_major_version > 5 {
5959
$dst_dir = "${datadog_agent::params::conf_dir}/activemq_xml.d"
6060
file { $legacy_dst:
6161
ensure => 'absent'

manifests/integrations/apache.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
include datadog_agent
3737

3838
$legacy_dst = "${datadog_agent::params::legacy_conf_dir}/apache.yaml"
39-
if $::datadog_agent::agent_major_version > 5 {
39+
if $::datadog_agent::_agent_major_version > 5 {
4040
$dst_dir = "${datadog_agent::params::conf_dir}/apache.d"
4141
file { $legacy_dst:
4242
ensure => 'absent'

manifests/integrations/cacti.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
include datadog_agent
2222

2323
$legacy_dst = "${datadog_agent::params::legacy_conf_dir}/cacti.yaml"
24-
if $::datadog_agent::agent_major_version > 5 {
24+
if $::datadog_agent::_agent_major_version > 5 {
2525
$dst_dir = "${datadog_agent::params::conf_dir}/cacti.d"
2626
file { $legacy_dst:
2727
ensure => 'absent'

manifests/integrations/cassandra.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
require ::datadog_agent
3636

3737
$legacy_dst = "${datadog_agent::params::legacy_conf_dir}/cassandra.yaml"
38-
if $::datadog_agent::agent_major_version > 5 {
38+
if $::datadog_agent::_agent_major_version > 5 {
3939
$dst_dir = "${datadog_agent::params::conf_dir}/cassandra.d"
4040

4141
file { $legacy_dst:

manifests/integrations/ceph.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
}
2525

2626
$legacy_dst = "${datadog_agent::params::legacy_conf_dir}/ceph.yaml"
27-
if $::datadog_agent::agent_major_version > 5 {
27+
if $::datadog_agent::_agent_major_version > 5 {
2828
$dst_dir = "${datadog_agent::params::conf_dir}/ceph.d"
2929
file { $legacy_dst:
3030
ensure => 'absent'

manifests/integrations/consul.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
include datadog_agent
3737

3838
$legacy_dst = "${datadog_agent::params::legacy_conf_dir}/consul.yaml"
39-
if $::datadog_agent::agent_major_version > 5 {
39+
if $::datadog_agent::_agent_major_version > 5 {
4040
$dst_dir = "${datadog_agent::params::conf_dir}/consul.d"
4141
file { $legacy_dst:
4242
ensure => 'absent'

manifests/integrations/directory.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
}
9090

9191
$legacy_dst = "${datadog_agent::params::legacy_conf_dir}/directory.yaml"
92-
if $::datadog_agent::agent_major_version > 5 {
92+
if $::datadog_agent::_agent_major_version > 5 {
9393
$dst_dir = "${datadog_agent::params::conf_dir}/directory.d"
9494
file { $legacy_dst:
9595
ensure => 'absent'

manifests/integrations/disk.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
}
7171

7272
$legacy_dst = "${datadog_agent::params::legacy_conf_dir}/disk.yaml"
73-
if $::datadog_agent::agent_major_version > 5 {
73+
if $::datadog_agent::_agent_major_version > 5 {
7474
$dst_dir = "${datadog_agent::params::conf_dir}/disk.d"
7575
file { $legacy_dst:
7676
ensure => 'absent'

0 commit comments

Comments
 (0)