Skip to content

Assign roles to servers and execute commands on sets of servers with specific roles

Notifications You must be signed in to change notification settings

Azael05x/shipit-roles

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

shipit-roles

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

shipitjs/shipit#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

About

Assign roles to servers and execute commands on sets of servers with specific roles

Resources

Stars

Watchers

Forks

Packages

No packages published