Skip to content

A rather direct provisioning and deployment system in ruby, bash over ssh, and rsync.

Notifications You must be signed in to change notification settings

dekellum/syncwrap

Repository files navigation

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::Debian

    • SyncWrap::Ubuntu

  • SyncWrap::RHEL

    • SyncWrap::CentOS

    • SyncWrap::AmazonLinux

  • SyncWrap::Arch (limited)

Non-exhaustive list of 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 — Ruby Bundler installed (source) dependencies

  • SyncWrap::Puma

  • SyncWrap::Rustc — Rust language compiler and tools

  • SyncWrap::Cargo — Rust cargo install

Other utilities:

  • SyncWrap::ChangeGuard — make changes transactional via a remote guard file

  • SyncWrap::TimeChecker (.check) — compare remote host system clocks

SyncWrap makes customizing the above or implementing new components easy, as needed in your own projects.

License

Copyright © 2011-2018 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.

About

A rather direct provisioning and deployment system in ruby, bash over ssh, and rsync.

Resources

Stars

Watchers

Forks

Packages

No packages published