Wings2fly
Wings2fly

Reputation: 917

How to include a chef recipe based on the output from bash command?

I would like to get the count of a particular process , and include the config recipe only if there are no processes.

Something to this effect. How is this possible in chef?

if !( "(ps aux | grep splunkd | grep -v grep | wc -l) > 0 ") 
  include_recipe 'platform::splunk_config' 
end

Upvotes: 0

Views: 126

Answers (1)

Mr.
Mr.

Reputation: 10102

i can offer an idea to use ruby_block resourece in a conjunction with a guard, and it should be something like:

ruby_block 'splank configuration' do
  block { include_recipe 'platform::splunk_config' }
  not_if "ps aux | grep splunkd | grep -v grep | wc -l > 0"
end

but i haven't tried it :)

Upvotes: 1

Related Questions