Class: Chef::Application::Recipe
- Inherits:
-
Chef::Application
- Object
- Chef::Application
- Chef::Application::Recipe
- Defined in:
- lib/chef/application/recipe.rb
Instance Method Summary collapse
- #find_recipe(recipe_path) ⇒ Object
-
#initialize ⇒ Recipe
constructor
A new instance of Recipe.
- #reconfigure ⇒ Object
-
#run ⇒ Object
Get this party started.
- #run_application ⇒ Object
- #run_chef_recipe ⇒ Object
Constructor Details
#initialize ⇒ Recipe
Returns a new instance of Recipe.
63 64 65 |
# File 'lib/chef/application/recipe.rb', line 63 def initialize super end |
Instance Method Details
#find_recipe(recipe_path) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/chef/application/recipe.rb', line 76 def find_recipe(recipe_path) if recipe_path.nil? STDERR.puts exit 1 elsif !::File.exist?(recipe_path) STDERR.puts "No file at #{recipe_path}" STDERR.puts exit 1 end recipe_path = File.(recipe_path) end |
#reconfigure ⇒ Object
67 68 69 |
# File 'lib/chef/application/recipe.rb', line 67 def reconfigure configure_logging end |
#run ⇒ Object
Get this party started
123 124 125 126 |
# File 'lib/chef/application/recipe.rb', line 123 def run reconfigure run_application end |
#run_application ⇒ Object
110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/chef/application/recipe.rb', line 110 def run_application begin run_chef_recipe Chef::Application.exit! "Exiting", 0 rescue SystemExit => e raise rescue Exception => e Chef::Application.debug_stacktrace(e) Chef::Application.fatal!("#{e.class}: #{e.}", 1) end end |
#run_chef_recipe ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/chef/application/recipe.rb', line 88 def run_chef_recipe recipe_path = ARGV[0] recipe_path = find_recipe recipe_path Chef::Config[:solo] = true client = Chef::Client.new client.run_ohai client.load_node client.build_node run_context = if client.events.nil? Chef::RunContext.new(client.node, {}) else Chef::RunContext.new(client.node, {}, client.events) end recipe = Chef::Recipe.new("(chef-recipe cookbook)", "(chef-recipe recipe)", run_context) recipe.from_file(recipe_path) runner = Chef::Runner.new(run_context) runner.converge end |