socal piggies-app-deploy

Post on 13-May-2015

1.232 Views

Category:

Technology

1 Downloads

Preview:

Click to see full reader

DESCRIPTION

presentation file for my talk at socal python group Feb 22, 2012

TRANSCRIPT

Application Deployment is System State

Joshua Timberman@jtimberman

joshua@opscode.com

Wednesday, February 22, 12

% whoami

Wednesday, February 22, 12

Wednesday, February 22, 12

Wednesday, February 22, 12

Who are you?

• Developers?

• System administrators?

• DevOps?

Wednesday, February 22, 12

System State

Wednesday, February 22, 12

Configuration Management

Wednesday, February 22, 12

System Integration

http://www.flickr.com/photos/opalsson/3773629074/

Wednesday, February 22, 12

WAT?

Wednesday, February 22, 12

n-Tier Infrastructure

Database Master

Load Balancer

App Server App Server

• Provision

• Configure

• Integrate

{{

Wednesday, February 22, 12

Wednesday, February 22, 12

We're hiring!opscode.com/careers/

Wednesday, February 22, 12

Resources

Wednesday, February 22, 12

Declarative interface to system resources

Wednesday, February 22, 12

user "django_app" do shell "/bin/false comment "Django App User" system true action :createend

package "python" do action :installend

python_pip "gunicorn" do action :installend

Wednesday, February 22, 12

Describe *what*.

Not how.

Wednesday, February 22, 12

def install_package(name, version) package_name = "#{name}=#{version}" package_name = name if @is_virtual_package run_command_with_systems_locale( :command => "apt-get -q -y #{expand_options(@new_resource.options)} install #{package_name}", :environment => { "DEBIAN_FRONTEND" => "noninteractive" } )end

Wednesday, February 22, 12

package “python” { yum install pythonapt-get install pythonpacman sync pythonpkg_add -r python

Wednesday, February 22, 12

Recipes

Wednesday, February 22, 12

Ruby Internal Ruby DSL Ruby

Wednesday, February 22, 12

def method_missing(method_symbol, *args, &block) return "lol method_missing"end

Wednesday, February 22, 12

user "django_app" do shell "/bin/false comment "Django App" system trueend

package "python"

python_pip "gunicorn" do action :installend

Wednesday, February 22, 12

Cookbooks

Wednesday, February 22, 12

opscode/cookbooks/python├── README.md├── attributes│   └── default.rb├── metadata.rb├── providers│   ├── pip.rb│   └── virtualenv.rb├── recipes│   ├── default.rb│   ├── package.rb│   ├── pip.rb│   ├── source.rb│   └── virtualenv.rb└── resources ├── pip.rb └── virtualenv.rb

Wednesday, February 22, 12

Roles

Wednesday, February 22, 12

Roles describe nodes.

Wednesday, February 22, 12

name "django_cms"description "django app app server"run_list( "recipe[mysql::client]", "recipe[application]")

Wednesday, February 22, 12

Roles contain recipes

Wednesday, February 22, 12

name "base"description "All nodes have the base role"run_list( "recipe[zsh]", "recipe[sudo]", "recipe[apt]", "recipe[git]", "recipe[build-essential]")override_attributes( :authorization => { :sudo => { :users => ["ubuntu"], :passwordless => true } })

Wednesday, February 22, 12

Application Deployment

Wednesday, February 22, 12

Wednesday, February 22, 12

Wednesday, February 22, 12

Wednesday, February 22, 12

Wednesday, February 22, 12

Wednesday, February 22, 12

Build your own

• Let's be realistic.

• You own your availability.

Wednesday, February 22, 12

Application Deployment vs...

• Configuration management

• Ad-hoc system administration

• Going against policy

Wednesday, February 22, 12

Wednesday, February 22, 12

Wednesday, February 22, 12

Package management

• Rpm

• Deb

• Pkgsrc

• Gems

• Eggs

• Not a solved problem.

Wednesday, February 22, 12

git "/srv/django_app" do  repository "git://github.com/me/django_app.git"  reference "master"  action :syncend

Wednesday, February 22, 12

Fabric

Wednesday, February 22, 12

Capistrano

Wednesday, February 22, 12

chef-deploy

Wednesday, February 22, 12

deploy_revision[/srv/django_app]

Wednesday, February 22, 12

deploy_revision "/srv/django_app" do revision "2.0.17" repository "git://github.com/me/django_app.git" user "django_app" group "www-data" before_migrate do requirements_file = "#{release_path}/requirements.txt" execute "pip install -r #{requirements_file}" do cwd release_path end end action :deployend

Wednesday, February 22, 12

Ad-Hoc Deployment

• knife ssh

• capistrano

• fabric (use pychef!)

Wednesday, February 22, 12

require 'chef/knife'require 'chef/search/query'

Capistrano::Configuration.instance.load do  Chef::Knife.new.configure_chef

  def chef_role(name, query = "*:*", options = {})    attr = options.delete(:attribute) || :ipaddress    nodes = Chef::Search::Query.new.search(:node, query)[0].map {|n| n[attr] }    role name, *nodes, options    nodes  endend

https://github.com/cramerdev/capistrano-chefWednesday, February 22, 12

http://pychef.readthedocs.org/en/latest/fabric.html

from fabric.api import env, run, rolesfrom chef.fabric import chef_roledefs

env.roledefs = chef_roledefs()

@roles('web_app')def mytask(): run('uptime')

Wednesday, February 22, 12

http://www.flickr.com/photos/oberazzi/318947873/

Questions?

Joshua Timbermanjoshua@opscode.com

@jtimberman (twitter, github)lists.opscode.com

irc.freenode.net/chef

Wednesday, February 22, 12

top related