Git Product home page Git Product logo

migrate's Introduction

migrate

A configuration artifact migration tool

Migrate configuration artifacts from one system to another - say, dev to test, or legacy to new. Currently is a collection of objects designed to retrieve conf data; model said data as ruby objects to allow for programmatic modification; and to print the modeled data as a conf file.

Requires: ruby 2.x, optparse, yaml, and net/ssh gems, a server w/ ssh access

Usage

>irb
require 'migrate'

# First, create a (SSH-based) connection hash
connection = host: 'myhost', user: 'myuser', keyfile: '/path/to/mykey.pem'

# Create a server object with it
srv = Migration::Server.new connection: connection

## Use the AppManager to produce an application via the server's porter
# app = Migration::AppManager.produce '/path/to/app/conf.d', srv.porter

# Ask the server to fetch the app
app = srv.fetch '/path/to/app/conf.d'

# Explore the contents of the app through its config hash
app.conf
> { 'path' => { 'to' => { 'app' => { 'conf.d' => { 'auth.conf' => [ #parsed content array ], 'web.conf' => [] }}}}

# Paths become hash keys
app.conf[ 'path' ][ 'to' ][ 'app' ][ 'conf.d' ][ 'auth.conf' ]
> # structured file contents

# Alternately, retrieve contents via the path string
app.contents '/path/to/app/conf.d/auth.conf'
> # structured file contents

# Conf data is auto-parsed based on what it looks like.
# In the case of an INI-style file, with named stanzas,
# the result is an array of Artifacts containing the 
# parsed stanza.
stanza = app.contents( '/path/to/app/conf.d/auth.conf' ).first

# The artifact provides methods to view its contents
stanza.name             # INI header
stanza.source           # pre-parsed source text
stanza.data             # parsed source text (typically a hash)
stanza.has? key         # test if stanza has a particular key
stanza.fix! key, 'val'  # explicitly set key to 'val'

# ...or set with a block:
index = 'bar'
stanza.fix! key do |v|
  v.gsub /index\s?=\s?foo/, "index = #{ index }"
end

...

migrate's People

Contributors

awstahl avatar

Watchers

James Cloos avatar  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.