class Kitchen::LifecycleHook::Remote

Public Instance Methods

run() click to toggle source

Execute a specific remote command hook.

@return [void]

# File lib/kitchen/lifecycle_hook/remote.rb, line 10
def run
  # Check if we're in a state that makes sense to even try.
  unless instance.last_action
    if hook[:skippable]
      # Just not even trying.
      return
    else
      raise UserError, "Cannot use remote lifecycle hooks during phases when the instance is not available"
    end
  end

  begin
    conn = instance.transport.connection(state_file.read)
    conn.execute(command)
  rescue Kitchen::Transport::SshFailed => e
    return if hook[:skippable] && e.message.match(/^SSH exited \(\d{1,3}\) for command: \[.+\]$/)

    raise
  end
end

Private Instance Methods

command() click to toggle source

return [String]

# File lib/kitchen/lifecycle_hook/remote.rb, line 34
def command
  hook.fetch(:remote)
end