Class: ChefDK::ChefRunner
- Inherits:
-
Object
- Object
- ChefDK::ChefRunner
- Defined in:
- lib/chef-dk/chef_runner.rb
Overview
An adapter to chef’s APIs to kick off a chef-client run.
Instance Attribute Summary collapse
-
#cookbook_path ⇒ Object
readonly
Returns the value of attribute cookbook_path.
-
#run_list ⇒ Object
readonly
Returns the value of attribute run_list.
Instance Method Summary collapse
- #configure ⇒ Object
- #converge ⇒ Object
- #formatter ⇒ Object
-
#initialize(cookbook_path, run_list) ⇒ ChefRunner
constructor
A new instance of ChefRunner.
- #ohai ⇒ Object
- #policy ⇒ Object
- #run_context ⇒ Object
- #stderr ⇒ Object
- #stdout ⇒ Object
Constructor Details
#initialize(cookbook_path, run_list) ⇒ ChefRunner
Returns a new instance of ChefRunner.
27 28 29 30 31 32 |
# File 'lib/chef-dk/chef_runner.rb', line 27 def initialize(cookbook_path, run_list) @cookbook_path = cookbook_path @run_list = run_list @formatter = nil @ohai = nil end |
Instance Attribute Details
#cookbook_path ⇒ Object (readonly)
Returns the value of attribute cookbook_path.
24 25 26 |
# File 'lib/chef-dk/chef_runner.rb', line 24 def cookbook_path @cookbook_path end |
#run_list ⇒ Object (readonly)
Returns the value of attribute run_list.
25 26 27 |
# File 'lib/chef-dk/chef_runner.rb', line 25 def run_list @run_list end |
Instance Method Details
#configure ⇒ Object
58 59 60 61 62 63 |
# File 'lib/chef-dk/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 ⇒ Object
34 35 36 37 |
# File 'lib/chef-dk/chef_runner.rb', line 34 def converge configure Chef::Runner.new(run_context).converge end |
#formatter ⇒ Object
54 55 56 |
# File 'lib/chef-dk/chef_runner.rb', line 54 def formatter @formatter ||= Chef::Formatters.new(:doc, stdout, stderr) end |
#ohai ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/chef-dk/chef_runner.rb', line 65 def ohai return @ohai if @ohai @ohai = Ohai::System.new @ohai.all_plugins(["platform", "platform_version"]) @ohai end |
#policy ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/chef-dk/chef_runner.rb', line 43 def policy return @policy_builder if @policy_builder @policy_builder = Chef::PolicyBuilder::ExpandNodeObject.new("chef-dk", ohai.data, {}, nil, formatter) @policy_builder.load_node @policy_builder.build_node @policy_builder.node.run_list(*run_list) @policy_builder. @policy_builder end |
#run_context ⇒ Object
39 40 41 |
# File 'lib/chef-dk/chef_runner.rb', line 39 def run_context @run_context ||= policy.setup_run_context end |
#stderr ⇒ Object
77 78 79 |
# File 'lib/chef-dk/chef_runner.rb', line 77 def stderr $stderr end |
#stdout ⇒ Object
73 74 75 |
# File 'lib/chef-dk/chef_runner.rb', line 73 def stdout $stdout end |