Class: Kitchen::Provisioner::Shell
- Defined in:
- lib/kitchen/provisioner/shell.rb
Overview
Basic shell provisioner.
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.
-
#run_command ⇒ String
Generates a command string which will invoke the main provisioner command on the prepared instance.
Methods inherited from Base
#call, #cleanup_sandbox, #initialize, #install_command, kitchen_provisioner_api_version, #prepare_command, #sandbox_path
Methods included from Logging
#banner, #debug, #error, #fatal, #info, #warn
Methods included from Configurable
#[], #bourne_shell?, #calculate_path, #config_keys, #diagnose, #diagnose_plugin, #finalize_config!, included, #name, #powershell_shell?, #remote_path_join, #unix_os?, #verify_dependencies, #windows_os?
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:
47 48 49 50 51 |
# File 'lib/kitchen/provisioner/shell.rb', line 47 def create_sandbox super prepare_data prepare_script 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.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/kitchen/provisioner/shell.rb', line 54 def init_command root = config[:root_path] data = remote_path_join(root, "data") code = if powershell_shell? Util.outdent!(<<-POWERSHELL) if (Test-Path "#{data}") { Remove-Item "#{data}" -Recurse -Force } if (-Not (Test-Path "#{root}")) { New-Item "#{root}" -ItemType directory | Out-Null } POWERSHELL else "#{sudo("rm")} -rf #{data} ; mkdir -p #{root}" end wrap_shell_code(code) end |
#run_command ⇒ String
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.
75 76 77 78 79 80 81 82 83 |
# File 'lib/kitchen/provisioner/shell.rb', line 75 def run_command script = remote_path_join( config[:root_path], File.basename(config[:script]) ) code = powershell_shell? ? %{& "#{script}"} : sudo(script) prefix_command(wrap_shell_code(code)) end |