Babushka


   Richard McGain
       @mcgain
 richardmcgain.com
the name
Babushka in Russian means "mother"

             But. . .

 In Australia, it is the name for
       Russian Nesting Dolls
the installer               .




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

This installs Babushka, ruby and git
(if they are not already installed)
the purpose
   Automates system tasks such as:

● Deploys
● Setting up your dev box
● Other important stuff you don't want
  screwed up
the basics
$ babushka deploy
                    A dependency or "dep"

The command
the concept
dep "dep names can have spaces" do
  met? {
    return true or false
    no side effects
  }
  meet {
    do the actual work here
  }
end
the code
dep "precompile assets" do
  met? {
    File.directory? "public/assets"
  }

  meet {
    `rake assets:precompile`
  }
end
the require
dep "deploy" do
  requires [
    "precompile assets",
    "push to heroku"
  ]
end
the variables                     .




$ babushka push ref=master remote=origin

dep "push", :ref, :remote do
  requires("repo exists").with(remote)
  `git push #{remote} #{ref}:#{ref}`
end
the file
Where does Babushka look for this dep?

./babushka-deps/
~/.babushka-deps/
 /usr/local/bin/babushka/deps/

it looks for all ruby files
recursively.
the github
$ babushka mcgain:deploy

it clones:
github.com/mcgain/babushka-deps

then loads the repo and runs the dep

WARNING: only do this for deps you
trust
the shell
shell "rake annotate"
the shell
shell "[ 1 == 0 ]" do |s|
  if s.result == 1
    math_seems_to_work
  end
end
the stdout
Also stderr!

shell "grep" do |s|
  puts s.stdout #prints nothing
  puts s.stderr #prints helpful error
end
the cd
We can cd

cd "~/.vim/bundle"
shell "git clone gh.co/tpope/vim-repo"

cd "~/.vim/bundle" do
  shell "git clone gh.co/vim/plugin"
end
the git
def rails_repo
  @repo ||= Babushka::GitRepo.new(
    'some-git-repo'
  )
end

rails_repo.repo_shell "git push"
the methods
There are some convenience methods:

  rebasing?
  current_head
  branch!
  checkout!
  reset_hard!
  ahead?
  behind?
the install
dep "colors.npm"
will install the node package colors

but if the name doesn't match

dep 'django.pip' do
 installs 'Django'
 provides 'django-admin.py'
end
the list
.lib for libraries
.bin for binaries
.gem for gems
.py ...
.npm ...
the ruby
dep 'ruby.bin' do
  installs {
    via [:lenny, :hardy, :lucid],
       %w[ruby irb ruby1.8-dev]
    via :apt, %w[ruby ruby1.8-dev]
    via :yum, %w[ruby ruby-irb]
    otherwise 'ruby'
  }
  provides 'ruby >= 1.8.6', 'irb'
end
the versions
dep 'postgres.bin' do
  installs 'postgresql'
  provides 'psql ~> 9.0.0'
end
the integration                     .




Although it is a standalone tool it is
also a library (with / without DSL )

Babushka does not scale, 1 system only

Chef, Capistrano, Vagrant, Puppet all
solve a slightly different problem and
are complementary.
the future
google for:

site:github.com babushka-deps


       Questions?
            Richard McGain
                @mcgain
          richardmcgain.com

Babushka

  • 1.
    Babushka Richard McGain @mcgain richardmcgain.com
  • 2.
    the name Babushka inRussian means "mother" But. . . In Australia, it is the name for Russian Nesting Dolls
  • 3.
    the installer . $ sh -c "`curl https://babushka.me/up`" This installs Babushka, ruby and git (if they are not already installed)
  • 4.
    the purpose Automates system tasks such as: ● Deploys ● Setting up your dev box ● Other important stuff you don't want screwed up
  • 5.
    the basics $ babushkadeploy A dependency or "dep" The command
  • 6.
    the concept dep "depnames can have spaces" do met? { return true or false no side effects } meet { do the actual work here } end
  • 7.
    the code dep "precompileassets" do met? { File.directory? "public/assets" } meet { `rake assets:precompile` } end
  • 8.
    the require dep "deploy"do requires [ "precompile assets", "push to heroku" ] end
  • 9.
    the variables . $ babushka push ref=master remote=origin dep "push", :ref, :remote do requires("repo exists").with(remote) `git push #{remote} #{ref}:#{ref}` end
  • 10.
    the file Where doesBabushka look for this dep? ./babushka-deps/ ~/.babushka-deps/ /usr/local/bin/babushka/deps/ it looks for all ruby files recursively.
  • 11.
    the github $ babushkamcgain:deploy it clones: github.com/mcgain/babushka-deps then loads the repo and runs the dep WARNING: only do this for deps you trust
  • 12.
  • 13.
    the shell shell "[1 == 0 ]" do |s| if s.result == 1 math_seems_to_work end end
  • 14.
    the stdout Also stderr! shell"grep" do |s| puts s.stdout #prints nothing puts s.stderr #prints helpful error end
  • 15.
    the cd We cancd cd "~/.vim/bundle" shell "git clone gh.co/tpope/vim-repo" cd "~/.vim/bundle" do shell "git clone gh.co/vim/plugin" end
  • 16.
    the git def rails_repo @repo ||= Babushka::GitRepo.new( 'some-git-repo' ) end rails_repo.repo_shell "git push"
  • 17.
    the methods There aresome convenience methods: rebasing? current_head branch! checkout! reset_hard! ahead? behind?
  • 18.
    the install dep "colors.npm" willinstall the node package colors but if the name doesn't match dep 'django.pip' do installs 'Django' provides 'django-admin.py' end
  • 19.
    the list .lib forlibraries .bin for binaries .gem for gems .py ... .npm ...
  • 20.
    the ruby dep 'ruby.bin'do installs { via [:lenny, :hardy, :lucid], %w[ruby irb ruby1.8-dev] via :apt, %w[ruby ruby1.8-dev] via :yum, %w[ruby ruby-irb] otherwise 'ruby' } provides 'ruby >= 1.8.6', 'irb' end
  • 21.
    the versions dep 'postgres.bin'do installs 'postgresql' provides 'psql ~> 9.0.0' end
  • 22.
    the integration . Although it is a standalone tool it is also a library (with / without DSL ) Babushka does not scale, 1 system only Chef, Capistrano, Vagrant, Puppet all solve a slightly different problem and are complementary.
  • 23.
    the future google for: site:github.combabushka-deps Questions? Richard McGain @mcgain richardmcgain.com