Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempting to install file only if it is downloaded and/or modified #73

Merged
merged 3 commits into from
Aug 13, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions recipes/_install_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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