Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding recipe and template for etcd integration. #235

Merged
merged 4 commits into from
Oct 15, 2015
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
15 changes: 15 additions & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,21 @@ suites:
user: someuser
password: somepass

- name: datadog_etcd
run_list:
- recipe[datadog::etcd]
attributes:
datadog:
<<: *DATADOG
etcd:
instances:
- url: http://localhost:2379
timeout: 5
ssl_keyfile: /etc/etcd/ssl.key
ssl_certfile: /etc/etcd/ssl.crt
ssl_cert_validation: true
ssl_ca_certs: /etc/etcd/ca-certs.crt

- name: datadog_docker
run_list:
- recipe[datadog::docker]
Expand Down
24 changes: 24 additions & 0 deletions recipes/etcd.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
include_recipe 'datadog::dd-agent'

# Monitor etcd
#
# API endpoint of your etcd instance
# - url: "https://server:port"
# Change the time to wait on an etcd API request
# timeout: 5
#
# If certificate-based authentication of clients is enabled on your etcd server,
# specify the key file and the certificate file that the check should use.
# ssl_keyfile: /path/to/key/file
# ssl_certfile: /path/to/certificate/file
#
# Set to `false` to disable the validation of the server's SSL certificates (default: true).
# ssl_cert_validation: true
#
# If ssl_cert_validation is enabled, you can provide a custom file
# that lists trusted CA certificates (optional).
# ssl_ca_certs: /path/to/CA/certificate/file

datadog_monitor 'etcd' do
instances node['datadog']['etcd']['instances']
end
12 changes: 12 additions & 0 deletions templates/default/etcd.yaml.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
instances:
<% @instances.each do |i| -%>
- url: <%= i['url'] %>
<% if i['timeout'] -%>timeout: <%= i['timeout'] %><% end -%>
<% if i['ssl_keyfile'] -%>ssl_keyfile: <%= i['ssl_keyfile'] %><% end -%>
<% if i['ssl_certfile'] -%>ssl_certfile: <%= i['ssl_certfile'] %><% end -%>
<% if i['ssl_cert_validation'] -%>ssl_cert_validation: <%= i['ssl_cert_validation'] %><% end -%>
<% if i['ssl_ca_certs'] -%>ssl_ca_certs: <%= i['ssl_ca_certs'] %><% end -%>
<% end -%>

# Nothing to configure here
init_config:
3 changes: 3 additions & 0 deletions test/integration/datadog_etcd/serverspec/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source 'https://rubygems.org'

gem 'json_spec', '~> 1.1'
37 changes: 37 additions & 0 deletions test/integration/datadog_etcd/serverspec/etcd_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Encoding: utf-8
require 'json_spec'
require 'serverspec'
require 'yaml'

set :backend, :exec
set :path, '/sbin:/usr/local/sbin:$PATH'

AGENT_CONFIG = '/etc/dd-agent/conf.d/etcd.yaml'

describe service('datadog-agent') do
it { should be_running }
end

describe file(AGENT_CONFIG) do
it { should be_a_file }

it 'is valid yaml matching input values' do
generated = YAML.load_file(AGENT_CONFIG)

expected = {
'instances' => [
{
'url' => 'http://localhost:2379',
'timeout' => 5,
'ssl_keyfile' => '/etc/etcd/ssl.key',
'ssl_certfile' => '/etc/etcd/ssl.crt',
'ssl_cert_validation' => true,
'ssl_ca_certs' => '/etc/etcd/ca-certs.crt'
}
],
'init_config' => nil
}

expect(generated.to_json).to be_json_eql expected.to_json
end
end