Skip to content

Commit

Permalink
Centos 6 deprecation and relevant GPG keys installation (#806)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pythyu authored Apr 29, 2024
1 parent d60332f commit 3985da9
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 19 deletions.
23 changes: 19 additions & 4 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -376,12 +376,27 @@
if $agent_major_version != undef and $agent_major_version != $_agent_major_version {
fail('Provided and deduced agent_major_version don\'t match')
}
$_agent_minor_version = 0 + $3
} elsif $agent_major_version != undef {
$_agent_major_version = $agent_major_version
} else {
$_agent_major_version = $datadog_agent::params::default_agent_major_version
}

case $facts['os']['name'] {
'RedHat', 'CentOS', 'OracleLinux': {
if $facts['os']['release']['full'] =~ /^6(.[0-9])?/ and $agent_version == 'latest' {
notice("datadog-agent ${_agent_major_version}.51 is the last supported version on CentOS 6. Installing ${_agent_major_version}.51 now")
$agent_full_version='7.51.1'
} elsif $facts['os']['release']['full'] =~ /^6(.[0-9])?/ and $_agent_minor_version != undef and $_agent_minor_version > 51 {
fail("datadog-agent ${_agent_major_version}.51 is the last supported version on CentOS 6.")
} else {
$agent_full_version = $agent_version
}
}
default: { $agent_full_version = $agent_version }
}

if $_agent_major_version != 5 and $_agent_major_version != 6 and $_agent_major_version != 7 {
fail("agent_major_version must be either 5, 6 or 7, not ${_agent_major_version}")
}
Expand Down Expand Up @@ -438,7 +453,7 @@
}
class { 'datadog_agent::ubuntu':
agent_major_version => $_agent_major_version,
agent_version => $agent_version,
agent_version => $agent_full_version,
agent_flavor => $agent_flavor,
agent_repo_uri => $agent_repo_uri,
release => $apt_release,
Expand All @@ -451,15 +466,15 @@
agent_flavor => $agent_flavor,
agent_repo_uri => $agent_repo_uri,
manage_repo => $manage_repo,
agent_version => $agent_version,
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_version,
agent_version => $agent_full_version,
msi_location => $win_msi_location,
api_key => $api_key,
hostname => $host,
Expand All @@ -478,7 +493,7 @@
agent_major_version => $_agent_major_version,
agent_flavor => $agent_flavor,
agent_repo_uri => $agent_repo_uri,
agent_version => $agent_version,
agent_version => $agent_full_version,
rpm_repo_gpgcheck => $rpm_repo_gpgcheck,
}
}
Expand Down
14 changes: 12 additions & 2 deletions manifests/redhat.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,22 @@

if $manage_repo {

$keys = [
$all_keys = [
'https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public',
'https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public',
'https://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public',
'https://keys.datadoghq.com/DATADOG_RPM_KEY_B01082D3.public',
'https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public',
]
#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 > 5 and ($agent_version == 'latest' or 0 + $3 > 35) {
$keys = $all_keys[0,3]
} else {
$keys = $all_keys
}
} else {
$keys = $all_keys
}

if ($rpm_repo_gpgcheck != undef) {
$repo_gpgcheck = $rpm_repo_gpgcheck
Expand Down
16 changes: 13 additions & 3 deletions manifests/suse.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,20 @@
$current_key = 'https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public'
$all_keys = [
$current_key,
'https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public',
'https://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public',
'https://keys.datadoghq.com/DATADOG_RPM_KEY_B01082D3.public',
'https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public',
]
#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 > 5 and ($agent_version == 'latest' or 0 + $3 > 35) {
$keys_to_use = $all_keys[0,3]
} else {
$keys_to_use = $all_keys
}
} else {
$keys_to_use = $all_keys
}

if ($rpm_repo_gpgcheck != undef) {
$repo_gpgcheck = $rpm_repo_gpgcheck
Expand All @@ -32,8 +42,8 @@

case $agent_major_version {
5 : { fail('Agent v5 package not available in SUSE') }
6 : { $gpgkeys = $all_keys }
7 : { $gpgkeys = $all_keys }
6 : { $gpgkeys = $keys_to_use }
7 : { $gpgkeys = $keys_to_use }
default: { fail('invalid agent_major_version') }
}

Expand Down
10 changes: 2 additions & 8 deletions spec/classes/datadog_agent_redhat_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
.with_enabled(1)\
.with_gpgcheck(1)\
.with_gpgkey('https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public
https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public
https://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public
https://keys.datadoghq.com/DATADOG_RPM_KEY_B01082D3.public')\
https://keys.datadoghq.com/DATADOG_RPM_KEY_B01082D3.public
https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public')\
.with_baseurl('https://yum.datadoghq.com/rpm/x86_64/')\
.with_repo_gpgcheck(false)
end
Expand Down Expand Up @@ -89,7 +89,6 @@
.with_enabled(1)\
.with_gpgcheck(1)\
.with_gpgkey('https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public
https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public
https://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public
https://keys.datadoghq.com/DATADOG_RPM_KEY_B01082D3.public')\
.with_baseurl('https://yum.datadoghq.com/stable/6/x86_64/')\
Expand Down Expand Up @@ -145,7 +144,6 @@
.with_enabled(1)\
.with_gpgcheck(1)\
.with_gpgkey('https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public
https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public
https://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public
https://keys.datadoghq.com/DATADOG_RPM_KEY_B01082D3.public')\
.with_baseurl('https://yum.datadoghq.com/stable/7/x86_64/')\
Expand Down Expand Up @@ -203,7 +201,6 @@
.with_enabled(1)\
.with_gpgcheck(1)\
.with_gpgkey('https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public
https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public
https://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public
https://keys.datadoghq.com/DATADOG_RPM_KEY_B01082D3.public')\
.with_baseurl('https://yum.datadoghq.com/stable/7/x86_64/')\
Expand Down Expand Up @@ -242,7 +239,6 @@
.with_enabled(1)\
.with_gpgcheck(1)\
.with_gpgkey('https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public
https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public
https://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public
https://keys.datadoghq.com/DATADOG_RPM_KEY_B01082D3.public')\
.with_baseurl('https://yum.datadoghq.com/stable/7/x86_64/')\
Expand Down Expand Up @@ -279,7 +275,6 @@
.with_enabled(1)\
.with_gpgcheck(1)\
.with_gpgkey('https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public
https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public
https://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public
https://keys.datadoghq.com/DATADOG_RPM_KEY_B01082D3.public')\
.with_baseurl('https://yum.datadoghq.com/stable/7/x86_64/')\
Expand Down Expand Up @@ -316,7 +311,6 @@
.with_enabled(1)\
.with_gpgcheck(1)\
.with_gpgkey('https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public
https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public
https://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public
https://keys.datadoghq.com/DATADOG_RPM_KEY_B01082D3.public')\
.with_baseurl('https://yum.datadoghq.com/stable/7/x86_64/')\
Expand Down
2 changes: 0 additions & 2 deletions spec/classes/datadog_agent_suse_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
.with_enabled(1)\
.with_gpgcheck(1)\
.with_gpgkey('https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public
https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public
https://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public
https://keys.datadoghq.com/DATADOG_RPM_KEY_B01082D3.public')\
.with_baseurl('https://yum.datadoghq.com/suse/stable/6/x86_64')
Expand All @@ -66,7 +65,6 @@
.with_enabled(1)\
.with_gpgcheck(1)\
.with_gpgkey('https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public
https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public
https://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public
https://keys.datadoghq.com/DATADOG_RPM_KEY_B01082D3.public')\
.with_baseurl('https://yum.datadoghq.com/suse/stable/7/x86_64')
Expand Down

0 comments on commit 3985da9

Please sign in to comment.