Use yumrepo from user as-is, default to our repo
This also allows us to have a single parameter for all agents, like we
do for apt.
MODIFY
README.md
README.md
@@ -85,8 +85,8 @@ Some attributes have changed their names from version 3.x to 4.x of this cookboo
| Change package_action | `'agent_package_action'` or `'agent6_package_action'` | `'agent_package_action'` for all versions |
| Change APT repo URL | `'aptrepo'` or `'agent6_aptrepo'` | `'aptrepo'` for all versions |
| Change APT repo dist | `'aptrepo_dist'` or `'agent6_aptrepo_dist'` | `'aptrepo_dist'` for all versions |
-| Change YUM repo | `'yumrepo'` or `'agent6_yumrepo'`.<br>Component and arch are part of the URL: `https://yum.datadoghq.com/stable/6/x86_64/` | `'yumrepo'` for Agent 6/7 or `'agent5_yumrepo'` for Agent 5.<br>Component and arch not part of the URL for Agent 6 and 7: `https://yum.datadoghq.com/stable/` |
-| Change SUSE repo | `'yumrepo_suse'` or `'agent6_yumrepo_suse'`.<br>Component and arch are part of the URL: `https://yum.datadoghq.com/suse/stable/6/x86_64/` | `'yumrepo_suse'` for Agent 6/7 or `'agent5_yumrepo_suse'` for Agent 5.<br>Component and arch not part of the URL for Agent 6 and 7: `https://yum.datadoghq.com/suse/stable/` |
+| Change YUM repo | `'yumrepo'` or `'agent6_yumrepo'` | `'yumrepo'` for all versions |
+| Change SUSE repo | `'yumrepo_suse'` or `'agent6_yumrepo_suse'` | `'yumrepo_suse'` for all versions |
## Example

MODIFY
attributes/default.rb
attributes/default.rb
@@ -110,29 +110,11 @@ default['datadog']['tags_submission_retries'] = nil
# you can set it as a key/value of this hash attribute. `nil` values will be ignored.
default['datadog']['handler_extra_config'] = {}
-# Repository configuration
-architecture_map = {
- 'i686' => 'i386',
- 'i386' => 'i386',
- 'x86' => 'i386'
-}
-architecture_map.default = 'x86_64'
-
-# Older versions of yum embed M2Crypto with SSL that doesn't support TLS1.2
-yum_protocol =
- if node['platform_family'] == 'rhel' && node['platform_version'].to_i < 6
- 'http'
- else
- 'https'
- end
-
# repos where datadog-agent packages are available
default['datadog']['aptrepo'] = 'http://apt.datadoghq.com'
default['datadog']['aptrepo_dist'] = 'stable'
-default['datadog']['yumrepo'] = 'https://yum.datadoghq.com/stable/' # MUST end in /
-default['datadog']['yumrepo_suse'] = 'https://yum.datadoghq.com/suse/stable/' # MUST end in /
-default['datadog']['agent5_yumrepo'] = "#{yum_protocol}://yum.datadoghq.com/rpm/#{architecture_map[node['kernel']['machine']]}/" # MUST end in /
-default['datadog']['agent5_yumrepo_suse'] = "https://yum.datadoghq.com/suse/rpm/#{architecture_map[node['kernel']['machine']]}/" # MUST end in /
+default['datadog']['yumrepo'] = nil # uses official repos by default
+default['datadog']['yumrepo_suse'] = nil # uses official repos by default
# NB: if you're not using the default repos and/or distributions, make sure
# to pin the version you're installing with node['datadog']['agent_version']

MODIFY
metadata.rb
metadata.rb
@@ -4,7 +4,7 @@ maintainer_email 'package@datadoghq.com'
license 'Apache-2.0'
description 'Installs/Configures datadog components'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
-version '3.99.3'
+version '3.99.4'
chef_version '>= 12.7'
source_url 'https://github.com/DataDog/chef-datadog'
issues_url 'https://github.com/DataDog/chef-datadog/issues'

MODIFY
recipes/repository.rb
recipes/repository.rb
# limitations under the License.
#
+# Repository configuration
+yum_a5_architecture_map = {
+ 'i686' => 'i386',
+ 'i386' => 'i386',
+ 'x86' => 'i386'
+}
+yum_a5_architecture_map.default = 'x86_64'
+
case node['platform_family']
when 'debian'
include_recipe 'apt'
@@ -79,14 +87,20 @@ when 'rhel', 'fedora', 'amazon'
end
end
+ if !node['datadog']['yumrepo'].nil?
+ baseurl = node['datadog']['yumrepo']
+ else
+ # Older versions of yum embed M2Crypto with SSL that doesn't support TLS1.2
+ yum_protocol_a5 = node['platform_family'] == 'rhel' ? 'http' : 'https'
case node['datadog']['agent_major_version'].to_i
when 6, 7
- baseurl = URI.join(node['datadog']['yumrepo'], "#{node['datadog']['agent_major_version']}/", "#{node['kernel']['machine']}/").to_s
+ baseurl = "https://yum.datadoghq.com/stable/#{node['datadog']['agent_major_version']}/#{node['kernel']['machine']}/"
when 5
- baseurl = node['datadog']['agent5_yumrepo']
+ baseurl = "#{yum_protocol_a5}://yum.datadoghq.com/rpm/#{yum_a5_architecture_map[node['kernel']['machine']]}/"
else
Chef::Log.error('agent_major_version not supported.')
end
+ end
# Add YUM repository
yum_repository 'datadog' do
@@ -134,14 +148,18 @@ when 'suse'
action :nothing
end
+ if !node['datadog']['yumrepo_suse'].nil?
+ baseurl = node['datadog']['yumrepo_suse']
+ else
case node['datadog']['agent_major_version'].to_i
when 6, 7
- baseurl = URI.join(node['datadog']['yumrepo_suse'], "#{node['datadog']['agent_major_version']}/", "#{node['kernel']['machine']}/").to_s
+ baseurl = "https://yum.datadoghq.com/suse/stable/#{node['datadog']['agent_major_version']}/#{node['kernel']['machine']}/"
when 5
- baseurl = node['datadog']['agent5_yumrepo_suse']
+ baseurl = "https://yum.datadoghq.com/suse/rpm/#{yum_a5_architecture_map[node['kernel']['machine']]}/"
else
Chef::Log.error('agent_major_version not supported.')
end
+ end
# Add YUM repository
zypper_repository 'datadog' do

Use yumrepo from user as-is, default to our repo

This also allows us to have a single parameter for all agents, like we
do for apt.