• Stars
    star
    310
  • Rank 129,959 (Top 3 %)
  • Language
    Go
  • Created over 9 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Minimalist provisioning tool written in Go.

Stack

Minimalist provisioning tool written in Go.

golang provisioning tool stack

# Node
curl -L# http://nodejs.org/dist/v0.10.30/node-v0.10.30-darwin-x64.tar.gz | tar -zx --strip 1 -C /usr/local

# Node version manager
npm install -g n

# Node releases
n 0.8.28
n 0.10.30
n 0.11.13

Installation

Via go-get:

$ go get github.com/visionmedia/stack/cmd/stack

Via binaries:

soonnnnn

Usage

  Usage:
    stack [--list] [--no-color] [--verbose] <file>
    stack -h | --help
    stack --version

  Options:
    -C, --no-color   output with color disabled
    -l, --list       output commit status
    -V, --verbose    output command stdio
    -h, --help       output help information
    -v, --version    output version

About

There are a lot of great provisioning tools out there, but as far as I know most of them are part of much larger systems, use unfamiliar DSLs, or rely on the presence of an interpreter for scripting languages such as Ruby or Python.

I'm not suggesting this tool is better than any existing solution but I really wanted something that looked and behaved like a regular shell script. Also since it's written in Go it's very simple to curl the binary on to any existing system.

The choice of using shell commands makes this tool less declarative than some of the alternatives, however I think it's a good fit for the goal of being a minimalistic solution.

How it works

Stack behaves like shell scripts with set -e, as it will exit on failure. Unlike shell scripts a commit log is used in order to prevent re-execution of previous commands.

The log is held at ~/.provision.log (by default), this file keeps track of commands which have already completed. Once a command is run and successfully exits, it is considered complete, at which time the SHA1 of the command is written to this file. Subsequent runs will see the SHA and ignore the command.

The commit log is shared between any number of provision files, this means the same command run in a different provisioning script will no-op if it has already been successfully run.

If a command line is modified it will result in a different hash, thus it will be re-run.

This gif illustrates how exiting after the initial "commit" will cause it to be ignored the second time around:

stack commits

Syntax

The syntax has two flavours, the shell-like syntax, and the canonical version which pkg/provisioner consumes. For example here is the shell version of a small node.js provisioning script:

# Node
curl -L# http://nodejs.org/dist/v0.10.30/node-v0.10.30-darwin-x64.tar.gz | tar -zx --strip 1 -C /usr/local

# Node version manager
npm install -g n

# Node releases
n 0.8.28
n 0.10.30
n 0.11.13

Here's the same script after it's rewritten to the canonical syntax:

LOG Node
RUN curl -L# http://nodejs.org/dist/v0.10.30/node-v0.10.30-darwin-x64.tar.gz | tar -zx --strip 1 -C /usr/local

LOG Node version manager
RUN npm install -g n

LOG Node releases
RUN n 0.8.28
RUN n 0.10.30
RUN n 0.11.13

Commands

Currently only a few commands are supported, however more may be added in the future to simplify common processes, provide concurrency, and so on.

Open an issue if there's something you'd like to see!

RUN

RUN <command> executes a command through /bin/sh, so shell features such as globbing, brace expansion and pipelines will work as expected.

If the <command> exits > 0 then commit is a failure and will not be written to the log.

Lines without a command are considered to be RUN lines.

LOG

LOG <message> simply outputs a log message to stdio.

Aliased as #.

INCLUDE

INCLUDE <path> reads the file at <path>, rewrites it and injects it into the location of this command in the pre-processing step.

The include <path> is relative to the CWD.

Aliased as . and source.

Options

--verbose

By default output is suppressed, however --verbose will stream std{err,out}:

stack provisioning verbose

Running tests

All tests:

$ make test

Individual tests:

$ cd pkg/rewriter
$ go test

License

MIT

More Repositories

1

page.js

Micro client-side router inspired by the Express router
JavaScript
7,621
star
2

move.js

CSS3 backed JavaScript animation framework
JavaScript
4,712
star
3

node-progress

Flexible ascii progress bar for nodejs
JavaScript
2,913
star
4

masteringnode

Open source eBook for nodejs - written w/ markdown, outputs to various formats (pdf, mobi, epub, html, etc)
JavaScript
1,834
star
5

express-resource

Resourceful routing for Express
JavaScript
1,414
star
6

uikit

UIKit - modern ui components for the modern web
JavaScript
1,320
star
7

deploy

Minimalistic deployment shell script
Shell
1,148
star
8

screenshot-app

website screenshot service & app - powered by node.js, express, redis, node-canvas, phantomjs and more
JavaScript
850
star
9

expresso

use mocha
JavaScript
760
star
10

bytes.js

node byte string parser
JavaScript
440
star
11

node-jscoverage

jscoverage modified to support SSJS
C++
400
star
12

batch

Simple async batch with concurrency control and progress reporting
JavaScript
318
star
13

express-messages

Express flash notification message rendering
JavaScript
261
star
14

google-search

Ruby - Google Search API
Ruby
258
star
15

express-params

Express param pre-condition functions
JavaScript
146
star
16

stats

JavaScript source statistics with simple API & CLI written with node.js
JavaScript
78
star
17

histogram

JavaScript canvas histogram component
JavaScript
68
star
18

go-debug

Old anti-pattern go-debug thing
Go
56
star
19

minstache

Mini mustache compiling to stand-alone functions
JavaScript
53
star
20

go-hpc

HTTP RPC codec for Gorilla RPC v2.
Go
29
star
21

connect-render

Template Render helper for connect: res.render(view, options).
JavaScript
17
star
22

readme

repos are now at /tj/*
1
star