npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

grunt-ssh-multi-exec

v4.2.4

Published

Execute a set of SSH commands against multiple boxes

Downloads

255

Readme

#grunt-ssh-multi-exec

Execute a set of SSH commands against multiple boxes

Build Status Dependency Status NPM version

NPM

Getting Started

This plugin requires Grunt 0.4.x

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm i grunt-ssh-multi-exec --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-ssh-multi-exec');

Overview

In your project's Gruntfile, add a section named grunt-ssh-multi-exec to the data object passed into grunt.initConfig().

grunt.initConfig({
  'ssh-multi-exec': {
    echo: {
      hosts: ['192.168.1.64:22', '192.168.1.65:22'],
      username: 'user',
      password: '********',
      commands: [
        {
          input: 'echo 1'
        },
        {
          input: 'echo 2'
        }
      ]
    }
  }
});

Authentication Options

Password

grunt.initConfig({
  'ssh-multi-exec': {
    echo: {
      hosts: ['127.0.0.1:22'],
      username: 'user',
      password: '********',
      commands: [
        {
          input: 'echo 1'
        }
      ]
    }
  }
});

Private Key

grunt.initConfig({
  'ssh-multi-exec': {
    echo: {
      hosts: ['127.0.0.1:22'],
      username: 'user',
      privateKey: '/path/to/private/key',
      passphrase: 'passphrase', // optional
      commands: [
        {
          input: 'echo 1'
        }
      ]
    }
  }
});

Additional Options

Limited Parallelism

By default, this module will execute commands against all specified hosts all at once. Setting maxDegreeOfParallelism will split available hosts into multiple batches; each batch no greater than the specified number. In this example, hosts will be split into two batches with two hosts per batch:

grunt.initConfig({
  'ssh-multi-exec': {
    echo: {
      hosts: ['192.168.1.64:22', '192.168.1.65:22', '192.168.1.66:22', '192.168.1.67:22'],
      maxDegreeOfParallelism: 2
      username: 'user',
      password: '********',
      commands: [
        {
          input: 'echo 1'
        }
      ]
    }
  }
});

Forced Execution

In some scenarios it is useful to be able to continue execution of a command set despite failures. A boolean force flag applied at command level allows you to mark individual commands for forced execution. In this example, second command will execute even though first had failed:

grunt.initConfig({
  'ssh-multi-exec': {
    echo: {
      hosts: ['127.0.0.1:22'],
      username: 'user',
      password: '********',
      commands: [
        {
          input: '/etc/init.d/my_svc stop',
          force: true
        },
        {
          input: 'rm -rf /var/www/my_svc'
        }
      ]
    }
  }
});

Success and Error Handlers

Optional success and error handlers can be defined at individual command level to handle additional tasks such as logging or cleanup:

grunt.initConfig({
  'ssh-multi-exec': {
    echo: {
      hosts: ['127.0.0.1:22'],
      username: 'user',
      password: '********',
      commands: [
        {
          input: 'touch me',
          success: function(data, context, done) {
            console.log(data);
            done();
          },
          error: function(err, context, done) {
            console.log(err);
            done();
          }
        }
      ]
    }
  }
});

Release History

  • v4.2.4 (2016-04-07)
    • updated dependencies
  • v4.2.3 (2015-07-17)
    • updated dependencies
  • v4.2.0 (2015-03-23)
    • updated dependencies
  • v4.1.0 (2015-01-20)
    • added passphrase option
  • v4.0.4 (2014-11-26)
    • fixed error reporting
  • v4.0.3 (2014-08-31)
    • fixed error noop behaviour
  • v4.0.2 (2014-08-31)
    • fixed error noop behaviour
  • v4.0.1 (2014-08-05)
    • fixed noop behaviour
  • v4.0.0 (2014-08-05)
    • made callback behaviour more deterministic (to allow long-running operations to block further ssh command execution)
    • updated dependencies
    • updated to ssh2 v0.3.4 (hopefully, this will put an end to internal ssh2 errors we've been seeing)
  • v3.1.1 (2014-03-19)
    • fixed a force option bug that was preventing execution of subsequent commands in some scenarios
  • v3.1.0 (2014-03-18)
    • added force option
  • v3.0.0 (2014-03-14)
    • Breaking change! - remove mode option
    • added maxDegreeOfParallelism option
  • v2.4.0 (2014-03-14)
    • added option to execute command sets sequentially
  • v2.3.0 (2014-03-13)
    • added context to success and error callbacks
  • v2.2.0 (2014-03-12)
    • fixed dependency versioning
  • v2.1.0 (2014-03-12)
    • fixed bug that was preventing execution of commands that do not return a response
  • v2.0.0 (2014-03-11)
    • Breaking change! - task renamed to ssh-multi-exec
  • v1.0.0 (2014-03-10)
    • Breaking change! - see port configuration
    • added support for executing commands against multiple boxes
    • added log message batching (clean, coherent logs)
  • v0.1.2 (2014-03-10)
    • added password-based authentication
  • v0.1.0 (2014-03-07)
    • initial release