user784637
user784637

Reputation: 16152

Is there a way to run ad-hoc commands instead of creating a recipe within a chef-solo ruby script?

I'm using chef solo with the following files.

node.json

{
  "run_list": [
    "recipe[testing]"
  ]
}

solo.rb

file_cache_path "/home/vagrant/chef"
cookbook_path "/home/vagrant/chef/cookbooks"
json_attribs "/home/vagrant/chef/node.json"

execute "testing" do
  command "echo hello"
end

Why doesn't the echo hello part of the solo.rb run? Is it possible to run ad-hoc commands within solo.rb?

Or should solo.rb only be used to specify the path of node.json which would include a recipe for the ad-hoc command. I'm trying to avoid creating a recipe for just a simple one-off command.

Upvotes: 0

Views: 1073

Answers (2)

coderanger
coderanger

Reputation: 54249

If you want to run ad hoc Chef code, you can use chef-apply.

Upvotes: 1

sethvargo
sethvargo

Reputation: 26997

You can read more about the solo.rb config file, but that is the config file for Chef Solo - you cannot execute recipe code inside that config file. If you want to execute a Chef recipe, you can add it to the run_list in the JSON file.

Upvotes: 0

Related Questions