Snakes on a TreadmillNoah Kantrowitz  2011-07-06
Chef•   Configuration management•   Deployment logic?•   Best practices! (mostly•   Not all Ruby code, I promise
Deploy Resource•   Pull from source•   Atomic updates via symlinks•   Fast rollback•   We all do this already, right?
Deploy Resourcedeploy_revision /srv/myapp do repo git@github.com/coderanger/myapp branch release user www-dataend
Folder Layout•   /srv/myapp    •   /srv/myapp/shared        •   /srv/myapp/shared/releases            •   /srv/myapp/share...
Folder Layout•   /srv/myapp    •   /srv/myapp/shared        •   /srv/myapp/shared/releases            •   /srv/myapp/share...
Resets                              purge_before_symlink []•   Rails-specific defaults   create_dirs_before_symlink []•   ...
Symlinks                                        template /srv/myapp/shared/settings_local.py do                           ...
Migrations                                   deploy_revision /srv/myapp do                                    ...         ...
Packages•   before_migrate                     deploy_revision /srv/myapp do•   before_symlink    ...                     ...
NIH                                 {                                     "id": "myapp",                                  ...
Other Cookbooks•   python    •   pip packages    •   python_virtualenv•   application::gunicorn•   postgres•   nginx
Want More?•   http://wiki.opscode.com/•   http://community.opscode.com/cookbooks/•   http://help.opscode.com/kb/otherhelp/...
PyChef•   pip install pychef            import chef•   Reads knife.rb or client.rb                                  api = ...
Search•   Search(‘index’, ‘query’)•   row.object                               import chef                               a...
T-Shirts and stickers!
Noah Kantrowitz    noah@opscode.com        @kantrn
Upcoming SlideShare
Loading in...5
×

Snakes on a Treadmill

1,380

Published on

Using Chef for Continuous Deployment with Django.

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

  • Be the first to like this

No Downloads
Views
Total Views
1,380
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
7
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • The ones in red need to be created with directory resources, the rest are created for you.\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Snakes on a Treadmill

    1. 1. Snakes on a TreadmillNoah Kantrowitz 2011-07-06
    2. 2. Chef• Configuration management• Deployment logic?• Best practices! (mostly• Not all Ruby code, I promise
    3. 3. Deploy Resource• Pull from source• Atomic updates via symlinks• Fast rollback• We all do this already, right?
    4. 4. Deploy Resourcedeploy_revision /srv/myapp do repo git@github.com/coderanger/myapp branch release user www-dataend
    5. 5. Folder Layout• /srv/myapp • /srv/myapp/shared • /srv/myapp/shared/releases • /srv/myapp/shared/releases/4faedb2ee... • /srv/myapp/shared/releases/9457be295... • ... • /srv/myapp/current
    6. 6. Folder Layout• /srv/myapp • /srv/myapp/shared • /srv/myapp/shared/releases • /srv/myapp/shared/releases/4faedb2ee... • /srv/myapp/shared/releases/9457be295... • ... • /srv/myapp/current
    7. 7. Resets purge_before_symlink []• Rails-specific defaults create_dirs_before_symlink []• :-( symlinks({}) symlink_before_migrate({})
    8. 8. Symlinks template /srv/myapp/shared/settings_local.py do source settings_local.py.erb vars ... end• Put config files in shared• ‘path/in/shared’ => ‘path/in/app’ deploy_revision /srv/myapp do ...• symlink vs. before_migrate symlink_before_migrate( settings_local.py=>conf/settings_local.py ) end
    9. 9. Migrations deploy_revision /srv/myapp do ... migrate true• Run migrations automatically migration_command /srv/myapp/shared/env/bin/python • Only on “master” machine? end /srv/myapp/current/manage.py syncdb --migrate migrate node[:roles].include? migrator
    10. 10. Packages• before_migrate deploy_revision /srv/myapp do• before_symlink ... before_migrate /srv/myapp/shared/env/bin/pip install -r • before_restart end /srv/myapp/current/requirements.txt• after_restart
    11. 11. NIH { "id": "myapp", "server_roles": [ "myapp" ], "type": { "myapp": [ "django" ] },• application::django "repository": "git@github.com:coderanger/myapp.git", "revision": {• http://ckbk.it/application }, "production": "release"• Data-driven deployment "databases": { "production": {• PyChef! "username": "db_user", "adapter": "postgres", "database": "production" } }, "owner": "www-data", "group": "www-data", "packages": { "curl": "7.19.5-1ubuntu2" },
    12. 12. Other Cookbooks• python • pip packages • python_virtualenv• application::gunicorn• postgres• nginx
    13. 13. Want More?• http://wiki.opscode.com/• http://community.opscode.com/cookbooks/• http://help.opscode.com/kb/otherhelp/build-a-django-stack• https://github.com/ericholscher/chef-django-example• My DjangoCon talk (hopefully!)
    14. 14. PyChef• pip install pychef import chef• Reads knife.rb or client.rb api = chef.autoconfigure()• chef.Object(‘id’) bag = chef.DataBag(applications)• chef.Object.list() item = bag[myapp]• obj.save() item[revision][production] = v1.1• obj.delete() item.save()
    15. 15. Search• Search(‘index’, ‘query’)• row.object import chef api = chef.autoconfigure() for row in chef.Search(node, role:myapp): print row.object[fqdn]
    16. 16. T-Shirts and stickers!
    17. 17. Noah Kantrowitz noah@opscode.com @kantrn
    1. A particular slide catching your eye?

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

    ×