0
Oops! I deployed it again
New ways to get your app in the cloud Dylan Jay
You've written a web app
And now you need a host
We want it to be easy
We want flexibility
We want it to be cheap
Options
Type Providers Flexibility (Easy) Scalability
Shared Few
e.g. Webfaction
($14)
Limited Choice
(Control Panel)
None...
Can you have your cake
and eat it to?
Hostout (Fabric, buildout)
&
Silverlining
Code under development
Push vs Pull
Fabric
<< fabfile.py >>
from fabric import api
def host_type():
api.run('uname -s')
$ fab -H localhost,linuxbox host_type
Buildout Workflow
Get the “buildout”
$ python bootstrap.py
$ bin/buildout
$ bin/myinstalledscript
… add recipes to buildou...
Building myapp
$ bin/buildout
$ bin/paster serve src/myapp/myapp.ini
Useful recipes
● zc.recipe.egg – download eggs and create
scripts
● collective.recipe.command – run shell
commands
● colle...
Hostout
Is
a buildout recipe
to replicate a local buildout
to many hosts
(using fabric)
Why document it when you can code it?
Basic Hostout
[buildout]
parts = host1
[host1]
recipe = collective.hostout
host = 127.0.0.1:10022
fabfiles = fabfile.py
op...
Command line
$> bin/hostout host1 host_type
$> bin/hostout host1 host2 host_type echo
hello
Share your command
< setup.py >
entry_points = {'zc.buildout': ['default =pkg:Recipe',],
'fabric': ['fabfile = pkg.fabfile...
Built in commands
● Run
● Sudo
● Deploy
● Predeploy
– Bootstrap – platform dependent
● setupusers
● setowners
● Uploadeggs...
Releasing eggs
1 hostoutversions.cfg during buildout
2 sdist with md5 for all develop eggs
3 fabric.api.put all hashed egg...
Hostout
● Get a “production” buildout
● To your develop.cfg buildout add...
[myhost]
recipe = collective.hostout
extends =...
Hostout is modular
● collective.hostout
● Deploys buildout to any posix host. Needs IP and
password
● hostout.ubuntu
● boo...
Suggested layout
● buildout.cfg (extends = config/deploy.cfg config/devel.cfg)
● config/
● base.cfg (extends = base.cfg)
●...
User model
[host1]
user = {initial sudo user}
buildout-user = {owns buildout files + pw-less
login}
effective-user = {owns...
Extra Options
● include = {files to include in buildout zip}
● parts = {override parts}
● sudo-parts = {sudo bin/buildout ...
Deployment Hooks
def predeploy():
domystuff
api.env.hostout.super.predeploy()
● Calls that are overridable
– api.env.hosto...
hostout.supervisor
● Pre and post deployment stop and start
● bin/hostout host status
● bin/hostout host supervisorboot
● ...
hostout.cloud
● bin/hostout host create
● bin/hostout host destroy
● Predeploy hook to create if needed
[host1]
extends =
...
Gotchas
● Eggs must be releasable. Ie need setuptools-git
etc
● All files must be checked in locally
● Interactive command...
$ bin/hostout host deploy
Silverlining
● By Ian Bicking
● Create app layout/dir
● $ silver init myapp
● Install dependencies into dir
● $ cd app; bi...
Silverlining II
● Configure it
● Edit app.ini: runner = src/myapp/myapp.ini
● Create host
● $ silver create-node myhost
● ...
Hostout vs. Silverlining
● Many deployers
● Checkin. Checkout. Buildout. deploy
● Hostout uses fabric
● Cross platform but...
Silverlining vs. Hostout
● Silverlining is batteries included
● You don't need a production buildout
● Silverlining is “kn...
Thanks
● Dylan Jay
● http://www.pretaweb.com
● twitter: djay75
● pyconau@dylanjay.com
● Know plone, syd admin or pywebdev?...
Photo Credits
http://www.flickr.com/photos/benheine/4613609067/sizes/l/in/set-72157622547905358/
http://www.flickr.com/pho...
Opps I deployed it again-ploneconf2010
Opps I deployed it again-ploneconf2010
Upcoming SlideShare
Loading in...5
×

Opps I deployed it again-ploneconf2010

1,208

Published on

Hostout integrates buildout and fabric into an extensible out of the box deployment system.

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,208
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
14
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide
  • Isolated environment
    Combine eggs, sdist, cmmi, .cfg, php, whatever
    Recipes do the combining
    Flow is Configure, build (auto install), run
    Vs
    Install, configure, run
    Can share “buildouts”
  • Transcript of "Opps I deployed it again-ploneconf2010"

    1. 1. Oops! I deployed it again New ways to get your app in the cloud Dylan Jay
    2. 2. You've written a web app And now you need a host
    3. 3. We want it to be easy
    4. 4. We want flexibility
    5. 5. We want it to be cheap
    6. 6. Options Type Providers Flexibility (Easy) Scalability Shared Few e.g. Webfaction ($14) Limited Choice (Control Panel) None AppEngine One Google (Free) No Choice (Launcher) Built in VPS Lots e.g. Slicehost ($20) Unlimited choice (DIY) DIY Cloud Few e.g. Rackspace ($11) Unlimited choice (DIY) DIY
    7. 7. Can you have your cake and eat it to?
    8. 8. Hostout (Fabric, buildout) & Silverlining
    9. 9. Code under development
    10. 10. Push vs Pull
    11. 11. Fabric << fabfile.py >> from fabric import api def host_type(): api.run('uname -s') $ fab -H localhost,linuxbox host_type
    12. 12. Buildout Workflow Get the “buildout” $ python bootstrap.py $ bin/buildout $ bin/myinstalledscript … add recipes to buildout.cfg from pypi … $ bin/buildout
    13. 13. Building myapp $ bin/buildout $ bin/paster serve src/myapp/myapp.ini
    14. 14. Useful recipes ● zc.recipe.egg – download eggs and create scripts ● collective.recipe.command – run shell commands ● collective.recipe.template – make config files from templates ● zc.recipe.cmmi – compile, make, install stuff ● isotoma.recipe.apache – or any other useful shortcuts ● mr.developer – manage source control
    15. 15. Hostout Is a buildout recipe to replicate a local buildout to many hosts (using fabric)
    16. 16. Why document it when you can code it?
    17. 17. Basic Hostout [buildout] parts = host1 [host1] recipe = collective.hostout host = 127.0.0.1:10022 fabfiles = fabfile.py option1 = buildout user = root password = root path = /var/host1
    18. 18. Command line $> bin/hostout host1 host_type $> bin/hostout host1 host2 host_type echo hello
    19. 19. Share your command < setup.py > entry_points = {'zc.buildout': ['default =pkg:Recipe',], 'fabric': ['fabfile = pkg.fabfile'] }, [host1] recipe = collective.hostout extends = pkg
    20. 20. Built in commands ● Run ● Sudo ● Deploy ● Predeploy – Bootstrap – platform dependent ● setupusers ● setowners ● Uploadeggs ● Uploadbuildout ● Buildout ● Postdeploy
    21. 21. Releasing eggs 1 hostoutversions.cfg during buildout 2 sdist with md5 for all develop eggs 3 fabric.api.put all hashed eggs (if needed) 1 Direct to egg cache 4 deployed.cfg with hashed versions pinned 5 Upload zip of buildout + includes 6 fabric.api.run( bin/buildout -c deployed.cfg )
    22. 22. Hostout ● Get a “production” buildout ● To your develop.cfg buildout add... [myhost] recipe = collective.hostout extends = hostout.cloud hostout.ubuntu hosttype = rackspace key = myaccount secret = myapikey buildout = production.cfg ● $ bin/buildout ● $ bin/hostout myhost deploy
    23. 23. Hostout is modular ● collective.hostout ● Deploys buildout to any posix host. Needs IP and password ● hostout.ubuntu ● bootstraps ubuntu host for buildout ● hostout.cloud ● Creates node ready to be bootstrapped ● fabfiles = myfabfile.py – add your own
    24. 24. Suggested layout ● buildout.cfg (extends = config/deploy.cfg config/devel.cfg) ● config/ ● base.cfg (extends = base.cfg) ● devel.cfg (extends = base.cfg) ● prod.cfg (extends = base.cfg) ● deploy.cfg (extends = base.cfg) – [host1] – buildout = production.cfg – parts = instance1
    25. 25. User model [host1] user = {initial sudo user} buildout-user = {owns buildout files + pw-less login} effective-user = {owns var dir} buildout-group = {group owns both}
    26. 26. Extra Options ● include = {files to include in buildout zip} ● parts = {override parts} ● sudo-parts = {sudo bin/buildout install …} ● pre-commands = {shell to sudo before} ● post-commads = {shell to sudo after} ● path = {location of buildout}
    27. 27. Deployment Hooks def predeploy(): domystuff api.env.hostout.super.predeploy() ● Calls that are overridable – api.env.hostout.callmycommand()
    28. 28. hostout.supervisor ● Pre and post deployment stop and start ● bin/hostout host status ● bin/hostout host supervisorboot ● bin/hostout host start/stop/restart
    29. 29. hostout.cloud ● bin/hostout host create ● bin/hostout host destroy ● Predeploy hook to create if needed [host1] extends = hostout.cloud hostout.ubuntu hostout.supervisor hosttype = rackspace hostname = ploneplonk key = ${keys:rackspace_key} secret = ${keys:rackspace_secret}
    30. 30. Gotchas ● Eggs must be releasable. Ie need setuptools-git etc ● All files must be checked in locally ● Interactive commands get stuck
    31. 31. $ bin/hostout host deploy
    32. 32. Silverlining ● By Ian Bicking ● Create app layout/dir ● $ silver init myapp ● Install dependencies into dir ● $ cd app; bin/easy_install repoze.bfg ● Install your code into dir ● $ bin/python src/myapp/setup.py develop
    33. 33. Silverlining II ● Configure it ● Edit app.ini: runner = src/myapp/myapp.ini ● Create host ● $ silver create-node myhost ● $ silver setup-node myhost ● Deploy (rsync) ● $ silver update myapp --node myhost
    34. 34. Hostout vs. Silverlining ● Many deployers ● Checkin. Checkout. Buildout. deploy ● Hostout uses fabric ● Cross platform but more dependencies (pycrypto) ● Hostout is modular ● Package your own fabfiles to help others deploy ● Hostout is flexible – helps professionals ● Buildout is powerful. No limit to building/installing. NoSQL etc. ● Buildout shares dl code
    35. 35. Silverlining vs. Hostout ● Silverlining is batteries included ● You don't need a production buildout ● Silverlining is “known” target platform ● means less variables to go wrong ● Familiar workflow ● Commandline vs cfg.
    36. 36. Thanks ● Dylan Jay ● http://www.pretaweb.com ● twitter: djay75 ● pyconau@dylanjay.com ● Know plone, syd admin or pywebdev? - we're hiring
    37. 37. Photo Credits http://www.flickr.com/photos/benheine/4613609067/sizes/l/in/set-72157622547905358/ http://www.flickr.com/photos/stevedave/3444248057/sizes/o/ http://www.flickr.com/photos/rkbcupcakes/3409724942/sizes/o/ http://www.flickr.com/photos/irrational_cat/517564258/
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×