Skip to content

Commit

Permalink
Merge branch 'master' into DataDogGH-473
Browse files Browse the repository at this point in the history
  • Loading branch information
olivielpeau authored Sep 28, 2017
2 parents abcee10 + ed46b65 commit 8d48eee
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 7 deletions.
2 changes: 1 addition & 1 deletion attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
# Agent Version
# Default of `nil` will install latest version. On Windows, this will also upgrade to latest
# This attribute accepts either a `string` or `hash` with the key as platform_name and value of package version
# In the case of fedora use platform_name of rhel
# In the case of fedora and amazon linux, use platform_name of rhel
# Example:
# default['datadog']['agent_version'] = {
# 'rhel' => '5.9.0-1',
Expand Down
4 changes: 2 additions & 2 deletions recipes/_install-linux.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
dd_agent_version =
if node['datadog']['agent_version'].respond_to?(:each_pair)
case node['platform_family']
when 'rhel', 'fedora'
when 'rhel', 'fedora', 'amazon'
node['datadog']['agent_version']['rhel']
else
node['datadog']['agent_version'][node['platform_family']]
Expand Down Expand Up @@ -60,7 +60,7 @@
action node['datadog']['agent_package_action'] # default is :install
options '--force-yes' if node['datadog']['agent_allow_downgrade']
end
when 'rhel', 'fedora'
when 'rhel', 'fedora', 'amazon'
yum_package 'datadog-agent' do
version dd_agent_version
retries package_retries unless package_retries.nil?
Expand Down
1 change: 1 addition & 0 deletions recipes/rabbitmq.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# "user" => "guest",
# "pass" => "guest",
# "ssl_verify" => "true"
# "tag_families" => "false"
# }
# ]

Expand Down
3 changes: 2 additions & 1 deletion recipes/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
action :add
end

when 'rhel', 'fedora'
when 'rhel', 'fedora', 'amazon'
# Import new RPM key
if node['datadog']['yumrepo_gpgkey_new']
# gnupg is required to check the downloaded key's fingerprint
Expand Down Expand Up @@ -76,6 +76,7 @@
proxy_username node['datadog']['yumrepo_proxy_username']
proxy_password node['datadog']['yumrepo_proxy_password']
gpgkey node['datadog']['yumrepo_gpgkey']
gpgcheck true
action :create
end
end
3 changes: 2 additions & 1 deletion recipes/supervisord.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# Build a data structure with configuration.
# @see https://github.com/DataDog/dd-agent/blob/master/conf.d/supervisord.yaml.example Supervisord Example
# @example
# node.override['datadog']['supervisord']['instances'] =
# node.override['datadog']['supervisord']['instances'] = [
# {
# name: 'server0',
# socket: 'unix:///var/run/default-supervisor.sock'
Expand All @@ -37,6 +37,7 @@
# 'webapp'
# ]
# }
# ]

datadog_monitor 'supervisord' do
instances node['datadog']['supervisord']['instances']
Expand Down
48 changes: 48 additions & 0 deletions spec/integrations/elasticsearch_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
describe 'datadog::elasticsearch' do
expected_yaml = <<-EOF
init_config:
instances:
- url: http://localhost:9200
username: testuser
password: testpassword
pshard_stats: true
tags:
- 'env:test'
EOF

cached(:chef_run) do
ChefSpec::SoloRunner.new(step_into: ['datadog_monitor']) do |node|
node.automatic['languages'] = { 'python' => { 'version' => '2.7.2' } }
node.set['datadog'] = {
api_key: 'someapikey',
elasticsearch: {
instances: [
{
url: 'http://localhost:9200',
username: 'testuser',
password: 'testpassword',
pshard_stats: true,
tags: ['env:test']
}
]
}
}
end.converge(described_recipe)
end

subject { chef_run }

it_behaves_like 'datadog-agent'

it { is_expected.to include_recipe('datadog::dd-agent') }

it { is_expected.to add_datadog_monitor('elastic') }

it 'renders expected YAML config file' do
expect(chef_run).to(render_file('/etc/dd-agent/conf.d/elastic.yaml').with_content { |content|
expect(YAML.safe_load(content).to_json).to be_json_eql(YAML.safe_load(expected_yaml).to_json)
})
end
end
1 change: 1 addition & 0 deletions spec/integrations/rabbitmq_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
rabbitmq_user: guest
rabbitmq_pass: guest
ssl_verify: true
tag_families: false
tags:
- optional_tag1
- optional_tag2
Expand Down
12 changes: 12 additions & 0 deletions templates/default/elastic.yaml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ instances:
<% unless i["timeout"].nil? %>
timeout: <%= i["timeout"] %>
<% end %>
<% unless i["pending_task_stats"].nil? %>
pending_task_stats: <%= i["pending_task_stats"] %>
<% end %>
<% unless i["ssl_verify"].nil? %>
ssl_verify: <%= i["ssl_verify"] %>
<% end %>
<% unless i["ssl_cert"].nil? %>
ssl_cert: <%= i["ssl_cert"] %>
<% end %>
<% unless i["ssl_key"].nil? %>
ssl_key: <%= i["ssl_key"] %>
<% end %>
<% if i.key?('tags') -%>
tags:
<% i['tags'].each do |t| -%>
Expand Down
14 changes: 13 additions & 1 deletion templates/default/mongo.yaml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,19 @@ instances:
ssl_certfile: <%= i['ssl_certfile'] %>
ssl_keyfile: <%= i['ssl_keyfile'] %>
<% end %>
<% if i.key?('additional_metrics') -%>
additional_metrics:
<% i['additional_metrics'].each do |t| %>
- <%= t %>
<%end -%>
<% end %>
<% if i.key?('collections') -%>
collections:
<% i['collections'].each do |t| %>
- <%= t %>
<%end -%>
<% end %>
<% end -%>

init_config:
# No init_config details needed
# No init_config details needed
4 changes: 3 additions & 1 deletion templates/default/rabbitmq.yaml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
instances:
# for every instance a 'rabbitmq_api_url' must be provided, pointing to the api
# url of the RabbitMQ Managment Plugin (http://www.rabbitmq.com/management.html)
# optional: 'rabbitmq_user' (default: guest), 'rabbitmq_pass' (default: guest), and 'ssl_verify' (default: true)
# optional: 'rabbitmq_user' (default: guest), 'rabbitmq_pass' (default: guest), 'ssl_verify' (default: true) and 'tag_families' (default: false)
<% @instances.each do |i| -%>
- rabbitmq_api_url: <%= i['api_url'] %>
rabbitmq_user: <%= i['user'] || 'guest' %>
rabbitmq_pass: <%= i['pass'] || 'guest' %>
ssl_verify: <%= i.key?('ssl_verify') ? i['ssl_verify'] : 'true' %>
# https://help.datadoghq.com/hc/en-us/articles/211590103-Tagging-RabbitMQ-queues-by-tag-family
tag_families: <%= i['tag_families'] || 'false' %>
<% if i.key?('tags') -%>
tags:
<% i['tags'].each do |x| -%>
Expand Down

0 comments on commit 8d48eee

Please sign in to comment.