A rather direct provisioning and deployment system in ruby, bash over ssh, and rsync.
Ruby HTML CSS Shell
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin
examples
lib
rdoc_css
sync
test
.gitignore
.gt-config
.travis.yml
Gemfile
Gemfile.lock
History.rdoc
Manifest.txt
README.rdoc
Rakefile
syncwrap.gemspec

README.rdoc

SyncWrap

Description

A rather direct provisioning and deployment system in ruby, bash over ssh, and rsync. SyncWrap is a refreshingly straightforward, DSL-free non-framework with no central server or repository requirements. The “magic”, if any, lies in the elegant component model, the shell command queue, and a few powerful methods like rput (augmented rsync).

Features

  • Default Thread-per-host parallel operation, with synchronized block/live console output for debugging.

  • Multi-line shell support (often via here-document), command queue, and composition support in SyncWrap::Component#sh for more natural script embedding. You'll know you are provisioning with bash, in all its syntactic glory.

  • SyncWrap::Component#rput wraps rsync, with support for multiple source roots, transparent ERB templates, and target file owner/permissions control. Returns the file change status allowing reactive scripting (i.e. restart daemon since config has changed.)

  • Linux distro differences are factored out into distro-specific components with utility methods exposed in host context.

  • SyncWrap::AmazonEC2 provider with host profiles: create and provision hosts in a single step.

  • Independent of (but easily integrated into) rake

  • Depends only on ruby 1.9+ stdlib Open3 for interaction with bash, ssh and rsync. Also works on jruby 1.7.x, 9.x and recent rubinuous (see Travis CI variants).

Synopsis

Simplest example. Place the following in a sync.rb file:

class Greeter < SyncWrap::Component
  def install
    say_it
  end

  def say_it
    sh <<-SH
      echo "Hello from #{host.name}"
    SH
  end
end

host 'localhost', Greeter.new

Try it via the command line:

gem install syncwrap
syncwrap --help
syncwrap -f ./sync.rb --list  # -f default; list
syncwrap                      # Run it
syncwrap -v                   # Run it with full verbose output
syncwrap -v Greeter.say_it    # Without Greeter#install default

Output from syncwrap -v (minus the terminal color):

== localhost #<Module:0x00000001e95678>::Greeter#install: enqueue
<-- sh localhost (-v coalesce live)
echo "Hello from localhost"
Hello from localhost
--> Exit 0 (success)

See more elaborate examples, including ec2 provider support, in the examples directory and LAYOUT.

Components

Component hierarchy implementing SyncWrap::Distro, for common methods like dist_install and other distribution-specific behaviors:

  • SyncWrap::Arch (limited support)

  • SyncWrap::Debian

    • SyncWrap::Ubuntu

  • SyncWrap::RHEL

    • SyncWrap::CentOS

    • SyncWrap::AmazonLinux

Components implementing #install:

  • SyncWrap::MDRaid, SyncWrap::LVMCache - Software raid, lvm volumes, lvm cache, filesystems, mounts

  • SyncWrap::Network and SyncWrap::EtcHosts - hostname, static names, resolver config

  • SyncWrap::Users - developer accounts, home directory files (incl. ssh keys), sudoers access

  • SyncWrap::RunUser - a user for running deployed daemons, jobs, in var directories.

  • SyncWrap::PostgreSQL

  • SyncWrap::OpenJDK or SyncWrap::CommercialJDK

  • SyncWrap::JRubyVM and/or SyncWrap::CRubyVM (MRI, from source)

  • SyncWrap::BundlerGem, SyncWrap::RakeGem, SyncWrap::TarpitGem - base (pre-bundle) Rubygems

  • SyncWrap::SourceTree, SyncWrap::Bundle

  • SyncWrap::ChangeGuard

  • SyncWrap::Puma

  • SyncWrap::Iyyov - job scheduler and process monitor with utilities for SyncWrap::IyyovDaemon deployment.

  • SyncWrap::Geminabox - private gem server

  • SyncWrap::Qpid - AMQP broker

Component wish list

The above only represents my more recent project needs. Pull requests to add, for example, the following would be well received:

  • Rails (based on SourceTree, Bundle and ideally without per-host asset compile)

  • Nginx

  • Mongo

  • Redis

SyncWrap makes it reasonable to implement any of the above yourself.

License

Copyright © 2011-2017 David Kellum

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at:

www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.