Chiefwarpaint
Chiefwarpaint

Reputation: 683

CHEF Use a Not_If to Check if Program is Installed

I'm trying to make my CHEF script smart enough to not try and install Rails, if it's already installed. Below is how I'm currently handling it, but it seems like there is probably a better way.

execute 'install_rails' do
  user 'root'
  cwd '/root/'
  command "/root/.rbenv/shims/gem install rails -v #{node['rails']['version']}"
  not_if "rails -v | grep \'#{node['rails']['version']}\'"
end

Does anyone have any experience with a better way to do this?

Upvotes: 1

Views: 762

Answers (1)

coderanger
coderanger

Reputation: 54267

Why not just use the normal gem_package resource or the ruby_gem resource from poise-ruby?

Upvotes: 1

Related Questions