Class: NodeSpec::Provisioning::Chef
- Inherits:
-
Object
- Object
- NodeSpec::Provisioning::Chef
- Defined in:
- lib/nodespec/provisioning/chef.rb
Constant Summary collapse
- CLIENT_CONFIG_FILENAME =
'chef_client.rb'
- ATTRIBUTES_FILENAME =
'chef_client_attributes.json'
- NODES_DIRNAME =
'chef_nodes'
Instance Method Summary collapse
- #chef_apply_execute(snippet, options = []) ⇒ Object
- #chef_apply_recipe(recipe_file, options = []) ⇒ Object
- #chef_client_config(text) ⇒ Object
- #chef_client_runlist(*args) ⇒ Object
-
#initialize(node) ⇒ Chef
constructor
A new instance of Chef.
- #set_attributes(attributes) ⇒ Object
- #set_cookbook_paths(*paths) ⇒ Object
Constructor Details
#initialize(node) ⇒ Chef
Returns a new instance of Chef.
11 12 13 14 15 |
# File 'lib/nodespec/provisioning/chef.rb', line 11 def initialize(node) @node = node @custom_attributes = {} @configuration_entries = [] end |
Instance Method Details
#chef_apply_execute(snippet, options = []) ⇒ Object
17 18 19 |
# File 'lib/nodespec/provisioning/chef.rb', line 17 def chef_apply_execute(snippet, = []) @node.execute("chef-apply #{.join(' ')} -e #{snippet.shellescape}") end |
#chef_apply_recipe(recipe_file, options = []) ⇒ Object
21 22 23 |
# File 'lib/nodespec/provisioning/chef.rb', line 21 def chef_apply_recipe(recipe_file, = []) @node.execute("chef-apply #{recipe_file.shellescape} #{.join(' ')}") end |
#chef_client_config(text) ⇒ Object
36 37 38 |
# File 'lib/nodespec/provisioning/chef.rb', line 36 def chef_client_config(text) @configuration_entries << text end |
#chef_client_runlist(*args) ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/nodespec/provisioning/chef.rb', line 40 def chef_client_runlist(*args) run_list_items, = [], [] run_list_items << args.take_while {|arg| arg.is_a? String} += args.last if args.last.is_a? Array << configuration_option << attributes_option @node.execute("chef-client -z #{.compact.join(' ')} -o #{run_list_items.join(',').shellescape}") end |
#set_attributes(attributes) ⇒ Object
32 33 34 |
# File 'lib/nodespec/provisioning/chef.rb', line 32 def set_attributes(attributes) @custom_attributes = attributes end |
#set_cookbook_paths(*paths) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/nodespec/provisioning/chef.rb', line 25 def set_cookbook_paths(*paths) unless paths.empty? paths_in_quotes = paths.map {|p| "'#{p}'"} @configuration_entries << %Q(cookbook_path [#{paths_in_quotes.join(",")}]) end end |