0.1.1 • Published 4 years ago

gym v0.1.1

Weekly downloads
23
License
ISC
Repository
-
Last release
4 years ago

gym

gym helps you automate the process of setting up a computer or server efficiently and consistently.

Introduction

Setting up a computer or server usually consists of many steps. In Ubuntu for example, you might want to add some PPAs, install some packages with apt-get, and modify some configuration files. Repeating these steps manually for every computer or server you set up is not only time-consuming, but also error-prone. gym helps you automate these tasks.

Features

  • "workouts" are defined declaratively, which means you can define tasks in any order, and they will be aggregated and executed in the order defined in the flow.
  • "machines" return promises that can be executed simultaneously or chained however you like, giving you full control over program flow.

Getting started

A "gymfile" is just a JavaScript file that is passed to node. For this reason, you at least need to have node installed in order to use gym.

gymfiles contain three sections: machines, workout and flow.

machines

The machines section defines a plain object machines that contains a collection of machines. A machine is a plugin that performs a single operation on a collection of "motions". For example, the apt machine (gym-apt on npm) installs packages on Ubuntu using apt, where each motion is a string whose value is the name of the package to be installed.

workout

The workout section defines a plain object workout that contains a collection of exercises. An exercise is a collection of motions, where each motion is mapped to the name of the machine that the motion should be passed to.

flow

The flow section defines the order in which the machines should be executed after gym has been set up with all the machines, all of the motions in the workout have been assigned to each machine. Machine methods return Bluebird promises that can be used directly, or consumed by any A+/Promises library.

Sample gymfile.js

let gym = require("gym");
let sudo = require("gym-sudo");
let ppa = require("gym-ppa");
let apt = require("gym-apt");

let machines = {
    sudo: sudo,
    ppa: ppa,
    apt: apt,
};

let workout = {
    nginx: {
        ppa: "ppa:nginx/stable",
        apt: "nginx",
    },
    haproxy: {
        ppa: "ppa:vbernat/haproxy-1.5",
        apt: "haproxy",
    },
};

gym.setup(machines, workout)
    .then(sudo.start)
    .then(ppa.start)
    .then(apt.start)
    .catch(console.error);

Running the gymfile:

npm install gym gym-apt gym-ppa gym-sudo
node gymfile
0.1.1

4 years ago

0.2.2

4 years ago

0.2.1

4 years ago

0.1.0

4 years ago