diff --git a/recipes/_install_file.rb b/recipes/_install_file.rb index b5e2b943..091d767a 100644 --- a/recipes/_install_file.rb +++ b/recipes/_install_file.rb @@ -26,30 +26,37 @@ package pkg end + grafana_installed = "dpkg -l | grep '^ii' | grep grafana | grep #{node['grafana']['version']}" + remote_file "#{Chef::Config[:file_cache_path]}/grafana-#{node['grafana']['version']}.deb" do source "#{node['grafana']['file']['url']}_#{node['grafana']['version']}_amd64.deb" - action :create - not_if "dpkg -l | grep '^ii' | grep grafana | grep #{node['grafana']['version']}" + action :create_if_missing + not_if grafana_installed end dpkg_package "grafana-#{node['grafana']['version']}" do source "#{Chef::Config[:file_cache_path]}/grafana-#{node['grafana']['version']}.deb" action :install + not_if grafana_installed end + when 'rhel' pkgs = %w(initscripts fontconfig) pkgs.each do |pkg| package pkg end + grafana_installed = "yum list installed | grep grafana | grep #{node['grafana']['version']}" + remote_file "#{Chef::Config[:file_cache_path]}/grafana-#{node['grafana']['version']}.rpm" do source "#{node['grafana']['file']['url']}-#{node['grafana']['version']}-1.x86_64.rpm" - action :create - not_if "yum list installed | grep grafana | grep #{node['grafana']['version']}" + action :create_if_missing + not_if grafana_installed end rpm_package "grafana-#{node['grafana']['version']}" do source "#{Chef::Config[:file_cache_path]}/grafana-#{node['grafana']['version']}.rpm" action :install + not_if grafana_installed end end