0

is there a way to use Chef methods like "yum_package" in a ruby script, executed by standard ruby environment and not in a chef cookbook?

I try to install and remove yum packages in a ruby script and i was thinking about using the methods chef is offering in cookbooks. Chef is already installed on the system.

What i tried is:

require "/opt/chef/embedded/apps/chef/lib/chef.rb"
Chef::Resource::YumPackage.property("vim","7.4.160")
Chef::Resource::YumPackage.action(:install)

I am a beginner in ruby and not sure if i am on the right way. Have somebody tried to use chef Methods in Ruby before? I hope you could help me out with that Problem.

Thanks Til

Til
  • 95
  • 1
  • 1
  • 8

1 Answers1

0

This is not something you can do directly, using the Chef DSL requires a lot of stuff to be set up in the background. If you are looking to write a simple script using the Chef recipe DSL, check out the chef-apply command.

coderanger
  • 52,400
  • 4
  • 52
  • 75