|
285 | 285 | Boolean $sd_jmx_enable = false, |
286 | 286 | String $consul_token = '', |
287 | 287 | Integer $cmd_port = 5001, |
288 | | - Integer $agent_major_version = $datadog_agent::params::agent_major_version, |
| 288 | + Optional[Integer] $agent_major_version = undef, |
289 | 289 | Optional[String] $conf_dir = undef, |
290 | 290 | Boolean $conf_dir_purge = $datadog_agent::params::conf_dir_purge, |
291 | 291 | $dd_user = $datadog_agent::params::dd_user, |
|
313 | 313 | Optional[String] $agent_version = $datadog_agent::params::agent_version, |
314 | 314 | ) inherits datadog_agent::params { |
315 | 315 |
|
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 { |
317 | 328 | fail('agent_major_version must be either 5, 6 or 7') |
318 | 329 | } |
319 | 330 |
|
|
335 | 346 | validate_legacy(String, 'validate_re', $_syslog_port, '^\d*$') |
336 | 347 |
|
337 | 348 | if $conf_dir == undef { |
338 | | - if $agent_major_version == 5 { |
| 349 | + if $_agent_major_version == 5 { |
339 | 350 | $_conf_dir = $datadog_agent::params::legacy_conf_dir |
340 | 351 | } else { |
341 | 352 | $_conf_dir = $datadog_agent::params::conf_dir |
|
377 | 388 | case $::operatingsystem { |
378 | 389 | 'Ubuntu','Debian' : { |
379 | 390 | class { 'datadog_agent::ubuntu': |
380 | | - agent_major_version => $agent_major_version, |
| 391 | + agent_major_version => $_agent_major_version, |
381 | 392 | agent_version => $agent_version, |
382 | 393 | service_ensure => $service_ensure, |
383 | 394 | service_enable => $service_enable, |
|
390 | 401 | } |
391 | 402 | 'RedHat','CentOS','Fedora','Amazon','Scientific','OracleLinux' : { |
392 | 403 | class { 'datadog_agent::redhat': |
393 | | - agent_major_version => $agent_major_version, |
| 404 | + agent_major_version => $_agent_major_version, |
394 | 405 | agent_repo_uri => $agent_repo_uri, |
395 | 406 | manage_repo => $manage_repo, |
396 | 407 | agent_version => $agent_version, |
|
401 | 412 | } |
402 | 413 | 'Windows' : { |
403 | 414 | class { 'datadog_agent::windows' : |
404 | | - agent_major_version => $agent_major_version, |
| 415 | + agent_major_version => $_agent_major_version, |
405 | 416 | agent_repo_uri => $agent_repo_uri, |
406 | 417 | agent_version => $agent_version, |
407 | 418 | service_ensure => $service_ensure, |
|
438 | 449 | } |
439 | 450 | } |
440 | 451 |
|
441 | | - if $agent_major_version == 5 { |
| 452 | + if $_agent_major_version == 5 { |
442 | 453 |
|
443 | 454 | if ($::operatingsystem == 'Windows') { |
444 | 455 | fail('Installation of agent 5 with puppet is not supported on Windows') |
|
0 commit comments