# = Rudy -- Skeleton configuration # # Rudy automatically looks for configuration files in the following # locations (in this order): # # ./.rudy/config # ~/.rudy/config # # ~/.rudy/*.rb # ./Rudyfile # ./machines.rb, ./routines.rb, ./commands.rb # ./config/rudy/*.rb # ./.rudy/*.rb # /etc/rudy/*.rb # # When multuple files are found, the configuration is NOT OVERRIDDEN, # it's ADDED or APPENDED depending on context. This means you can split # configuration across many files as you please. # # There are five sections: accounts, defaults, machines, commands and routines. # # By convention, accounts go in ./.rudy/config or ~/.rudy/config # machines, commands, routines, and defaults configuration go in ./Rudyfile or # into separate files in ./.rudy or ./config/rudy (machines.rb, commands.rb, ...) # # --------------------------------------------------------- MACHINES -------- # The machines block describes the 'physical' characteristics of your machines. machines do region :'us-east-1' do ami 'ami-e348af8a' # Alestic Debian 5.0, 32-bit (US) end region :'eu-west-1' do ami 'ami-6ecde51a' # Alestic Debian 5.0, 32-bit (EU) end hostname :rudy # One of: :default, :rudy, 'your-name' # We've defined an environment called 'stage' with one role: 'app'. # The configuration inside the env block is available to all its # roles. The configuration inside the role blocks is available only # to machines in that specific role. env :stage, :prod do user :root # User to connect as size 'm1.small' # EC2 machine type for all machines # in the 'stage' environment role :app do positions 1 # Only 1 machine in stage-app #addresses '11.22.33.44' # Define an elastic IP to reuse disks do # Define EBS volumes path '/rudy/disk1' do # The paths can be anything but size 2 # they must be unique. device '/dev/sdr' # Devices must be unique too. end end end role :db do # You can define as many roles end # as you like. These are just role :balancer do # a couple examples. end users do # Specify existing private keys per user rudy do keypair '/path/2/private-key' end end end end # ----------------------------------------------------------- COMMANDS -------- # The commands block defines shell commands that can be used in routines. The # ones defined here are added to the default list defined by Rye::Cmd (Rudy # executes all SSH commands via Rye). # # Usage: # # allow COMMAND-NAME # allow COMMAND-NAME, '/path/2/COMMAND' # allow COMMAND-NAME, '/path/2/COMMAND', 'default argument', 'another arg' # commands do allow :gem_install, '/usr/bin/gem', 'install', :V, '--no-rdoc', '--no-ri' allow :apt_get, 'apt-get', :y, :q allow :rubycode do puts "Some ruby code running in #{self}" end end # ----------------------------------------------------------- ROUTINES -------- # The routines block describes the repeatable processes for each machine group. # To run a routine, specify its name on the command-line: rudy startup routines do env :stage, :prod do # We'll define routines for the stage-app role :app do # and prod-app machine groups. user :root # The default remote user startup do # $ rudy startup adduser :rudy # Create a user called 'rudy' # disks do # Define EBS volume routines create '/rudy/disk1' # Create an EBS volume, attach it, give end # it a filesystem, and mount it. # remote :rudy do # Run remote SSH commands after startup mkdir :p, 'great' # $ mkdir -p great touch 'great/scott' # $ touch great/scott ls :l, :a # $ ls -l -a * end end shutdown do # $ rudy shutdown remote :root do # Run remote SSH commands before shutdown uptime end disks do destroy '/rudy/disk1' # Unmount and destroy the EBS volume end end reboot do # $ rudy reboot before_remote do # Run any pre-reboot tasks like stopping uptime # web servers and databases. end # remote do # Run any startup tasks like starting uptime # processes or initializing the filesystem end end backup do # $ rudy backup disks do # A simple routine that creates an EBS snapshot '/rudy/disk1' # snapshot of the specified volume. end end restore do # $ rudy restore disks do # A contrived example of restoring a destroy '/rudy/disk1' # disk from a backup. NOTE: You'll need restore '/rudy/disk1' # to run 'rudy backup' at least once end # before otherise there are no backups end # to restore from. end end # Define global routines available to all machine groups # This routine will update a basic Debian machine and # install essential libraries. # See http://github.com/rudy/arcade sysupdate do # $ rudy sysupdate remote :root do apt_get 'update' # Update debian / ubuntu apt_get 'install', 'build-essential', 'sqlite3', 'libsqlite3-dev' apt_get 'install', 'apache2-prefork-dev', 'libapr1-dev' gem_install 'rudy' end end anything do # $ rudy anything before :uptime # Specify a dependency local do # This is Ruby, so any valid syntax ls :l # can be used in the definitions. end # See: SysInfo gem for more info. end uptime do # $ rudy uptime remote { uptime } # Short block syntax end end # ----------------------------------------------------------- DEFAULTS -------- # These values are used as defaults for their respective global settings. All # non-boolean values are expected to be Symbols. # defaults do zone :'us-east-1d' environment :stage role :app #user ENV['USER'] # The default remote user #localhost 'hostname' # A local hostname instead of localhost #color true # Terminal colors? true/false #yes false # Auto-confirm? true/false #keydir '~/.ssh/' # The path to store SSH keys end