4
What Moonshine does
Update packages
Configure SSH
Configure iptables
Build and install Apache, MySQL/Postgres, Ruby Enterprise Edition,
RubyGems, Passenger, ImageMagick, PostFix, cron, logrotate, NTP, Rails, gems, git, etc. etc.…
Deploy!
Manage!
…and more!
5
What Moonshine is built on
Made by Rails Machine
Puppet
ShadowPuppet (extracted from Moonshine)
Capistrano
6
Moonshine Plugins
ar_mailer
Local and Amazon S3 backups
god
iptables
memcached
sphinx
ssh
Wordpress (?!)
7
Getting Started
8
What you need
A server running Ubuntu 8.10
A user on the server who can sudo and
access your Git repository
A beer (optional)
9
Install Plugins
script/plugin install git://github.com/railsmachine/moonshine.git
script/plugin install git://github.com/railsmachine/moonshine_ssh.git
script/plugin install git://github.com/railsmachine/
moonshine_iptables.git
Install any other Moonshine plugins you want
script/generate moonshine
Generates config/moonshine.yml and app/manifests/
10
Gems
Make sure all of your gems are declared in environment.rb
rake moonshine:gems
Generates gems.yml
You need to do this any time you add/remove/change the gems
11
Edit moonshine.yml
:ruby: ree
:application: ultranetweb
:user: rails
:time_zone: UTC
:deploy_to: /srv/ultranetweb
:domain: ultranetweb.com
:domain_aliases:
- www.ultranetweb.com
- assets1.ultranetweb.com
# The entries in shared_children are created in #{application}/shared
:shared_children:
- system
- log
- pids
- config
:repository: git@github.com:robotmode/ultranetweb.git
13
Edit application_manifest.rb
Located in app/manifests/
# Installs Rails, Apache, Passenger, the database from database.yml, Postfix,
# Cron, logrotate and NTP.
recipe :default_stack
plugin :ssh
recipe :ssh
plugin :iptables
recipe :iptables
14
Edit application_manifest.rb
Located in app/manifests/
def application_packages
send_weekly_emails = "/usr/bin/rake -f #{configuration[:deploy_to]}/
current/Rakefile mailer:send_weekly_emails RAILS_ENV=#{ENV['RAILS_ENV']}"
cron 'notifications:send_weekly_emails',
:command => send_weekly_emails,
:user => configuration[:user],
:minute => 0,
:hour => 3,
:weekday => 1
# Only run the following on the 'staging' stage using capistrano-ext.
on_stage 'staging' do
file '/etc/motd', :ensure => :file, :content => "!!! STAGING SERVER !!!"
end
end
15
Capify and go!
capify .
config/deploy.rb:
server "ultranetweb.com", :app, :web, :db, :primary =>
true
Add to git
git add . && git commit -am "added moonshine" && git
push
Bootstrap!
cap
deploy:setup
Deploy!
cap
deploy
16
Now, cap deploy will…
Verify your system config on each deploy
Run migrations
Install gems
…and their system dependencies!
Pull down submodules
Keep your system configuration in
version control!
17
But what about other servers?
You can have per-server manifests for your app servers, database
servers, memcache, etc.
set :moonshine_manifest, 'memcached_manifest'
By default, Moonshine sets your database auto-increment to 10 to
allow for easier database sharding later
Check the Moonshine Google Group for more info
18
Resources
Source/wiki: http://github.com/railsmachine/moonshine
Docs: http://railsmachine.github.com/moonshine/
Mailing list: http://groups.google.com/group/railsmachine-
moonshine
Slides will be up at http://jarinheit.com in the next couple of days
0 comments
Post a comment