Skip to content

Commit

Permalink
Stop dd-handler recipe if chef_handler is not available.
Browse files Browse the repository at this point in the history
  • Loading branch information
remeh committed Mar 19, 2019
1 parent 02b51ae commit 758b844
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 6 additions & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
@@ -23,8 +23,13 @@
supports os
end

# Chef 14 has included the community chef_handler cookbook to its resources.
# However, versions of Chef < 14 still need to include the chef_handler cookbook
# in their dependencies:
#
# depends 'chef_handler', '>= 1.2' # chef_handler >= 1.2 is needed for Chef < 14

depends 'apt' # We recommend '>= 2.1.0'. See CHANGELOG.md for details
depends 'chef_handler', '>= 1.2' # We recommend '~> 1.3' with Chef < 12. See CHANGELOG.md for details
depends 'windows' # We recommend '< 1.39.0' if running Chef >= 12.6. See README.md for details
depends 'yum', '>= 3.0' # Use '~> 3.0' with Chef < 12

9 changes: 8 additions & 1 deletion recipes/dd-handler.rb
Original file line number Diff line number Diff line change
@@ -25,7 +25,14 @@
return
end

include_recipe 'chef_handler'
unless respond_to?(:chef_handler)
# Chef 14 has included the community chef_handler cookbook to its resources.
# However, versions of Chef < 14 still need to include the chef_handler cookbook
# in their dependencies:
Chef::Log.warn('To use dd-handler, you need to add chef_handler >= 1.2 to your depencies. See datadog/metadata.rb for more info.')
return
end

ENV['DATADOG_HOST'] = node['datadog']['url']

chef_gem 'chef-handler-datadog' do # ~FC009

0 comments on commit 758b844

Please sign in to comment.