Class: Kitchen::Provisioner::ChefBase
- Defined in:
- lib/kitchen/provisioner/chef_base.rb
Overview
Common implementation details for Chef-related provisioners.
Instance Attribute Summary
Attributes included from Configurable
Instance Method Summary collapse
-
#create_sandbox ⇒ Object
Creates a temporary directory on the local workstation into which provisioner related files and directories can be copied or created.
-
#init_command ⇒ String
Generates a command string which will perform any data initialization or configuration required after the provisioner software is installed but before the sandbox has been transferred to the instance.
-
#install_command ⇒ String
Generates a command string which will install and configure the provisioner software on an instance.
Methods inherited from Base
#cleanup_sandbox, #finalize_config!, #initialize, #name, #prepare_command, #run_command, #sandbox_path
Methods included from Logging
#banner, #debug, #error, #fatal, #info, #warn
Methods included from Configurable
#[], #calculate_path, #config_keys, #diagnose, #finalize_config!, included
Constructor Details
This class inherits a constructor from Kitchen::Provisioner::Base
Instance Method Details
#create_sandbox ⇒ Object
Creates a temporary directory on the local workstation into which provisioner related files and directories can be copied or created. The contents of this directory will be copied over to the instance before invoking the provisioner's run command. After this method completes, it is expected that the contents of the sandbox is complete and ready for copy to the remote instance.
Note: any subclasses would be well advised to call super first when overriding this method, for example:
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/kitchen/provisioner/chef_base.rb', line 102 def create_sandbox super prepare_json prepare_cache prepare_cookbooks prepare(:data) prepare(:data_bags) prepare(:environments) prepare(:nodes) prepare(:roles) prepare(:clients) prepare( :secret, :type => :file, :dest_name => "encrypted_data_bag_secret", :key_name => :encrypted_data_bag_secret_key_path ) end |
#init_command ⇒ String
Generates a command string which will perform any data initialization
or configuration required after the provisioner software is installed
but before the sandbox has been transferred to the instance. If no work
is required, then nil
will be returned.
93 94 95 96 97 98 99 |
# File 'lib/kitchen/provisioner/chef_base.rb', line 93 def init_command dirs = %w[cookbooks data data_bags environments roles clients]. map { |dir| File.join(config[:root_path], dir) }.join(" ") lines = ["#{sudo("rm")} -rf #{dirs}", "mkdir -p #{config[:root_path]}"] Util.wrap_command(lines.join("\n")) end |
#install_command ⇒ String
Generates a command string which will install and configure the
provisioner software on an instance. If no work is required, then nil
will be returned.
85 86 87 88 89 90 |
# File 'lib/kitchen/provisioner/chef_base.rb', line 85 def install_command return unless config[:require_chef_omnibus] lines = [Util.shell_helpers, chef_shell_helpers, chef_install_function] Util.wrap_command(lines.join("\n")) end |