From 7b75cc7be14b1c242cbb581d5ea90811b175ed9e Mon Sep 17 00:00:00 2001 From: Kylian Serrania Date: Fri, 19 Aug 2022 10:41:13 +0200 Subject: [PATCH] Specify release but not epoch for RPM packages on Chef < 14 (#858) In #856, we reverted the logic introduced in #839 when Chef < 14 is used, as the yum logic in Chef < 14 doesn't support the use of epochs. However, before #839, the release was added in all cases to the package version. In #856 we forgot to restore that, which this PR does. --- libraries/recipe_helpers.rb | 8 ++++++-- spec/dd-agent_spec.rb | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/libraries/recipe_helpers.rb b/libraries/recipe_helpers.rb index 4f2afcd5..e1933700 100644 --- a/libraries/recipe_helpers.rb +++ b/libraries/recipe_helpers.rb @@ -22,11 +22,15 @@ def agent_version(node) dd_agent_version = dd_agent_version[platform_family] end if !dd_agent_version.nil? && dd_agent_version.match(/^[0-9]+\.[0-9]+\.[0-9]+((?:~|-)[^0-9\s-]+[^-\s]*)?$/) - # For RHEL-based distros, we can only add epoch and release when running Chef >= 14, as Chef < 14 - # has different yum logic that doesn't know how to work with epoch and/or release + # For RHEL-based distros: + # - we can only add epoch and release when running Chef >= 14, as Chef < 14 + # has different yum logic that doesn't know how to work with epoch and release + # - for Chef < 14, we only add release if %w[debian suse].include?(node['platform_family']) || (%w[amazon fedora rhel].include?(node['platform_family']) && chef_version_ge?(14)) dd_agent_version = '1:' + dd_agent_version + '-1' + elsif %w[amazon fedora rhel].include?(node['platform_family']) + dd_agent_version += '-1' end end dd_agent_version diff --git a/spec/dd-agent_spec.rb b/spec/dd-agent_spec.rb index cc5bde17..07b11e51 100644 --- a/spec/dd-agent_spec.rb +++ b/spec/dd-agent_spec.rb @@ -1449,7 +1449,7 @@ def set_env_var(name, value) if Chef::Datadog.chef_version_ge? 14 expect(chef_run).to install_dnf_package('datadog-agent').with_version('1:6.16.0-1') else - expect(chef_run).to install_dnf_package('datadog-agent').with_version('6.16.0') + expect(chef_run).to install_dnf_package('datadog-agent').with_version('6.16.0-1') end end end