Skip to content

Commit 3985da9

Browse files
authored
Centos 6 deprecation and relevant GPG keys installation (#806)
1 parent d60332f commit 3985da9

File tree

5 files changed

+46
-19
lines changed

5 files changed

+46
-19
lines changed

manifests/init.pp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,12 +376,27 @@
376376
if $agent_major_version != undef and $agent_major_version != $_agent_major_version {
377377
fail('Provided and deduced agent_major_version don\'t match')
378378
}
379+
$_agent_minor_version = 0 + $3
379380
} elsif $agent_major_version != undef {
380381
$_agent_major_version = $agent_major_version
381382
} else {
382383
$_agent_major_version = $datadog_agent::params::default_agent_major_version
383384
}
384385

386+
case $facts['os']['name'] {
387+
'RedHat', 'CentOS', 'OracleLinux': {
388+
if $facts['os']['release']['full'] =~ /^6(.[0-9])?/ and $agent_version == 'latest' {
389+
notice("datadog-agent ${_agent_major_version}.51 is the last supported version on CentOS 6. Installing ${_agent_major_version}.51 now")
390+
$agent_full_version='7.51.1'
391+
} elsif $facts['os']['release']['full'] =~ /^6(.[0-9])?/ and $_agent_minor_version != undef and $_agent_minor_version > 51 {
392+
fail("datadog-agent ${_agent_major_version}.51 is the last supported version on CentOS 6.")
393+
} else {
394+
$agent_full_version = $agent_version
395+
}
396+
}
397+
default: { $agent_full_version = $agent_version }
398+
}
399+
385400
if $_agent_major_version != 5 and $_agent_major_version != 6 and $_agent_major_version != 7 {
386401
fail("agent_major_version must be either 5, 6 or 7, not ${_agent_major_version}")
387402
}
@@ -438,7 +453,7 @@
438453
}
439454
class { 'datadog_agent::ubuntu':
440455
agent_major_version => $_agent_major_version,
441-
agent_version => $agent_version,
456+
agent_version => $agent_full_version,
442457
agent_flavor => $agent_flavor,
443458
agent_repo_uri => $agent_repo_uri,
444459
release => $apt_release,
@@ -451,15 +466,15 @@
451466
agent_flavor => $agent_flavor,
452467
agent_repo_uri => $agent_repo_uri,
453468
manage_repo => $manage_repo,
454-
agent_version => $agent_version,
469+
agent_version => $agent_full_version,
455470
rpm_repo_gpgcheck => $rpm_repo_gpgcheck,
456471
}
457472
}
458473
'Windows' : {
459474
class { 'datadog_agent::windows' :
460475
agent_major_version => $_agent_major_version,
461476
agent_repo_uri => $agent_repo_uri,
462-
agent_version => $agent_version,
477+
agent_version => $agent_full_version,
463478
msi_location => $win_msi_location,
464479
api_key => $api_key,
465480
hostname => $host,
@@ -478,7 +493,7 @@
478493
agent_major_version => $_agent_major_version,
479494
agent_flavor => $agent_flavor,
480495
agent_repo_uri => $agent_repo_uri,
481-
agent_version => $agent_version,
496+
agent_version => $agent_full_version,
482497
rpm_repo_gpgcheck => $rpm_repo_gpgcheck,
483498
}
484499
}

manifests/redhat.pp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,22 @@
1414

1515
if $manage_repo {
1616

17-
$keys = [
17+
$all_keys = [
1818
'https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public',
19-
'https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public',
2019
'https://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public',
2120
'https://keys.datadoghq.com/DATADOG_RPM_KEY_B01082D3.public',
21+
'https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public',
2222
]
23+
#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'
24+
if $agent_version =~ /([0-9]+:)?([0-9]+)\.([0-9]+)\.([0-9]+)((?:~|-)[^0-9\s-]+[^-\s]*)?(?:-([0-9]+))?/ or $agent_version == 'latest' {
25+
if $agent_major_version > 5 and ($agent_version == 'latest' or 0 + $3 > 35) {
26+
$keys = $all_keys[0,3]
27+
} else {
28+
$keys = $all_keys
29+
}
30+
} else {
31+
$keys = $all_keys
32+
}
2333

2434
if ($rpm_repo_gpgcheck != undef) {
2535
$repo_gpgcheck = $rpm_repo_gpgcheck

manifests/suse.pp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,20 @@
1515
$current_key = 'https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public'
1616
$all_keys = [
1717
$current_key,
18-
'https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public',
1918
'https://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public',
2019
'https://keys.datadoghq.com/DATADOG_RPM_KEY_B01082D3.public',
20+
'https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public',
2121
]
22+
#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'
23+
if $agent_version =~ /([0-9]+:)?([0-9]+)\.([0-9]+)\.([0-9]+)((?:~|-)[^0-9\s-]+[^-\s]*)?(?:-([0-9]+))?/ or $agent_version == 'latest' {
24+
if $agent_major_version > 5 and ($agent_version == 'latest' or 0 + $3 > 35) {
25+
$keys_to_use = $all_keys[0,3]
26+
} else {
27+
$keys_to_use = $all_keys
28+
}
29+
} else {
30+
$keys_to_use = $all_keys
31+
}
2232

2333
if ($rpm_repo_gpgcheck != undef) {
2434
$repo_gpgcheck = $rpm_repo_gpgcheck
@@ -32,8 +42,8 @@
3242

3343
case $agent_major_version {
3444
5 : { fail('Agent v5 package not available in SUSE') }
35-
6 : { $gpgkeys = $all_keys }
36-
7 : { $gpgkeys = $all_keys }
45+
6 : { $gpgkeys = $keys_to_use }
46+
7 : { $gpgkeys = $keys_to_use }
3747
default: { fail('invalid agent_major_version') }
3848
}
3949

spec/classes/datadog_agent_redhat_spec.rb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
.with_enabled(1)\
3535
.with_gpgcheck(1)\
3636
.with_gpgkey('https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public
37-
https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public
3837
https://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public
39-
https://keys.datadoghq.com/DATADOG_RPM_KEY_B01082D3.public')\
38+
https://keys.datadoghq.com/DATADOG_RPM_KEY_B01082D3.public
39+
https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public')\
4040
.with_baseurl('https://yum.datadoghq.com/rpm/x86_64/')\
4141
.with_repo_gpgcheck(false)
4242
end
@@ -89,7 +89,6 @@
8989
.with_enabled(1)\
9090
.with_gpgcheck(1)\
9191
.with_gpgkey('https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public
92-
https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public
9392
https://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public
9493
https://keys.datadoghq.com/DATADOG_RPM_KEY_B01082D3.public')\
9594
.with_baseurl('https://yum.datadoghq.com/stable/6/x86_64/')\
@@ -145,7 +144,6 @@
145144
.with_enabled(1)\
146145
.with_gpgcheck(1)\
147146
.with_gpgkey('https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public
148-
https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public
149147
https://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public
150148
https://keys.datadoghq.com/DATADOG_RPM_KEY_B01082D3.public')\
151149
.with_baseurl('https://yum.datadoghq.com/stable/7/x86_64/')\
@@ -203,7 +201,6 @@
203201
.with_enabled(1)\
204202
.with_gpgcheck(1)\
205203
.with_gpgkey('https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public
206-
https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public
207204
https://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public
208205
https://keys.datadoghq.com/DATADOG_RPM_KEY_B01082D3.public')\
209206
.with_baseurl('https://yum.datadoghq.com/stable/7/x86_64/')\
@@ -242,7 +239,6 @@
242239
.with_enabled(1)\
243240
.with_gpgcheck(1)\
244241
.with_gpgkey('https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public
245-
https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public
246242
https://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public
247243
https://keys.datadoghq.com/DATADOG_RPM_KEY_B01082D3.public')\
248244
.with_baseurl('https://yum.datadoghq.com/stable/7/x86_64/')\
@@ -279,7 +275,6 @@
279275
.with_enabled(1)\
280276
.with_gpgcheck(1)\
281277
.with_gpgkey('https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public
282-
https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public
283278
https://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public
284279
https://keys.datadoghq.com/DATADOG_RPM_KEY_B01082D3.public')\
285280
.with_baseurl('https://yum.datadoghq.com/stable/7/x86_64/')\
@@ -316,7 +311,6 @@
316311
.with_enabled(1)\
317312
.with_gpgcheck(1)\
318313
.with_gpgkey('https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public
319-
https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public
320314
https://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public
321315
https://keys.datadoghq.com/DATADOG_RPM_KEY_B01082D3.public')\
322316
.with_baseurl('https://yum.datadoghq.com/stable/7/x86_64/')\

spec/classes/datadog_agent_suse_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
.with_enabled(1)\
4747
.with_gpgcheck(1)\
4848
.with_gpgkey('https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public
49-
https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public
5049
https://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public
5150
https://keys.datadoghq.com/DATADOG_RPM_KEY_B01082D3.public')\
5251
.with_baseurl('https://yum.datadoghq.com/suse/stable/6/x86_64')
@@ -66,7 +65,6 @@
6665
.with_enabled(1)\
6766
.with_gpgcheck(1)\
6867
.with_gpgkey('https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public
69-
https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public
7068
https://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public
7169
https://keys.datadoghq.com/DATADOG_RPM_KEY_B01082D3.public')\
7270
.with_baseurl('https://yum.datadoghq.com/suse/stable/7/x86_64')

0 commit comments

Comments
 (0)