GithubHelp home page GithubHelp logo

samis / babushka Goto Github PK

View Code? Open in Web Editor NEW

This project forked from benhoskings/babushka

0.0 2.0 0.0 5.62 MB

Test-driven sysadmin.

Home Page: http://babushka.me

License: Other

Ruby 99.85% HTML 0.08% Shell 0.06%

babushka's Introduction

What

Babushka is a humble tool for automating computing chores. For each dependency (dep) of the job to do, a test, and the code to make that test pass -- test-driven sysadmin.

dep 'on git branch', :branch do
  met? {
    current_branch = shell('git branch').split("\n").collapse(/^\* /).first
    log "Currently on #{current_branch}."
    current_branch == branch
  }
  meet {
    log_shell("Checking out #{branch}", 'git', 'checkout', branch)
  }
end

That's an expository dep that can achieve the modest goal of being on the correct git branch. Notice the parameter denoted by the :branch symbol, and the two DSL words met? and meet: there's a clear separation of test (is the dependency met?) and code (meet the dependency).

Running this dep when a branch change is required shows how babushka does its work in blocks of met/meet/met: a failing test, an action blindly taken, and then the same test again, hopefully passing now as a result.

$ bin/babushka.rb 'on git branch' branch=stable
on git branch {
  Currently on master.
  meet {
    Checking out stable... done.
  }
  Currently on stable.
} ✓ on git branch

If we're already on the right branch, though, the initial test is already passing, and so there's no work to do.

$ bin/babushka.rb 'on git branch' branch=stable
on git branch {
  Currently on stable.
} ✓ on git branch

That's all very well for one isolated task. To achieve something bigger, tasks have to trigger other ones, which is where the third DSL word requires comes in.

dep 'on git branch', :branch do
  requires 'git'
  # ...

All the deps listed as requirements of this one have to succeed before this one is even attempted. That reflects reality: asking if we're on the right git branch doesn't even make sense if git isn't installed.

$ bin/babushka.rb 'on git branch' branch=stable
on git branch {
  git {
    'git' runs from /usr/bin.
    ✓ git is 2.3.8, which is >= 1.6.
  } ✓ git
  Currently on stable.
} ✓ on git branch

There are other things to learn about, like dep templates, dep sources, and the few remaining words in babushka's DSL, but the above is the nut of it. If you string a few dozen deps like this one together, you can provision a server from scratch, or do anything else you like.

There is much more detailed documentation on the website, along with per-method documentation which can be viewed here.

Installing

Babushka is most easily installed using babushka.me/up, a shell script that installs babushka via git (and its dependencies, ruby and git, via your system's package manager if required). It's safe to run on existing systems, and intended to be used as the first shell command on a new system too. You can install babushka this way using curl or wget:

sh -c "`curl https://babushka.me/up`"

If you'd rather install manually, all you need to do is clone the git repo (or extract an archive of it), and if you like, link bin/babushka.rb into your path as 'babushka'.

Check the install documentation, for the full details on customising the installation, including locking to specific versions and installing from forks using babushka.me/up.

Supported systems

Babushka itself should run on any Unix; there's nothing in the core of babushka that requires anything other than unix, ruby, and git.

I develop babushka against OS X and Ubuntu, so homebrew and apt are the best-supported package managers. There is also some yum (RedHat/Fedora/CentOS) and pacman (Arch) support, thanks to others' contributions. On other systems, specific operations (like installing a package using that system's package manager) will fail with an error message, but otherwise babushka should run fine. In any case, patches are most welcome.

Acknowledgements

Babushka takes advantage of these ruby libraries:

Thanks very much to everyone who's contributed to babushka, whether by submitting patches, discussing design ideas with me, testing, or just giving their feedback.

Rather than a list of contributors here, which inevitably falls out of date, check the contributors page. For other contributions, version-bumping commits always detail what changed and who helped out.

License

Babushka is licensed under the three-clause BSD license, except for lib/levenshtein/levenshtein.rb, which is licensed under the MIT license.

The BSD license can be found in full in the LICENSE file, and the MIT license can be found at the top of lib/levenshtein/levenshtein.rb.

babushka's People

Contributors

benhoskings avatar richo avatar dgoodlad avatar bearded avatar val avatar geekylucas avatar saaji avatar schnittchen avatar robwarm avatar aussiegeek avatar timriley avatar pda avatar pat avatar osseta avatar bjeanes avatar brentsnook avatar mirsal avatar sporkd avatar ryandoyle avatar tamird avatar ecin avatar wlangstroth avatar reentim avatar quad avatar saulius avatar samis avatar samertm avatar radar avatar jwark avatar santouras avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.