Skip to content

Commit 7aa172a

Browse files
authored
Merge pull request #219 from aaron-miller/topic_ssh
Feature: SSH Integration
2 parents 3ed7976 + 34f3005 commit 7aa172a

3 files changed

Lines changed: 100 additions & 0 deletions

File tree

manifests/integrations/ssh.pp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Class: datadog_agent::integrations::ssh
2+
#
3+
# This class will enable ssh check
4+
#
5+
# Parameters:
6+
# $host:
7+
# ssh server to use for ssh check
8+
#
9+
# $port
10+
#
11+
# $username
12+
#
13+
# $password
14+
#
15+
# $sftp_check
16+
#
17+
# $private_key_file
18+
#
19+
# $add_missing_keys
20+
#
21+
# Sample Usage:
22+
#
23+
# class { 'datadog_agent::integrations::ssh' :
24+
# host => 'localhost',
25+
# private_key_file => '/opt/super_secret_key',
26+
# }
27+
#
28+
29+
class datadog_agent::integrations::ssh(
30+
$host = $::fqdn,
31+
$port = 22,
32+
$username = $datadog_agent::params::dd_user,
33+
$password = undef,
34+
$sftp_check = true,
35+
$private_key_file = undef,
36+
$add_missing_keys = true,
37+
) inherits datadog_agent::params {
38+
include ::datadog_agent
39+
40+
file { "${datadog_agent::params::conf_dir}/ssh.yaml":
41+
ensure => file,
42+
owner => $datadog_agent::params::dd_user,
43+
group => $datadog_agent::params::dd_group,
44+
mode => '0600',
45+
content => template('datadog_agent/agent-conf.d/ssh.yaml.erb'),
46+
require => Package[$datadog_agent::params::package_name],
47+
notify => Service[$datadog_agent::params::service_name]
48+
}
49+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
require 'spec_helper'
2+
3+
describe 'datadog_agent::integrations::ssh' do
4+
let(:facts) {{
5+
operatingsystem: 'Ubuntu',
6+
}}
7+
let(:conf_dir) { '/etc/dd-agent/conf.d' }
8+
let(:dd_user) { 'dd-agent' }
9+
let(:dd_group) { 'root' }
10+
let(:dd_package) { 'datadog-agent' }
11+
let(:dd_service) { 'datadog-agent' }
12+
let(:conf_file) { "#{conf_dir}/ssh.yaml" }
13+
14+
context 'with default parameters' do
15+
it { should compile }
16+
end
17+
18+
context 'with parameters set' do
19+
let(:params) {{
20+
host: 'localhost',
21+
port: 222,
22+
username: 'foo',
23+
password: 'bar',
24+
sftp_check: false,
25+
}}
26+
it { should contain_file(conf_file).with_content(/host: localhost/) }
27+
it { should contain_file(conf_file).with_content(/port: 222/) }
28+
it { should contain_file(conf_file).with_content(/username: foo/) }
29+
it { should contain_file(conf_file).with_content(/password: bar/) }
30+
it { should contain_file(conf_file).without_content(/private_key_file:/) }
31+
end
32+
end
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#
2+
# Managed by Puppet
3+
#
4+
5+
init_config:
6+
7+
instances:
8+
9+
- host: <%= @host %>
10+
port: <%= @port %>
11+
username: <%= @username %>
12+
<% if @password -%>
13+
password: <%= @password %>
14+
<% end -%>
15+
sftp_check: <%= @sftp_check %>
16+
<% if @private_key_file -%>
17+
private_key_file: <%= @private_key_file %>
18+
<% end -%>
19+
add_missing_keys: <%= @add_missing_keys %>

0 commit comments

Comments
 (0)