class KnifeContainer::ChefRunner
An adapter to chef's APIs to kick off a chef-client run.
Attributes
cookbook_path[R]
run_list[R]
Public Class Methods
new(cookbook_path, run_list)
click to toggle source
# File lib/knife-container/chef_runner.rb, line 27 def initialize(cookbook_path, run_list) @cookbook_path = cookbook_path @run_list = run_list @formatter = nil @ohai = nil end
Public Instance Methods
configure()
click to toggle source
# File lib/knife-container/chef_runner.rb, line 58 def configure Chef::Config.solo = true Chef::Config.cookbook_path = cookbook_path Chef::Config.color = true Chef::Config.diff_disabled = true end
converge()
click to toggle source
# File lib/knife-container/chef_runner.rb, line 34 def converge configure Chef::Runner.new(run_context).converge end
formatter()
click to toggle source
# File lib/knife-container/chef_runner.rb, line 54 def formatter @formatter ||= Chef::Formatters.new(:doc, stdout, stderr) end
ohai()
click to toggle source
# File lib/knife-container/chef_runner.rb, line 65 def ohai return @ohai if @ohai @ohai = Ohai::System.new @ohai.all_plugins(["platform", "platform_version"]) @ohai end
policy()
click to toggle source
# File lib/knife-container/chef_runner.rb, line 43 def policy return @policy_builder if @policy_builder @policy_builder = Chef::PolicyBuilder::ExpandNodeObject.new("knife_container", ohai.data, {}, nil, formatter) @policy_builder.load_node @policy_builder.build_node @policy_builder.node.run_list(*run_list) @policy_builder.expand_run_list @policy_builder end
run_context()
click to toggle source
# File lib/knife-container/chef_runner.rb, line 39 def run_context @run_context ||= policy.setup_run_context end
stderr()
click to toggle source
# File lib/knife-container/chef_runner.rb, line 77 def stderr $stderr end
stdout()
click to toggle source
# File lib/knife-container/chef_runner.rb, line 73 def stdout $stdout end