title: Chef Best Practice Loop same recipe
body: <p>Can anyone suggest in chef a best way to handle looping and running a certain recipe. For example I have this in my recipe</p>
  
  <pre><code>apps_databag = search("aws_opsworks_app")
  
  apps_databag.each do |app_settings|
  
  case app_settings['app_source']['type']
    when 's3'
     include_recipe 'recipe'
    when 'git'
     include_recipe 'recipe2'
    else
     Chef::Log.warn("*** WARNING!! Cannot find app deployment type. Please check App .. Aborting ***")
  end
  </code></pre>
  
  <p>Background.. in 1 stack we have many APP that are deployed in different Server layers. We did because it cannot share RDS in two different stack. It's definitely working , now when we loop the APP we have do a trick that it will run this recipe according to it's type unfortunately include_recipe is not a good choice and for the sake of the recipe we don't want to make this recipe bloody to maintain by injecting more lines</p>
  
  <p>Any suggestion for this scenario?</p>