From c97636b800b19993f393ebfcaee2ecf3537d51a6 Mon Sep 17 00:00:00 2001 From: Mike Fiedler Date: Thu, 9 Apr 2015 10:58:06 +0300 Subject: [PATCH 1/2] Set compile_time when using chef_gem resource In Chef 12, the compile_time behavior flag was added, leading to WARN messages showing up in the Chef Client execution. Since the current method to invoke a handler is via a recipe, we need to install the gem during compile time to allow loading the handler to caputer execution items. See https://www.chef.io/blog/2015/02/17/chef-12-1-0-chef_gem-resource-warnings/ for more details on the new flag. Fixes #189 --- .kitchen.yml | 8 ++++++++ recipes/dd-handler.rb | 2 ++ test/integration/dd-handler/serverspec/dd-handler_spec.rb | 8 ++++++++ 3 files changed, 18 insertions(+) create mode 100644 test/integration/dd-handler/serverspec/dd-handler_spec.rb diff --git a/.kitchen.yml b/.kitchen.yml index b3fdf1b4..41bc3d93 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -44,6 +44,14 @@ suites: api_key: somethingnotnil application_key: alsonotnil +- name: dd-handler + run_list: + - recipe[datadog::dd-handler] + attributes: + datadog: &DATADOG + api_key: somethingnotnil + application_key: alsonotnil + - name: datadog_activemq run_list: - recipe[datadog::activemq] diff --git a/recipes/dd-handler.rb b/recipes/dd-handler.rb index f0b99bf9..22c87690 100644 --- a/recipes/dd-handler.rb +++ b/recipes/dd-handler.rb @@ -23,6 +23,8 @@ chef_gem 'chef-handler-datadog' do action :install version node['datadog']['chef_handler_version'] + # Chef 12 introduced `compile_time` - remove when Chef 11 is EOL. + compile_time true if respond_to?(:compile_time) end require 'chef/handler/datadog' diff --git a/test/integration/dd-handler/serverspec/dd-handler_spec.rb b/test/integration/dd-handler/serverspec/dd-handler_spec.rb new file mode 100644 index 00000000..bfd18943 --- /dev/null +++ b/test/integration/dd-handler/serverspec/dd-handler_spec.rb @@ -0,0 +1,8 @@ +require 'serverspec' + +set :backend, :exec +set :path, '/sbin:/usr/local/sbin:$PATH' + +describe package('chef-handler-datadog') do + it { should be_installed.by('gem') } +end From 7e81689ab6c972337409a4707ff46ab44bbe785e Mon Sep 17 00:00:00 2001 From: Mike Fiedler Date: Thu, 9 Apr 2015 12:17:53 +0300 Subject: [PATCH 2/2] disable FC009 until foodcritic metadata updated Also see https://github.com/acrmp/foodcritic/issues/318 --- recipes/dd-handler.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/dd-handler.rb b/recipes/dd-handler.rb index 22c87690..2622447d 100644 --- a/recipes/dd-handler.rb +++ b/recipes/dd-handler.rb @@ -20,7 +20,7 @@ include_recipe 'chef_handler' ENV['DATADOG_HOST'] = node['datadog']['url'] -chef_gem 'chef-handler-datadog' do +chef_gem 'chef-handler-datadog' do # ~FC009 action :install version node['datadog']['chef_handler_version'] # Chef 12 introduced `compile_time` - remove when Chef 11 is EOL.