space, → | next slide |
← | previous slide |
d | debug mode |
## <ret> | go to slide # |
c | table of contents (vi) |
f | toggle footer |
r | reload slides |
z | toggle help (this) |
apt-get install build-essential \
ruby ruby-dev rubygems
gem install puppet puppet-pip
Even in Ubuntu Maverick, pip
is out-of-date (0.7.2).
stage { "pre": before => Stage["main"] }
class python {
package {
"build-essential": ensure => latest;
"python": ensure => "2.6.6-2ubuntu1";
"python-dev": ensure => "2.6.6-2ubuntu1";
"python-setuptools": ensure => installed;
}
exec { "easy_install pip":
path => "/usr/local/bin:/usr/bin:/bin",
refreshonly => true,
require => Package["python-setuptools"],
subscribe => Package["python-setuptools"],
}
}
class { "python": stage => "pre" }
package {
"django":
ensure => "1.2.3",
provider => pip;
"mysql-python":
ensure => "1.2.3",
provider => pip;
}
package {
"django":
ensure => "1.2.3",
provider => pip;
"mysql-python":
ensure => "1.2.3",
provider => pip;
}
package {
"django":
ensure => "1.2.3",
provider => pip;
"libmysqlclient-dev":
ensure => "5.1.49-1ubuntu8.1";
"mysql-python":
ensure => "1.2.3",
provider => pip;
}
package {
"django":
ensure => "1.2.3",
provider => pip;
"libmysqlclient-dev":
ensure => "5.1.49-1ubuntu8.1";
"mysql-python":
ensure => "1.2.3",
provider => pip;
}
package {
"django":
ensure => "1.2.3",
provider => pip;
"libmysqlclient-dev":
ensure => "5.1.49-1ubuntu8.1";
"mysql-python":
ensure => "1.2.3",
provider => pip,
require =>
Package["libmysqlclient-dev"];
}
libmysqlclient-dev
.# As root!
export GEMS="/var/lib/gems/1.8/gems"
export RUBYLIB=$GEMS/"puppet-pip-0.0.1/lib"
puppet apply deps.pp
package { "fabric":
ensure => "0.9.3",
provider => pip,
}
from fabric.api import *
env.hosts = ['example.com']
def puppet():
put('deps.pp', 'deps.pp')
sudo('RUBYLIB={0} puppet apply {1} deps.pp'.format(
'/var/lib/gems/1.8/gems/puppet-pip-0.0.1/lib',
'--templatedir=.',
))
fab puppet
package { "south":
ensure => "0.7.2",
provider => pip,
}
puppet apply deps.pp
fab puppet
package {
"apache2-mpm-worker":
ensure => "2.2.16-1ubuntu3";
"libapache2-mod-wsgi":
ensure => "3.2-2";
}
file {
"/etc/apache2/sites-available/mysite":
content => template("mysite.erb"),
ensure => file,
require => Package["apache2-mpm-worker"];
"/etc/apache2/sites-enabled/001-mysite":
ensure => "/etc/apache2/sites-available/mysite",
require => Package["apache2-mpm-worker"];
"/etc/apache2/sites-enabled/000-default":
ensure => absent,
require => Package["apache2-mpm-worker"];
"/usr/local/share/wsgi/mysite/mysite.wsgi":
content => template("mysite.wsgi"),
ensure => file;
}
mysite.erb
<VirtualHost *:80>
DocumentRoot /usr/local/share/wsgi/mysite/media
Alias /media /usr/local/share/wsgi/mysite/media
WSGIScriptAlias / /usr/local/share/wsgi/mysite/mysite.wsgi
WSGIDaemonProcess mysite processes=2
WSGIProcessGroup mysite
</VirtualHost>
mysite.erb
with one process per core<VirtualHost *:80>
DocumentRoot /usr/local/share/wsgi/mysite/media
Alias /media /usr/local/share/wsgi/mysite/media
WSGIScriptAlias / /usr/local/share/wsgi/mysite/mysite.wsgi
WSGIDaemonProcess mysite processes=<%= processorcount %>
WSGIProcessGroup mysite
</VirtualHost>
mysite.wsgi
import os
import sys.path
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
sys.path.append('/usr/local/share/wsgi')
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
mysite.wsgi
really belong in Puppet?mysite.wsgi
, with Fabric.service { "apache2":
enable => true,
ensure => running,
require => Package["apache2-mpm-worker"],
subscribe => [
Package[
"apache2-mpm-worker",
"libapache2-mod-wsgi"],
File[
"/etc/apache2/sites-available/mysite",
"/etc/apache2/sites-enabled/001-mysite",
"/etc/apache2/sites-enabled/000-default",
"/usr/local/share/wsgi/mysite/mysite.wsgi"]],
}
puppet apply --templatedir=. deps.pp
fab puppet
manifests/nodes.pp
node "example.com" {
include python
include mysite
}
modules/python/manifests/init.pp
stage { "pre": before => Stage["main"] }
class python {
package {
"build-essential": ensure => latest;
"python": ensure => "2.6.6-2ubuntu1";
"python-dev": ensure => "2.6.6-2ubuntu1";
"python-setuptools": ensure => installed;
}
exec { "easy_install pip":
path => "/usr/local/bin:/usr/bin:/bin",
refreshonly => true,
require => Package["python-setuptools"],
subscribe => Package["python-setuptools"],
}
}
class { "python": stage => "pre" }
modules/mysite/manifests/init.pp
class mysite {
include python
package {
"django":
ensure => "1.2.3",
provider => pip;
# Et cetera.
}
file {
# Prefix template paths with the module name.
"/etc/apache2/sites-available/mysite":
content => template("mysite/mysite.erb"),
ensure => file,
require => Package["apache2-mpm-worker"];
# Et cetera.
}
service {
"apache2": # As above.
}
# Other resources as you like.
}