Skip to content

Commit 3b8eabb

Browse files
authored
Add install_info file (#628)
1 parent 20ece99 commit 3b8eabb

4 files changed

Lines changed: 51 additions & 1 deletion

File tree

manifests/init.pp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,8 @@
384384
$local_integrations = $integrations
385385
}
386386

387+
$_puppetversion = lookup({ 'name' => '::puppetversion', 'default_value' => 'unknown'})
388+
387389
include datadog_agent::params
388390
case upcase($log_level) {
389391
'CRITICAL': { $_loglevel = 'CRITICAL' }
@@ -558,6 +560,15 @@
558560
order => '08',
559561
}
560562
}
563+
564+
file {'/etc/dd-agent/install_info':
565+
owner => $dd_user,
566+
group => $dd_group,
567+
mode => '0640',
568+
content => template('datadog_agent/install_info.erb'),
569+
require => File['/etc/dd-agent'],
570+
}
571+
561572
} else { #Agent 6/7
562573

563574
# notify of broken params on agent6/7
@@ -714,6 +725,14 @@
714725
require => File['C:/ProgramData/Datadog'],
715726
}
716727

728+
file { 'C:/ProgramData/Datadog/install_info':
729+
owner => $dd_user,
730+
group => $dd_group,
731+
mode => '0660',
732+
content => template('datadog_agent/install_info.erb'),
733+
require => File['C:/ProgramData/Datadog'],
734+
}
735+
717736
} else {
718737

719738
file { '/etc/datadog-agent/datadog.yaml':
@@ -725,6 +744,14 @@
725744
require => File['/etc/datadog-agent'],
726745
}
727746

747+
file { '/etc/datadog-agent/install_info':
748+
owner => $dd_user,
749+
group => $dd_group,
750+
mode => '0640',
751+
content => template('datadog_agent/install_info.erb'),
752+
require => File['/etc/datadog-agent'],
753+
}
754+
728755
}
729756

730757
}

manifests/params.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
$apt_backup_keyserver = 'hkp://pool.sks-keyservers.net:80'
2424
$apt_keyserver = 'hkp://keyserver.ubuntu.com:80'
2525
$sysprobe_service_name = 'datadog-agent-sysprobe'
26+
$module_metadata = load_module_metadata($module_name)
2627

2728
case $::operatingsystem {
2829
'Ubuntu','Debian' : {

spec/classes/datadog_agent_spec.rb

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1591,18 +1591,35 @@
15911591
end
15921592

15931593
config_dir = WINDOWS_OS.include?(operatingsystem) ? 'C:/ProgramData/Datadog' : '/etc/datadog-agent'
1594-
config_yaml_file = config_dir + '/datadog.yaml'
1594+
config_yaml_file = File.join(config_dir, 'datadog.yaml')
1595+
install_info_file = File.join(config_dir, 'install_info')
15951596
log_file = WINDOWS_OS.include?(operatingsystem) ? 'C:/ProgramData/Datadog/logs/agent.log' : '\/var\/log\/datadog\/agent.log'
15961597

15971598
it { is_expected.to contain_file(config_dir) }
15981599
it { is_expected.to contain_file(config_yaml_file) }
1600+
it { is_expected.to contain_file(install_info_file) }
15991601
it { is_expected.to contain_file(config_dir + '/conf.d').with_ensure('directory') }
16001602

16011603
# Agent 5 files
16021604
it { is_expected.not_to contain_file('/etc/dd-agent') }
16031605
it { is_expected.not_to contain_concat('/etc/dd-agent/datadog.conf') }
16041606
it { is_expected.not_to contain_file('/etc/dd-agent/conf.d').with_ensure('directory') }
16051607

1608+
describe 'install_info check' do
1609+
let!(:install_info) do
1610+
contents = catalogue.resource('file', install_info_file).send(:parameters)[:content]
1611+
YAML.safe_load(contents)
1612+
end
1613+
1614+
it 'adds an install_info' do
1615+
expect(install_info['install_method']).to match(
1616+
'tool' => 'puppet',
1617+
'tool_version' => %r{^puppet-(\d+\.\d+\.\d+|unknown)$},
1618+
'installer_version' => %r{^datadog_module-\d+\.\d+\.\d+$},
1619+
)
1620+
end
1621+
end
1622+
16061623
describe 'agent6 parameter check' do
16071624
context 'with defaults' do
16081625
context 'for basic beta settings' do

templates/install_info.erb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
install_method:
3+
tool: puppet
4+
tool_version: puppet-<%= @_puppetversion %>
5+
installer_version: datadog_module-<%= @module_metadata['version'] %>

0 commit comments

Comments
 (0)