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

deploy-bot

v0.0.5

Published

A simple api for an **agent less** DevOps infrastructure provisionning bot.

Downloads

9

Readme

Deploy Bot

A simple api for an agent less DevOps infrastructure provisionning bot.

Why Node.js ?

1- Node.js likes I/O !! provisionning is all about input and ouput.

2- Lets handle multiple long processes and concurencial access easily.

3- promisses and events are perfect for dependencies and notifications

Command line API

Configure servers hosts

./deploy-bot.json or /etc/deploy-bot.json

{
    "host": {
        "host": "host.lan",
        "username": "user",
        "privateKey": "/home/user/.ssh/id_rsa"
    }
}

then run tasks:

deploy-bot -r uptime host

Programatic API

Connect

Shell = require('deploy-bot/shell');

var shell = new Shell();

shell.connect('host', function (shell) {
    console.log(shell.banner);
    shell.disconnect();
    process.exit();
});

Install

shell.connect('host', function () {
    return [
        shell.install('yum', ['nodejs', 'mongodb']),
        shell.install('gem', 'foreman')
    ]
}).all().done(function () {
    shell.disconnect();
    process.exit();
});

Configure

shell.connect('host', function () {

    return [
        shell.install('yum', 'mongodb'),
        shell.user({ // not yet implemented
            name: 'appuser',
            home: '/var/lib/app',
            group: 'users'
        }),
        shell.file('/etc/logrotate.d/mongodb', {
            template: 'mongodb/logrotate'
        }),
        shell.file('/etc/mongod.conf', {
            template: 'mongodb/conf'
        })
    ];
}).all().then(function () {
    shell.disconnect();
    process.exit();
});

Script

var bot = require('deploy-bot');

bot.registerTask('mytask', function (shell) {
    // do stuff here
});

shell.connect('host', function () {
    return shell.run('mytask'); // execute task
});

or

deploy-bot -r mytask host

Roadmap

  • Testable
  • Migrable, profile version
  • Profiles: aptitude, pacman
  • simple cmd interface
  • simple web gui
  • Hubot adapter
  • host "state" object attribute in host config
  • host "base" attribute for merge target host "state" in host config

Examples

Shell = require('deploy-bot/shell');

var cwd = '/home/user/myproject';

var shell = new Shell();
shell.connect('host', function () {
    return [
        shell.exec('mkdir -p ' + cwd + '/var/log/'),
        shell.exec('git clone [email protected]:you/myproject ' + cwd)
    ]
}).all().then(function () {
    return shell.exec('make install', cwd);
}).then(function () {
    return shell.exec(cwd + 'myproject/bin/run');

}).finally(function () {
    shell.disconnect();
}).fail(function (error) {
    console.error(error.stack || error);
    process.exit(1);
}).done(function () {
    process.exit();
});
shell.connect('host', function (shell) {
    return shell.install('nginx', 'postgres');
}).then(function () {
    return [
        shell.file.envFile('/home/user/env', {
            DB_HOST: 'localhost',
            DB_USER: 'user',
            EVIRONMENENT: 'staging'
        }),
        shell.file.addline('/home/user/.bashrc', 'source ~/env'),
        shell.file.upstart('/etc/init/myproject.conf', {
            script: '/bin/myproject run',
        })
    ];
}).all().then(function () {
    exec('initctl start myproject');
}).finally(function () {
    shell.disconnect();
}).fail(function (error) {
    console.error(error.stack || error);
}).done(function () {
    process.exit();
});
bot.reguisterTask('mongo-server-install', function(shell) {
    return Q.all([
        shell.install('yum', ['mongo', 'mongo-server']),
        shell.file.templateFile('/etc/mongod.conf')
    ]).then(function () {
        return shell.sudo('mongod -f /etc/mongod.conf');
    })
});

bot.reguisterTask('mongo-server-restart', function(shell) {
    /* ... */
});