[chef] Re: Run ruby script during chef-client run?


Chronological Thread 
  • From: Jeff Byrnes < >
  • To:
  • Subject: [chef] Re: Run ruby script during chef-client run?
  • Date: Thu, 19 Mar 2015 11:10:09 -0400

Rafal:

So yes, the ruby_block resource is for an inline block of Ruby code you want to run within the context of the Chef execution.

As for your execute resource, that appears to a way to do it. Curious though; is there any reason you wouldn’t write your script as a library for your cookbook, and then use the ruby_block resource to execute it? Do you need the script outside of the scope of Chef convergences?

-- 
Jeff Byrnes
@thejeffbyrnes
Lead DevOps Engineer
704.516.4628

On March 19, 2015 at 10:27:54 AM, Rafał Radecki ( "> ) wrote:

Hi All :)

I am trying to run a ruby script with /opt/chef-server/embedded/bin/ruby interpreter during chef-client run.

This works:

execute 'process_something' do
        action :run
        command '/opt/chef-server/embedded/bin/ruby /usr/local/bin/process_something.rb'
end

These do not work:

ruby 'process_something' do
        action :run
        command '/opt/chef-server/embedded/bin/ruby /usr/local/bin/process_something.rb'
end

and

ruby 'process_something' do
        action :run
        command '/usr/local/bin/process_something.rb'
end

I run the cookbook with '-l debug' but eventually got only:

[2015-03-19T14:24:41+00:00] INFO: ruby[process_something] ran successfully

in the logs.

Can anyone tell me how to run a ruby script during chef-client run with interpreter from /opt/chef-server/embedded/bin/ruby or /opt/chef/embedded/bin/ruby?

I know that I can use ruby_code resource but I am under impression that it should be used rather for blocks of ruby code and not for scripts, is it so?

BR,
Rafal.



Archive powered by MHonArc 2.6.16.

§