Class: ChefSpec::ServerRunner
- Inherits:
-
SoloRunner
- Object
- SoloRunner
- ChefSpec::ServerRunner
- Includes:
- ServerMethods
- Defined in:
- lib/chefspec/server_runner.rb,
lib/chefspec/chef_backwards_compat.rb
Instance Attribute Summary
Attributes inherited from SoloRunner
Instance Method Summary collapse
- #converge(*recipe_names) ⇒ Object
-
#cookbook_uploader_for(loader) ⇒ Object
The method airty for the Chef::CookbookUploader used to accept a list of cookbook paths.
-
#initialize(options = {}) {|node, _self| ... } ⇒ ServerRunner
constructor
A new instance of ServerRunner.
-
#upload_cookbooks! ⇒ Object
Upload the cookbooks to the Chef Server.
Methods included from ServerMethods
#client, #clients, #create_client, #create_data_bag, #create_environment, #create_node, #create_role, #data, #data_bag, entity, #environment, #environments, #get, #has_client?, #has_data_bag?, #has_environment?, #has_node?, #has_role?, #load_data, #node, #nodes, #role, #roles, #server
Methods inherited from SoloRunner
#compiling?, converge, #dry_run?, #find_resource, #find_resources, #inspect, #method_missing, #node, #resource_collection, #respond_to_missing?, #step_into?, #to_s
Methods included from Normalize
Constructor Details
#initialize(options = {}) {|node, _self| ... } ⇒ ServerRunner
Returns a new instance of ServerRunner.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/chefspec/server_runner.rb', line 14 def initialize( = {}) # Unlike the SoloRunner, the file_cache_path needs to remain consistent # for every Chef run or else the Chef client tries to loads the same # cookbook multiple times and will encounter deprecated logic when # creating LWRPs. It also slows down the entire process. [:file_cache_path] ||= RSpec.configuration.file_cache_path || ChefSpec::FileCachePathProxy.instance.file_cache_path # Call super, but do not pass in the block because we want to customize # our yielding. super(, &nil) Chef::Config[:client_key] = client_key Chef::Config[:client_name] = 'chefspec' Chef::Config[:node_name] = 'chefspec' Chef::Config[:solo] = false Chef::Config[:solo_legacy_mode] = false Chef::Config[:chef_server_url] = server.url Chef::Config[:http_retry_count] = 0 # Start the Chef Zero instance in the background server.start_background at_exit { server.stop if server.running? } # Unlike the SoloRunner, the node AND server object are yielded for # customization yield node, self if block_given? end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class ChefSpec::SoloRunner
Instance Method Details
#converge(*recipe_names) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/chefspec/server_runner.rb', line 66 def converge(*recipe_names) upload_cookbooks! super do yield if block_given? # Save the node back to the server for searching purposes client.register node.save end end |
#cookbook_uploader_for(loader) ⇒ Object
The method airty for the Chef::CookbookUploader used to accept a list of cookbook paths. This restores that behavior.
61 62 63 |
# File 'lib/chefspec/server_runner.rb', line 61 def cookbook_uploader_for(loader) Chef::CookbookUploader.new(loader.cookbooks) end |