Skip to content

Commit 3559eb5

Browse files
authored
Release 4.7.2 (#757)
- Undo revert of #754, seems to be working fine. - Update metadata and changelog.
1 parent 063c29e commit 3559eb5

File tree

11 files changed

+219
-64
lines changed

11 files changed

+219
-64
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
Changes
22
=======
33

4+
# 4.7.2 / 2020-11-25
5+
* [FEATURE] Trust new signing key [#754][] [@mikezhu-dd][]
6+
47
# 4.7.1 / 2020-11-25
58
* [BUGFIX] Revert [#754][]
69

attributes/default.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,10 @@
167167
# Only applies if specific version specified
168168
default['datadog']['windows_agent_installer_prefix'] = nil
169169

170-
# Location of additional rpm gpgkey to import (with signature `e09422b3`). In the future the rpm packages
170+
# Location of additional rpm gpg keys to import. In the future the rpm packages
171171
# of the Agent will be signed with this key.
172-
default['datadog']['yumrepo_gpgkey_new'] = "#{yum_protocol}://yum.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public"
172+
default['datadog']['yumrepo_gpgkey_new_e09422b3'] = "#{yum_protocol}://yum.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public"
173+
default['datadog']['yumrepo_gpgkey_new_fd4bf915'] = "#{yum_protocol}://yum.datadoghq.com/DATADOG_RPM_KEY_20200908.public"
173174

174175
# Windows Agent Blacklist
175176
# Attribute to enforce silent failures on agent installs when attempting to install a

metadata.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
maintainer_email '[email protected]'
44
license 'Apache-2.0'
55
description 'Installs/Configures datadog components'
6-
version '4.7.1'
6+
version '4.7.2'
77
chef_version '>= 12.7'
88
source_url 'https://github.com/DataDog/chef-datadog'
99
issues_url 'https://github.com/DataDog/chef-datadog/issues'

recipes/repository.rb

+65-27
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,22 @@
2626

2727
agent_major_version = Chef::Datadog.agent_major_version(node)
2828

29+
# A2923DFF56EDA6E76E55E492D3A80E30382E94DE expires in 2022
30+
# D75CEA17048B9ACBF186794B32637D44F14F620E expires in 2032
31+
apt_gpg_keys = ['A2923DFF56EDA6E76E55E492D3A80E30382E94DE', 'D75CEA17048B9ACBF186794B32637D44F14F620E']
32+
33+
# DATADOG_RPM_KEY_E09422B3.public expires in 2022
34+
# DATADOG_RPM_KEY_20200908.public expires in 2024
35+
rpm_gpg_keys = [['DATADOG_RPM_KEY_E09422B3.public', 'e09422b3', 'A4C0 B90D 7443 CF6E 4E8A A341 F106 8E14 E094 22B3'],
36+
['DATADOG_RPM_KEY_20200908.public', 'fd4bf915', 'C655 9B69 0CA8 82F0 23BD F3F6 3F4D 1729 FD4B F915']]
37+
38+
# Local file name of the key
39+
rpm_gpg_keys_name = 0
40+
# Short fingerprint for rpm commands, used in "rpm -q gpg-pubkey-*" and node['datadog']["yumrepo_gpgkey_new_*"]
41+
rpm_gpg_keys_short_fingerprint = 1
42+
# Space delimited full fingerprint
43+
rpm_gpg_keys_full_fingerprint = 2
44+
2945
case node['platform_family']
3046
when 'debian'
3147
apt_update 'update'
@@ -48,15 +64,17 @@
4864

4965
retries = node['datadog']['aptrepo_retries']
5066
keyserver = node['datadog']['aptrepo_use_backup_keyserver'] ? node['datadog']['aptrepo_backup_keyserver'] : node['datadog']['aptrepo_keyserver']
51-
# Add APT repository
52-
apt_repository 'datadog' do
53-
keyserver keyserver
54-
key 'A2923DFF56EDA6E76E55E492D3A80E30382E94DE'
55-
uri node['datadog']['aptrepo']
56-
distribution node['datadog']['aptrepo_dist']
57-
components components
58-
action :add
59-
retries retries
67+
# Add APT repositories
68+
apt_gpg_keys.each do |apt_gpg_key|
69+
apt_repository "datadog_apt_#{apt_gpg_key}" do
70+
keyserver keyserver
71+
key apt_gpg_key
72+
uri node['datadog']['aptrepo']
73+
distribution node['datadog']['aptrepo_dist']
74+
components components
75+
action :add
76+
retries retries
77+
end
6078
end
6179

6280
# Previous versions of the cookbook could create this repo file, make sure we remove it now
@@ -65,26 +83,31 @@
6583
end
6684
when 'rhel', 'fedora', 'amazon'
6785
# Import new RPM key
68-
if node['datadog']['yumrepo_gpgkey_new']
86+
rpm_gpg_keys.each do |rpm_gpg_key|
87+
next unless node['datadog']["yumrepo_gpgkey_new_#{rpm_gpg_key[rpm_gpg_keys_short_fingerprint]}"]
88+
6989
# gnupg is required to check the downloaded key's fingerprint
7090
package 'gnupg' do
7191
action :install
7292
only_if { node['packages']['gnupg2'].nil? }
7393
end
7494

7595
# Download new RPM key
76-
key_local_path = ::File.join(Chef::Config[:file_cache_path], 'DATADOG_RPM_KEY_E09422B3.public')
77-
remote_file 'DATADOG_RPM_KEY_E09422B3.public' do
96+
key_local_path = ::File.join(Chef::Config[:file_cache_path], rpm_gpg_key[rpm_gpg_keys_name])
97+
remote_file "remote_file_#{rpm_gpg_key[rpm_gpg_keys_name]}" do
7898
path key_local_path
79-
source node['datadog']['yumrepo_gpgkey_new']
80-
not_if 'rpm -q gpg-pubkey-e09422b3' # (key already imported)
81-
notifies :run, 'execute[rpm-import datadog key e09422b3]', :immediately
99+
source node['datadog']["yumrepo_gpgkey_new_#{rpm_gpg_key[rpm_gpg_keys_short_fingerprint]}"]
100+
not_if "rpm -q gpg-pubkey-#{rpm_gpg_key[rpm_gpg_keys_short_fingerprint]}" # (key already imported)
101+
notifies :run, "execute[rpm-import datadog key #{rpm_gpg_key[rpm_gpg_keys_short_fingerprint]}]", :immediately
82102
end
83103

104+
# The fingerprint string has spaces in it, calculate one without space here
105+
gpg_key_fingerprint_without_space = rpm_gpg_key[rpm_gpg_keys_full_fingerprint].delete(' ')
106+
84107
# Import key if fingerprint matches
85-
execute 'rpm-import datadog key e09422b3' do
108+
execute "rpm-import datadog key #{rpm_gpg_key[rpm_gpg_keys_short_fingerprint]}" do
86109
command "rpm --import #{key_local_path}"
87-
only_if "gpg --dry-run --quiet --with-fingerprint #{key_local_path} | grep 'A4C0 B90D 7443 CF6E 4E8A A341 F106 8E14 E094 22B3' || gpg --dry-run --import --import-options import-show #{key_local_path} | grep 'A4C0B90D7443CF6E4E8AA341F1068E14E09422B3'"
110+
only_if "gpg --dry-run --quiet --with-fingerprint #{key_local_path} | grep '#{rpm_gpg_key[rpm_gpg_keys_full_fingerprint]}' || gpg --dry-run --import --import-options import-show #{key_local_path} | grep '#{gpg_key_fingerprint_without_space}'"
88111
action :nothing
89112
end
90113
end
@@ -105,36 +128,51 @@
105128
end
106129

107130
# Add YUM repository
131+
yumrepo_gpgkeys = []
132+
if agent_major_version < 7
133+
yumrepo_gpgkeys.push(node['datadog']['yumrepo_gpgkey'])
134+
else
135+
rpm_gpg_keys.each do |rpm_gpg_key|
136+
yumrepo_gpgkeys.push(node['datadog']["yumrepo_gpgkey_new_#{rpm_gpg_key[rpm_gpg_keys_short_fingerprint]}"])
137+
end
138+
end
139+
108140
yum_repository 'datadog' do
109141
description 'datadog'
110142
baseurl baseurl
111143
proxy node['datadog']['yumrepo_proxy']
112144
proxy_username node['datadog']['yumrepo_proxy_username']
113145
proxy_password node['datadog']['yumrepo_proxy_password']
114-
gpgkey agent_major_version < 7 ? node['datadog']['yumrepo_gpgkey'] : node['datadog']['yumrepo_gpgkey_new']
146+
gpgkey yumrepo_gpgkeys
115147
gpgcheck true
116148
action :create
117149
end
118150
when 'suse'
119151
# Import new RPM key
120-
if node['datadog']['yumrepo_gpgkey_new']
152+
rpm_gpg_keys.each do |rpm_gpg_key|
153+
next unless node['datadog']["yumrepo_gpgkey_new_#{rpm_gpg_key[rpm_gpg_keys_short_fingerprint]}"]
154+
121155
# Download new RPM key
122-
new_key_local_path = ::File.join(Chef::Config[:file_cache_path], 'DATADOG_RPM_KEY_E09422B3.public')
123-
remote_file 'DATADOG_RPM_KEY_E09422B3.public' do
156+
new_key_local_path = ::File.join(Chef::Config[:file_cache_path], rpm_gpg_key[rpm_gpg_keys_name])
157+
remote_file "remote_file_#{rpm_gpg_key[rpm_gpg_keys_name]}" do
124158
path new_key_local_path
125-
source node['datadog']['yumrepo_gpgkey_new']
126-
not_if 'rpm -q gpg-pubkey-e09422b3' # (key already imported)
127-
notifies :run, 'execute[rpm-import datadog key e09422b3]', :immediately
159+
source node['datadog']["yumrepo_gpgkey_new_#{rpm_gpg_key[rpm_gpg_keys_short_fingerprint]}"]
160+
not_if "rpm -q gpg-pubkey-#{rpm_gpg_key[rpm_gpg_keys_short_fingerprint]}" # (key already imported)
161+
notifies :run, "execute[rpm-import datadog key #{rpm_gpg_key[rpm_gpg_keys_short_fingerprint]}]", :immediately
128162
end
129163

164+
# The fingerprint string has spaces in it, calculate one without space here
165+
gpg_key_fingerprint_without_space = rpm_gpg_key[rpm_gpg_keys_full_fingerprint].delete(' ')
166+
130167
# Import key if fingerprint matches
131-
execute 'rpm-import datadog key e09422b3' do
168+
execute "rpm-import datadog key #{rpm_gpg_key[rpm_gpg_keys_short_fingerprint]}" do
132169
command "rpm --import #{new_key_local_path}"
133-
only_if "gpg --dry-run --quiet --with-fingerprint #{new_key_local_path} | grep 'A4C0 B90D 7443 CF6E 4E8A A341 F106 8E14 E094 22B3' || gpg --dry-run --import --import-options import-show #{new_key_local_path} | grep 'A4C0B90D7443CF6E4E8AA341F1068E14E09422B3'"
170+
only_if "gpg --dry-run --quiet --with-fingerprint #{new_key_local_path} | grep '#{rpm_gpg_key[rpm_gpg_keys_full_fingerprint]}' || gpg --dry-run --import --import-options import-show #{new_key_local_path} | grep '#{gpg_key_fingerprint_without_space}'"
134171
action :nothing
135172
end
136173
end
137174

175+
# Now the old key is mostly hard-coded
138176
old_key_local_path = ::File.join(Chef::Config[:file_cache_path], 'DATADOG_RPM_KEY.public')
139177
remote_file 'DATADOG_RPM_KEY.public' do
140178
path old_key_local_path
@@ -167,7 +205,7 @@
167205
zypper_repository 'datadog' do
168206
description 'datadog'
169207
baseurl baseurl
170-
gpgkey agent_major_version < 7 ? node['datadog']['yumrepo_gpgkey'] : node['datadog']['yumrepo_gpgkey_new']
208+
gpgkey agent_major_version < 7 ? node['datadog']['yumrepo_gpgkey'] : node['datadog']["yumrepo_gpgkey_new_#{rpm_gpg_keys[0][rpm_gpg_keys_short_fingerprint]}"]
171209
gpgautoimportkeys false
172210
gpgcheck false
173211
action :create

0 commit comments

Comments
 (0)