Skip to content

An exit in parallel execution exits from all hosts #384

Open

Description

@spurnaye

I am using sshkit for parallel execution of commands on several servers. If there is an exit on one of the servers, then the exception is raised and execution on all the servers stops.
As per the my requirements only that host should be skipped continuing other hosts. Can this be achieved with the current code?

Here is an example code

require 'sshkit'
require 'sshkit/dsl'
include SSHKit::DSL

hosts = ['user1@example.com', 'user2@example2.com', 'user3@example3.com']

on hosts, in: :parallel do |host|
	execute './script.sh'
	execute './script_with_exit.sh'
end

Activity

  1. mattbrictson commented on Dec 27, 2016

    @mattbrictson
    Member

    Hi, thanks for the question. You should also check on Stack Overflow to see if you get more answers there.

    The requirement you describe is not possible with the current execution model of SSHKit, at least out of the box. You might be able to plug in your own custom runner to do this.

    In other words, instead of this:

    in: :parallel
    

    You could write this:

    in: ParallelIgnoringErrors
    

    And define the runner as follows:

    class ParallelIgnoringErrors < SSHKit::Runner::Abstract
      def execute
        # your custom execution logic goes here
      end
    end

    If you get it to work, let us know, and we can discuss whether this belongs in SSHKit and/or something that should be called out in the docs.

  2. leehambley commented on Dec 27, 2016

    @leehambley
    Member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions