Skip to content

Commit 0bdb73a

Browse files
committed
Merge pull request #235 from mubi/add-etcd
Adding recipe and template for etcd integration.
2 parents 0687ddf + eb74a40 commit 0bdb73a

File tree

5 files changed

+91
-0
lines changed

5 files changed

+91
-0
lines changed

.kitchen.yml

+15
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,21 @@ suites:
124124
user: someuser
125125
password: somepass
126126

127+
- name: datadog_etcd
128+
run_list:
129+
- recipe[datadog::etcd]
130+
attributes:
131+
datadog:
132+
<<: *DATADOG
133+
etcd:
134+
instances:
135+
- url: http://localhost:2379
136+
timeout: 5
137+
ssl_keyfile: /etc/etcd/ssl.key
138+
ssl_certfile: /etc/etcd/ssl.crt
139+
ssl_cert_validation: true
140+
ssl_ca_certs: /etc/etcd/ca-certs.crt
141+
127142
- name: datadog_docker
128143
run_list:
129144
- recipe[datadog::docker]

recipes/etcd.rb

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
include_recipe 'datadog::dd-agent'
2+
3+
# Monitor etcd
4+
#
5+
# API endpoint of your etcd instance
6+
# - url: "https://server:port"
7+
# Change the time to wait on an etcd API request
8+
# timeout: 5
9+
#
10+
# If certificate-based authentication of clients is enabled on your etcd server,
11+
# specify the key file and the certificate file that the check should use.
12+
# ssl_keyfile: /path/to/key/file
13+
# ssl_certfile: /path/to/certificate/file
14+
#
15+
# Set to `false` to disable the validation of the server's SSL certificates (default: true).
16+
# ssl_cert_validation: true
17+
#
18+
# If ssl_cert_validation is enabled, you can provide a custom file
19+
# that lists trusted CA certificates (optional).
20+
# ssl_ca_certs: /path/to/CA/certificate/file
21+
22+
datadog_monitor 'etcd' do
23+
instances node['datadog']['etcd']['instances']
24+
end

templates/default/etcd.yaml.erb

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
instances:
2+
<% @instances.each do |i| -%>
3+
- url: <%= i['url'] %>
4+
<% if i['timeout'] -%>timeout: <%= i['timeout'] %><% end -%>
5+
<% if i['ssl_keyfile'] -%>ssl_keyfile: <%= i['ssl_keyfile'] %><% end -%>
6+
<% if i['ssl_certfile'] -%>ssl_certfile: <%= i['ssl_certfile'] %><% end -%>
7+
<% if i['ssl_cert_validation'] -%>ssl_cert_validation: <%= i['ssl_cert_validation'] %><% end -%>
8+
<% if i['ssl_ca_certs'] -%>ssl_ca_certs: <%= i['ssl_ca_certs'] %><% end -%>
9+
<% end -%>
10+
11+
# Nothing to configure here
12+
init_config:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
source 'https://rubygems.org'
2+
3+
gem 'json_spec', '~> 1.1'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Encoding: utf-8
2+
require 'json_spec'
3+
require 'serverspec'
4+
require 'yaml'
5+
6+
set :backend, :exec
7+
set :path, '/sbin:/usr/local/sbin:$PATH'
8+
9+
AGENT_CONFIG = '/etc/dd-agent/conf.d/etcd.yaml'
10+
11+
describe service('datadog-agent') do
12+
it { should be_running }
13+
end
14+
15+
describe file(AGENT_CONFIG) do
16+
it { should be_a_file }
17+
18+
it 'is valid yaml matching input values' do
19+
generated = YAML.load_file(AGENT_CONFIG)
20+
21+
expected = {
22+
'instances' => [
23+
{
24+
'url' => 'http://localhost:2379',
25+
'timeout' => 5,
26+
'ssl_keyfile' => '/etc/etcd/ssl.key',
27+
'ssl_certfile' => '/etc/etcd/ssl.crt',
28+
'ssl_cert_validation' => true,
29+
'ssl_ca_certs' => '/etc/etcd/ca-certs.crt'
30+
}
31+
],
32+
'init_config' => nil
33+
}
34+
35+
expect(generated.to_json).to be_json_eql expected.to_json
36+
end
37+
end

0 commit comments

Comments
 (0)