Skip to content

Commit 1a362c5

Browse files
authored
Revert "Avoid potential dependency cycles when used with other modules (DataDog#463)" (DataDog#506)
This reverts commit 8a29860.
1 parent 027bfcf commit 1a362c5

4 files changed

Lines changed: 41 additions & 30 deletions

File tree

manifests/ubuntu/agent5.pp

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,13 @@
2525
Optional[String] $apt_keyserver = undef,
2626
) inherits datadog_agent::params{
2727

28-
exec { 'apt-transport-https':
29-
command => '/usr/bin/apt-get install -y -q apt-transport-https'
30-
}
28+
ensure_packages(['apt-transport-https'])
3129

3230
if !$skip_apt_key_trusting {
33-
$key = {
34-
'id' => $apt_key,
35-
'server' => $apt_keyserver
31+
::datadog_agent::ubuntu::install_key { [$apt_key]:
32+
server => $apt_keyserver,
33+
before => Apt::Source['datadog'],
3634
}
37-
} else {
38-
$key = {}
3935
}
4036

4137
# This is a hack - I'm not happy about it, but we should rarely
@@ -71,9 +67,8 @@
7167
location => $location,
7268
release => $release,
7369
repos => $repos,
74-
key => $key,
75-
require => Exec['apt-transport-https'],
76-
notify => Exec['datadog_apt-get_remove_agent6'],
70+
require => Package['apt-transport-https'],
71+
notify => [Exec['datadog_apt-get_remove_agent6'],Exec['apt_update']],
7772
}
7873

7974
package { 'datadog-agent-base':
@@ -84,7 +79,7 @@
8479
package { $datadog_agent::params::package_name:
8580
ensure => $agent_version,
8681
require => [Apt::Source['datadog'],
87-
Class['apt::update']],
82+
Exec['apt_update']],
8883
}
8984

9085
if $service_provider {

manifests/ubuntu/agent6.pp

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,12 @@
1616
Optional[String] $apt_keyserver = undef,
1717
) inherits datadog_agent::params {
1818

19-
exec { 'apt-transport-https':
20-
command => '/usr/bin/apt-get install -y -q apt-transport-https'
21-
}
22-
19+
ensure_packages(['apt-transport-https'])
2320
if !$skip_apt_key_trusting {
24-
$key = {
25-
'id' => $apt_key,
26-
'server' => $apt_keyserver
21+
::datadog_agent::ubuntu::install_key { [$apt_key]:
22+
server => $apt_keyserver,
23+
before => Apt::Source['datadog6'],
2724
}
28-
} else {
29-
$key = {}
3025
}
3126

3227
apt::source { 'datadog':
@@ -38,8 +33,8 @@
3833
location => $location,
3934
release => $release,
4035
repos => $repos,
41-
key => $key,
42-
require => Exec['apt-transport-https'],
36+
require => Package['apt-transport-https'],
37+
notify => Exec['apt_update'],
4338
}
4439

4540
package { 'datadog-agent-base':
@@ -50,7 +45,7 @@
5045
package { $datadog_agent::params::package_name:
5146
ensure => $agent_version,
5247
require => [Apt::Source['datadog6'],
53-
Class['apt::update']],
48+
Exec['apt_update']],
5449
}
5550

5651
if $service_provider {

manifests/ubuntu/install_key.pp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Resource type: datadog_agent::ubuntu::install_key
2+
#
3+
# This resource type install repository keys in Ubuntu
4+
#
5+
# Parameters:
6+
#
7+
# Actions:
8+
#
9+
# Requires:
10+
#
11+
# Sample Usage:
12+
#
13+
#
14+
#
15+
define datadog_agent::ubuntu::install_key($server) {
16+
apt::key { $name:
17+
id => $name,
18+
server => $server,
19+
}
20+
}

spec/classes/datadog_agent_ubuntu_spec.rb

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

1818
# it should install the mirror
19-
it { should_not contain_apt__key('Add key: 935F5A436A5A6E8788F0765B226AE980C7A7DA52 from Apt::Source datadog') }
19+
it { should_not contain_datadog_agent__ubuntu__install_key('935F5A436A5A6E8788F0765B226AE980C7A7DA52') }
2020
it do
21-
should contain_apt__key('Add key: A2923DFF56EDA6E76E55E492D3A80E30382E94DE from Apt::Source datadog')
21+
should contain_datadog_agent__ubuntu__install_key('A2923DFF56EDA6E76E55E492D3A80E30382E94DE')\
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_apt__key('Add key: A2923DFF56EDA6E76E55E492D3A80E30382E94DE from Apt::Source datadog')\
28+
should contain_datadog_agent__ubuntu__install_key('A2923DFF56EDA6E76E55E492D3A80E30382E94DE')\
2929
.with_server('hkp://pool.sks-keyservers.net:80')
3030
end
3131
end
@@ -38,7 +38,7 @@
3838

3939
# it should install the packages
4040
it do
41-
should contain_exec('apt-transport-https')\
41+
should contain_package('apt-transport-https')\
4242
.that_comes_before('file[/etc/apt/sources.list.d/datadog.list]')
4343
end
4444
it do
@@ -91,7 +91,8 @@
9191
end
9292

9393
# it should install the mirror
94-
it { should contain_apt__key('Add key: A2923DFF56EDA6E76E55E492D3A80E30382E94DE from Apt::Source datadog6') }
94+
it { should_not contain_datadog_agent__ubuntu__install_key('935F5A436A5A6E8788F0765B226AE980C7A7DA52') }
95+
it { should contain_datadog_agent__ubuntu__install_key('A2923DFF56EDA6E76E55E492D3A80E30382E94DE') }
9596

9697
it do
9798
should contain_file('/etc/apt/sources.list.d/datadog6.list')\
@@ -101,7 +102,7 @@
101102

102103
# it should install the packages
103104
it do
104-
should contain_exec('apt-transport-https')\
105+
should contain_package('apt-transport-https')\
105106
.that_comes_before('file[/etc/apt/sources.list.d/datadog6.list]')
106107
end
107108
it do

0 commit comments

Comments
 (0)