From 46ee21ca2ad424d7f180b7597d8d1df0ee96f6a1 Mon Sep 17 00:00:00 2001 From: Suleyman Kutlu Date: Mon, 8 Oct 2018 11:44:04 +0200 Subject: [PATCH 1/2] Using lazy this will allow other app cookbooks / wrappers / role cookbooks in the runlist to be able to set telegraf input / perf counter or other install attributes even if they are later than telegraf cookbook in the runlist. This way, correct / desired values of attributes will be used. --- recipes/default.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/recipes/default.rb b/recipes/default.rb index bcdd0f9..c4aceff 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -17,16 +17,16 @@ # limitations under the License. telegraf_install 'default' do - include_repository node['telegraf']['include_repository'] - install_version node['telegraf']['version'] - install_type node['telegraf']['install_type'] + include_repository lazy { node['telegraf']['include_repository'] } + install_version lazy { node['telegraf']['version'] } + install_type lazy { node['telegraf']['install_type'] } action :create end telegraf_config 'default' do - path node['telegraf']['config_file_path'] - config node['telegraf']['config'] - outputs node['telegraf']['outputs'] - perf_counters node['telegraf']['perf_counters'] - inputs node['telegraf']['inputs'] + path lazy { node['telegraf']['config_file_path'] } + config lazy { node['telegraf']['config'] } + outputs lazy { node['telegraf']['outputs'] } + perf_counters lazy { node['telegraf']['perf_counters'] } + inputs lazy { node['telegraf']['inputs'] } end From e26de7931fa5b02b0ef5c0382c3a7cbe63c14941 Mon Sep 17 00:00:00 2001 From: Suleyman Kutlu Date: Thu, 11 Oct 2018 14:26:28 +0200 Subject: [PATCH 2/2] Fix windows chocolatey package upgrade If an older version is already installed - we need to stop the service so files will not be in use --- resources/install.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/resources/install.rb b/resources/install.rb index d274d95..cb2dc08 100644 --- a/resources/install.rb +++ b/resources/install.rb @@ -90,6 +90,14 @@ end if platform_family? 'windows' + if telegraf_install? + service "telegraf_#{new_resource.name}" do + service_name 'telegraf' + action [:stop] + only_if { ::Win32::Service.exists?('telegraf') } + end + end + chocolatey_package 'telegraf' do version new_resource.install_version source node['telegraf']['chocolatey_source']