Skip to content

Commit

Permalink
Update recipes to support amazonlinux 2023 installation (#896)
Browse files Browse the repository at this point in the history
* Update recipes to support amazonlinux 2023 installation

* Move tweak for amazonlinux on recipe_helpers
  • Loading branch information
chouetz authored Jul 4, 2023
1 parent f8f9f9d commit 1657210
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
7 changes: 7 additions & 0 deletions libraries/recipe_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ def cookbook_version(run_context)
run_context.cookbook_collection['datadog'].version
end

def systemd_platform?(node)
(node['platform'] == 'amazon' || node['platform_family'] == 'amazon') && node['platform_version'].to_i >= 2022
end

def upstart_platform?(node)
agent_major_version(node) > 5 &&
(((node['platform'] == 'amazon' || node['platform_family'] == 'amazon') && node['platform_version'].to_i != 2) ||
Expand All @@ -146,6 +150,9 @@ def service_provider(node)
service_provider = Chef::Provider::Service.const_get(specified_provider)
end
service_provider
# Specific catch for Amazon Linux >= 2022 where Upstart doesn't work
elsif systemd_platform?(node)
Chef::Provider::Service::Systemd
elsif upstart_platform?(node)
Chef::Provider::Service::Upstart
end
Expand Down
7 changes: 4 additions & 3 deletions recipes/_install-linux.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@
action :upgrade
end
when 'rhel', 'fedora', 'amazon'
if platform_family?('rhel') && node['platform_version'].to_i >= 8 && !platform?('amazon') ||
platform_family?('fedora') && node['platform_version'].to_i >= 28
# yum_package doesn't work on RHEL 8 and Fedora >= 28
if (platform_family?('rhel') && node['platform_version'].to_i >= 8) ||
(platform_family?('fedora') && node['platform_version'].to_i >= 28) ||
(platform_family?('amazon') && node['platform_version'].to_i >= 2022)
# yum_package doesn't work on RHEL >= 8, Fedora >= 28 and AmazonLinux >=2022
# dnf_package only works on RHEL 8 / Fedora >= 28 if Chef 15+ is used
dnf_package dd_agent_flavor do
version dd_agent_version
Expand Down
16 changes: 6 additions & 10 deletions recipes/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,16 +174,12 @@ def warn_deprecated_yumrepo_gpgkey
end

# Previous versions of the cookbook could create these repo files, make sure we remove it now
apt_repository 'datadog-beta' do
action :remove
end

apt_repository 'datadog_apt_D75CEA17048B9ACBF186794B32637D44F14F620E' do
action :remove
end

apt_repository 'datadog_apt_A2923DFF56EDA6E76E55E492D3A80E30382E94DE' do
action :remove
['datadog-beta',
'datadog_apt_D75CEA17048B9ACBF186794B32637D44F14F620E',
'datadog_apt_A2923DFF56EDA6E76E55E492D3A80E30382E94DE'].each do |repo|
apt_repository repo do
action :remove
end
end

when 'rhel', 'fedora', 'amazon'
Expand Down

0 comments on commit 1657210

Please sign in to comment.