Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions manifests/ubuntu/agent5.pp
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,13 @@
Optional[String] $apt_keyserver = undef,
) inherits datadog_agent::params{

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

if !$skip_apt_key_trusting {
$key = {
'id' => $apt_key,
'server' => $apt_keyserver
::datadog_agent::ubuntu::install_key { [$apt_key]:
server => $apt_keyserver,
before => Apt::Source['datadog'],
}
} else {
$key = {}
}

# This is a hack - I'm not happy about it, but we should rarely
Expand Down Expand Up @@ -71,9 +67,8 @@
location => $location,
release => $release,
repos => $repos,
key => $key,
require => Exec['apt-transport-https'],
notify => Exec['datadog_apt-get_remove_agent6'],
require => Package['apt-transport-https'],
notify => [Exec['datadog_apt-get_remove_agent6'],Exec['apt_update']],
}

package { 'datadog-agent-base':
Expand All @@ -84,7 +79,7 @@
package { $datadog_agent::params::package_name:
ensure => $agent_version,
require => [Apt::Source['datadog'],
Class['apt::update']],
Exec['apt_update']],
}

if $service_provider {
Expand Down
19 changes: 7 additions & 12 deletions manifests/ubuntu/agent6.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,12 @@
Optional[String] $apt_keyserver = undef,
) inherits datadog_agent::params {

exec { 'apt-transport-https':
command => '/usr/bin/apt-get install -y -q apt-transport-https'
}

ensure_packages(['apt-transport-https'])
if !$skip_apt_key_trusting {
$key = {
'id' => $apt_key,
'server' => $apt_keyserver
::datadog_agent::ubuntu::install_key { [$apt_key]:
server => $apt_keyserver,
before => Apt::Source['datadog6'],
}
} else {
$key = {}
}

apt::source { 'datadog':
Expand All @@ -38,8 +33,8 @@
location => $location,
release => $release,
repos => $repos,
key => $key,
require => Exec['apt-transport-https'],
require => Package['apt-transport-https'],
notify => Exec['apt_update'],
}

package { 'datadog-agent-base':
Expand All @@ -50,7 +45,7 @@
package { $datadog_agent::params::package_name:
ensure => $agent_version,
require => [Apt::Source['datadog6'],
Class['apt::update']],
Exec['apt_update']],
}

if $service_provider {
Expand Down
20 changes: 20 additions & 0 deletions manifests/ubuntu/install_key.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Resource type: datadog_agent::ubuntu::install_key
#
# This resource type install repository keys in Ubuntu
#
# Parameters:
#
# Actions:
#
# Requires:
#
# Sample Usage:
#
#
#
define datadog_agent::ubuntu::install_key($server) {
apt::key { $name:
id => $name,
server => $server,
}
}
13 changes: 7 additions & 6 deletions spec/classes/datadog_agent_ubuntu_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
end

# it should install the mirror
it { should_not contain_apt__key('Add key: 935F5A436A5A6E8788F0765B226AE980C7A7DA52 from Apt::Source datadog') }
it { should_not contain_datadog_agent__ubuntu__install_key('935F5A436A5A6E8788F0765B226AE980C7A7DA52') }
it do
should contain_apt__key('Add key: A2923DFF56EDA6E76E55E492D3A80E30382E94DE from Apt::Source datadog')
should contain_datadog_agent__ubuntu__install_key('A2923DFF56EDA6E76E55E492D3A80E30382E94DE')\
end
context 'overriding keyserver' do
let(:params) {{
apt_keyserver: 'hkp://pool.sks-keyservers.net:80',
}}
it do
should contain_apt__key('Add key: A2923DFF56EDA6E76E55E492D3A80E30382E94DE from Apt::Source datadog')\
should contain_datadog_agent__ubuntu__install_key('A2923DFF56EDA6E76E55E492D3A80E30382E94DE')\
.with_server('hkp://pool.sks-keyservers.net:80')
end
end
Expand All @@ -38,7 +38,7 @@

# it should install the packages
it do
should contain_exec('apt-transport-https')\
should contain_package('apt-transport-https')\
.that_comes_before('file[/etc/apt/sources.list.d/datadog.list]')
end
it do
Expand Down Expand Up @@ -91,7 +91,8 @@
end

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

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

# it should install the packages
it do
should contain_exec('apt-transport-https')\
should contain_package('apt-transport-https')\
.that_comes_before('file[/etc/apt/sources.list.d/datadog6.list]')
end
it do
Expand Down