Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

How can I cal a custom recipe from my default recipe? If I try

recipe 'my-base-server'

I get an error 1 argument for 0

What I want to achieve is a logical division of my recipe into base, web-server and app-server. I will setup each recipe as described in the answer below but I want to include these recipes in my default recipe. What I can't figure out is probably dead simple, is how to call the web-server recipe I write from the default recipe. The web server recipe will in turn call the nginx recipe as described below. I am using Berkshelf. I don't want to use roles and nodes. I can't find documentation about how to do this with only wrapper recipes.

Essentially, all I want to know is very basic, how to define a run list in a recipe. I can't find a reference anywhere that doesn't do it from a role or node.

share|improve this question
add comment

2 Answers 2

You can use wrapper cookbooks like so (in this case, deploying a Tomcat app):

node.set['java']['install_flavor'] = 'oracle'
node.set['java']['oracle']['accept_oracle_download_terms'] = true
node.set['java']['jdk_version'] = 7


node.set['tomcat']['base_version'] = 7
node.set['tomcat']['loglevel'] = 'WARN'     # default is 'INFO'

tempdir     = node['appname']['temp_dir']
configdir   = node['appname']['config_dir']
loggingconf = node['appname']['logging_conf'] 
grailsenv   = node['appname']['grails_env']
appdir      = node['appname']['app_dir']

if Chef::Config[:solo]
    node.set["tomcat"]["keystore_password"] = 'throwawaypassword'
    node.set["tomcat"]["truststore_password"] = 'throwawaypassword'
end

include_recipe "java"
include_recipe "tomcat"
share|improve this answer
    
In what file is this code? –  markhorrocks Feb 9 at 6:56
    
This is in a custom cookbook recipe, in this example, the cookbook is called 'appname'. Honestly, it sounds like you should spend some time on learnchef.opscode.com –  gWaldo Feb 10 at 0:30
add comment
up vote -1 down vote accepted

I just needed to namespace the recipe like this

include_recipe 'my-rails-server::web-server'

where the recipe name was

recipes/web-server.rb

My problem was that I had tried this after creating a cookbook by hand and it didn't work. After I used

berks cookbook my-rails-server

it worked fine.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.