shipit-conditional

0.0.3 • Public • Published

shipit-conditional

License: MIT

Restrict certain tasks to certain servers

You may have situations where you only want to deploy to servers matching certain criteria. For example, you may have changed some aspect of how the web role works, but don’t want to trigger a deployment to your database servers.

originally inspired by Capistrano

**** Currently this requires shipit-bastion as well ***

The methods needed in the ssh pool are part of ssh-proxy-pool. Currently that means you need to include shipit-bastion before this plugin to use it.

Features

The server configuration in shipit will take an object.

  servers: [
        {
          user: "be",
          host: "www.brokerageengine.com",
          roles: ["app", "db"]
        }
      ]

By setting these flags you can define a method like following to be true if the server is a dbServer

(connection) =>connection.dbServer === true

The plugin adds

  • shipit.remoteWithCondition
  • shipit.remoteCopyWithCondition
  • shipit.copyToRemoteWithCondition
  • shipit.copyFromRemoteWithCondition

Each of them takes a condition function as the first argument

shipit.remoteWithCondition((condition => (connection.dbServer === true ), "pwd"))
shipit.copyToRemoteWithCondition((condition => (connection.appServer === true ), "/tmp/local.txt", "/tmp/remote.txt"))
const isRole = ( role) =>  (connection) => connection.options &&
    connection.options.remote &&
    connection.options.remote.roles &&
    connection.options.remote.roles.includes(role)
  const isAppServer = isRole("app")
  const isDBServer = isRole("db")
   
  
 
  shipit.task("pwd",async  function() {
    //Gets pwd for all app servers
   const result = await shipit.remoteWithCondition(isAppServer, "pwd")
   //Gets the /tmp only for the db server
   const result2 = await shipit.remoteWithCondition(isDBServer, "ls -l /tmp")
  });
};

License

MIT © 2019 Brokerage Engine, Inc

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.3
    6
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.3
    6
  • 0.0.2
    0
  • 0.0.1
    0

Package Sidebar

Install

npm i shipit-conditional

Weekly Downloads

6

Version

0.0.3

License

MIT

Unpacked Size

13 kB

Total Files

6

Last publish

Collaborators

  • delmendo
  • brokerageengine