shipit-roles

1.0.3 • Public • Published

shipit-roles

The shipit-roles module lets addresses the requirement outlined in this github issue:

https://github.com/shipitjs/shipit/issues/122

If you have a fleet of servers and that are configured in a specialized manner per role, shipit-roles lets you address them as a group during the deploy process. This allows you to restart the web server on only hosts that actually have a web server running or clear the cache on servers that actually keep a cache.

Installation

Install with npm or yarn:

npm install --save shipit-roles

Configuration

When you define your servers, use the following format:

...
servers: [
  {
    user: 'root',
    host: 'app1.example.com',
    role: 'appserver'
  },{
    user: 'root',
    host: 'app2.example.com',
    role: 'appserver'
  },{
    user: 'root',
    host: 'worker1.example.com',
    role: 'worker'
  },{
    user: 'root',
    host: 'worker2.example.com',
    role: 'worker'
  },{
    user: 'root',
    host: 'db1.example.com',
    role: 'database'
  }
]
...

You can have as many roles as you want and they can be identified with whatever word you choose. appserver, worker, and database are merely provided as examples.

Usage

shipit-roles monkey patches the remote() and remoteCopy() functions to accept a role option. If no role is provided, then it defaults to all servers. If a role is specified, then the command will only address the servers with that role.

const roles = require('shipit-roles')
 
module.exports = function (shipit) {
 
  roles(shipit)
 
  shipit.task('deploy:restart_appservers', () => {
    return shipit.remote('service nginx restart', { role: 'appserver' })
  })
 
  shipit.task('deploy:restart_workers', () => {
    return shipit.remote('service worker restart', { role: 'worker' })
  })
 
}

Author & Credits

Shipit-roles was written by Greg Kops and is based upon his work with Think Topography and The Cornell Cooperative Extension of Tompkins County

Dependencies (3)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i shipit-roles

    Weekly Downloads

    2

    Version

    1.0.3

    License

    ISC

    Unpacked Size

    5.01 kB

    Total Files

    3

    Last publish

    Collaborators

    • ccetc
    • mahaplatform
    • mochini