Class: Kitchen::Provisioner::Shell

Inherits:
Base
  • Object
show all
Defined in:
lib/kitchen/provisioner/shell.rb

Overview

Basic shell provisioner.

Author:

Instance Attribute Summary

Attributes included from Configurable

#instance

Instance Method Summary collapse

Methods inherited from Base

#cleanup_sandbox, #finalize_config!, #initialize, #install_command, #name, #prepare_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_sandboxObject

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:

Examples:

overriding #create_sandbox


class MyProvisioner < Kitchen::Provisioner::Base
  def create_sandbox
    super
    # any further file copies, preparations, etc.
  end
end


41
42
43
44
45
# File 'lib/kitchen/provisioner/shell.rb', line 41

def create_sandbox
  super
  prepare_data
  prepare_script
end

#init_commandString

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.

Returns:

  • (String)

    a command string



48
49
50
51
52
53
# File 'lib/kitchen/provisioner/shell.rb', line 48

def init_command
  data = File.join(config[:root_path], "data")
  cmd = "#{sudo("rm")} -rf #{data} ; mkdir -p #{config[:root_path]}"

  Util.wrap_command(cmd)
end

#run_commandString

Generates a command string which will invoke the main provisioner command on the prepared instance. If no work is required, then nil will be returned.

Returns:

  • (String)

    a command string



56
57
58
59
60
# File 'lib/kitchen/provisioner/shell.rb', line 56

def run_command
  Util.wrap_command(
    sudo(File.join(config[:root_path], File.basename(config[:script])))
  )
end