Method: Chef::Application::Apply#run_chef_recipe

Defined in:
lib/chef/application/apply.rb

#run_chef_recipeObject



223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# File 'lib/chef/application/apply.rb', line 223

def run_chef_recipe
  if config[:execute]
    @recipe_text = config[:execute]
    temp_recipe_file
  elsif config[:stdin]
    @recipe_text = STDIN.read
    temp_recipe_file
  else
    unless ARGV[0]
      puts opt_parser
      Chef::Application.exit! "No recipe file provided", Chef::Exceptions::RecipeNotFound.new
    end
    @recipe_filename = ARGV[0]
    @recipe_text, @recipe_fh = read_recipe_file @recipe_filename
  end
  recipe, run_context = get_recipe_and_run_context
  if config[:yaml] || File.extname(@recipe_filename) == ".yml"
    logger.info "Parsing recipe as YAML"
    recipe.from_yaml(@recipe_text)
  else
    recipe.instance_eval(@recipe_text, @recipe_filename, 1)
  end
  runner = Chef::Runner.new(run_context)
  catch(:end_client_run_early) do

    runner.converge
  ensure
    @recipe_fh.close

  end
  Chef::Platform::Rebooter.reboot_if_needed!(runner)
end