From d29dbdfbf425e36fb5b447a573f072d37fd3a8f5 Mon Sep 17 00:00:00 2001 From: Doug Luxem Date: Thu, 21 Mar 2019 11:24:04 -0500 Subject: [PATCH] Fixes Windows issue where filebeats service is reinstalled on each run --- resources/install.rb | 2 ++ spec/unit/recipes/default_spec.rb | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/resources/install.rb b/resources/install.rb index ab36f5c..69a522e 100755 --- a/resources/install.rb +++ b/resources/install.rb @@ -79,10 +79,12 @@ source package_file action :unzip not_if { ::File.exist?(new_resource.conf_dir + '/install-service-filebeat.ps1') } + notifies :run, 'powershell_script[install filebeat as service]', :immediately end powershell_script 'install filebeat as service' do code "& '#{new_resource.conf_dir}/install-service-filebeat.ps1'" + action :nothing end end diff --git a/spec/unit/recipes/default_spec.rb b/spec/unit/recipes/default_spec.rb index a841bac..db9510e 100644 --- a/spec/unit/recipes/default_spec.rb +++ b/spec/unit/recipes/default_spec.rb @@ -99,7 +99,8 @@ end it 'run powershell_script to install filebeat as service' do - expect(chef_run).to run_powershell_script('install filebeat as service') + expect(chef_run.windows_zipfile('C:/opt/filebeat')).to notify('powershell_script[install filebeat as service]').to(:run).immediately + expect(chef_run).to_not run_powershell_script('install filebeat as service') end end