Skip to content

Commit e710ae6

Browse files
authored
[ubuntu] removing unnecessary key management (DataDog#507)
1 parent 5beae76 commit e710ae6

4 files changed

Lines changed: 20 additions & 34 deletions

File tree

manifests/ubuntu/agent5.pp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@
2626
) inherits datadog_agent::params{
2727

2828
if !$skip_apt_key_trusting {
29-
::datadog_agent::ubuntu::install_key { [$apt_key]:
30-
server => $apt_keyserver,
31-
before => Apt::Source['datadog'],
29+
$key = {
30+
'id' => $apt_key,
31+
'server' => $apt_keyserver,
3232
}
33+
} else {
34+
$key = {}
3335
}
3436

3537
# This is a hack - I'm not happy about it, but we should rarely
@@ -66,6 +68,7 @@
6668
release => $release,
6769
repos => $repos,
6870
require => Class['apt'],
71+
key => $key,
6972
notify => Exec['datadog_apt-get_remove_agent6'],
7073
}
7174

@@ -77,7 +80,7 @@
7780
package { $datadog_agent::params::package_name:
7881
ensure => $agent_version,
7982
require => [Apt::Source['datadog'],
80-
Exec['apt_update']],
83+
Class['apt::update']],
8184
}
8285

8386
if $service_provider {

manifests/ubuntu/agent6.pp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@
1717
) inherits datadog_agent::params {
1818

1919
if !$skip_apt_key_trusting {
20-
::datadog_agent::ubuntu::install_key { [$apt_key]:
21-
server => $apt_keyserver,
22-
before => Apt::Source['datadog6'],
20+
$key = {
21+
'id' => $apt_key,
22+
'server' => $apt_keyserver,
2323
}
24+
} else {
25+
$key = {}
2426
}
2527

2628
apt::source { 'datadog':
@@ -33,6 +35,7 @@
3335
release => $release,
3436
repos => $repos,
3537
require => Class['apt'],
38+
key => $key,
3639
}
3740

3841
package { 'datadog-agent-base':
@@ -43,7 +46,7 @@
4346
package { $datadog_agent::params::package_name:
4447
ensure => $agent_version,
4548
require => [Apt::Source['datadog6'],
46-
Exec['apt_update']],
49+
Class['apt::update']],
4750
}
4851

4952
if $service_provider {

manifests/ubuntu/install_key.pp

Lines changed: 0 additions & 20 deletions
This file was deleted.

spec/classes/datadog_agent_ubuntu_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,20 @@
1616
end
1717

1818
# it should install the mirror
19-
it { should_not contain_datadog_agent__ubuntu__install_key('935F5A436A5A6E8788F0765B226AE980C7A7DA52') }
19+
it { should_not contain_apt__key('Add key: 935F5A436A5A6E8788F0765B226AE980C7A7DA52 from Apt::Source datadog') }
2020
it do
21-
should contain_datadog_agent__ubuntu__install_key('A2923DFF56EDA6E76E55E492D3A80E30382E94DE')\
21+
should contain_apt__key('Add key: A2923DFF56EDA6E76E55E492D3A80E30382E94DE from Apt::Source datadog')
2222
end
2323
context 'overriding keyserver' do
2424
let(:params) {{
2525
apt_keyserver: 'hkp://pool.sks-keyservers.net:80',
2626
}}
2727
it do
28-
should contain_datadog_agent__ubuntu__install_key('A2923DFF56EDA6E76E55E492D3A80E30382E94DE')\
28+
should contain_apt__key('Add key: A2923DFF56EDA6E76E55E492D3A80E30382E94DE from Apt::Source datadog')\
2929
.with_server('hkp://pool.sks-keyservers.net:80')
3030
end
3131
end
32-
32+
3333
it do
3434
should contain_file('/etc/apt/sources.list.d/datadog.list')\
3535
.that_notifies('exec[apt_update]')
@@ -87,8 +87,8 @@
8787
end
8888

8989
# it should install the mirror
90-
it { should_not contain_datadog_agent__ubuntu__install_key('935F5A436A5A6E8788F0765B226AE980C7A7DA52') }
91-
it { should contain_datadog_agent__ubuntu__install_key('A2923DFF56EDA6E76E55E492D3A80E30382E94DE') }
90+
it { should_not contain_apt__key('Add key: 935F5A436A5A6E8788F0765B226AE980C7A7DA52 from Apt::Source datadog6') }
91+
it { should contain_apt__key('Add key: A2923DFF56EDA6E76E55E492D3A80E30382E94DE from Apt::Source datadog6') }
9292

9393
it do
9494
should contain_file('/etc/apt/sources.list.d/datadog6.list')\

0 commit comments

Comments
 (0)