VladTheEnterprising
by Michael L. Welles
[email protected]
http://rubyforge.org/projects/vladenvironment/
Contributions by:
Alexander Rubin - [email protected]

== DESCRIPTION:

A series of packages to help using Vlad to manage "enterprise"
environments, includes host OS discovery and test-based per host
variable settings, targeting of environments and sub-environments,
mysql and xen management tasks.

Currently consists of the following:

* Vlad the Translator
* Vlad the Environmentalist
* Vlad the DBA
* Vlad the Xen Master

== FEATURES/PROBLEMS:

* Management of heterogenious enironments, dynamic discovery and
flexible handling of remote host types.

* Support of multiple environments and subenvironments, multiple
projects withing an environemnt

* Automation of common, time consuming, dba tasks, like installing,
syncronizing and bringing up new mysql slave instances.

* Beginnings of automation for xen image creation and management.

== SYNOPSIS:

* The Translator

Allows a flexiable callback system to set varabiles on a per-host
basis. For example, if the location of a given binary is different on
differing target hosts, you can add dialects such that
the path to the binary is set properly for each:

dialect :name => :local_bin_mysql,
:assert => lambda { run "if [ ! -x /usr/local/bin/mysql ]; then exit 1; fi" },
:set => { :mysql_cmd => "/usr/local/bin/mysql" }

dialect :name => :opt_bin_mysql,
:assert => lambda { run "if [ ! -x /opt/bin/mysql ]; then exit 1; fi" },
:set => { :mysql_cmd => "/opt/bin/mysql" }

If no exception is raised for an assertion, then variable will be set
in the context of each target host unless there is a global
already defined for the symbol.

The dialects are evaluated in the order that they're defined, with
later values replacing those defined earlier. The intention is to
start with general rules that will get ovverridden with increasingly
fine granularity.


* The Environmentalist

Supports multiple environments and sub-environments to deploy to.
Running with TARGET='production' will build a configuration from
config/enrvironment/produciton.rb as weill ruby files under the
config/environemtn/production/ directory.

Subenvironments may be specified. For example, if in production
I have more than one database group, I can specify which
I want to target in a given task by grouping them into seperate
files under config/environmenn/#target/#subenvironment.rb.

Specifying TARGET="production:vendor_content" will set only
what is defined in config/enviroment/production/vendor_condent.rb

This allows running tasks like "vlad:mysql:bootstrap_new_slaves"
a bit more fine grained control.

* The DBA

Utilities for common dba tasks. Currenltly, focused towards mysql
slave management. Given a subenvironment that has a :db_master
and :new_slave roles defined, "rake vlad:mysql:bootstrap_new_slaves"
will clean the mysql install on the new slaves, (re)install mysql
if necessary, grant replication priveleges to the new slave,
sync the slaves with a dump from the master and start replication.

By default will work with ubuntu, tested as well in a hetergenious
environment of ubuntu and (wierd and custom) NYTimes Solaris
servers. See Example.txt for the custom dialect for
the NYTimes Solaris setup, so that vlad could do the
necessary stuff on those machines while still working as expected
on the ubuntu hosts in the subenvironment.

Migrations and Versioning
=========================

As of 1.8, schema migrations and versioning are supported. By
default the app will look under db/migrations/[schema name]/[version
no]-[text]/[upgrade.sql|rollback.sql]

So, for example. Lets say I have a the folowing files:

db/migrations/UserContent/1-version_column/rollback.sql
db/migrations/UserContent/1-version_column/upgrade.sql
db/migrations/UserContent/2-crnr_sp_get_asset_comments/rollback.sql
db/migrations/UserContent/2-crnr_sp_get_asset_comments/upgrade.sql
db/migrations/UserContent/3-crnr_sp_update_asset_taxonomy_properties/rollback.sql
db/migrations/UserContent/3-crnr_sp_update_asset_taxonomy_properties/upgrade.sql

And I run the following command:

"rake vlad:mysql:migrate TARGET=testing:user_content"

VladtheDBA will will perform the following steps on :db_master
in my testing:user_content subenvironment:

- For each database defined there, if database
doesn't have a "schema_info" table, vlad will create one.

- It will look for a directory for that schema under db/migrations.

- If it finds one (in this case, UserContent), it will perform the
upgrade.sql for each migration migration subdirectory in
numerical order, until the version in the schema info table
is up to date with the migrations.

Running a rollback is as follows:

"rake vlad:mysql:migrate TARGET=testing:user_content
DATABASE=UserContent VERSION=1"

Will cause vlad to decremant backwards through the migrations
running the DDL in rollback.sql, until it gets back to version 1.

The idea was a blatant ripoff of activerecord migrations in rails,
but just in a framework neutral way, and with the only assumption
being that there's ssh and the mysql client available on the
db_master.

* The Xen Master

Beginnings of a series of tasks for autmating the creation and
management of Xen images. Currently has the expectation that
the master host will be running ubuntu (though this can be
fixed by adding other dialiects), and supports the creation
of ubuntu edgy, centos5, and centos4.4 images. None quite
are fire and forget yet -- but none of the problems are
insurmountable.


== REQUIREMENTS:

* vlad
* highline


== INSTALL:

* install vlad the deployer, per instructions
* sudo gem install VladTheEnterprising
* To project Rakefile:
* require 'vlad/enterprising'
* rake vlad:enterprising:setup
* Expected files will now be under config/deploy/files

== LICENSE:

(The MIT License)

Copyright (c) 2007

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.