Commit d04aa3c4 authored by Bruno Michel's avatar Bruno Michel

My first recipes: debug and nginx

parent 9d051d99
.vagrant
TODO
vendor
www
......@@ -4,13 +4,6 @@ Admin LinuxFr.org
Ce dépôt git contient les fichiers qui servent à l'administration du serveur LinuxFr.org -- pas les informations confidentielles ;)
Chef
----
Nous utilisons [Chef](http://www.opscode.com/chef) comme outil de déploiement automatique.
En pratique, nous nous servons de `chef-solo`, car nous n'avons jamais à gérer plus d'une instance à la fois.
Vagrant
-------
......@@ -19,6 +12,7 @@ Nous utilisons [Vagrant](http://vagrantup.com/) pour construire une VM pour Virt
Voici les instructions pour recréer la VM à partir de ce dépôt :
aptitude install virtualbox-ose rubygems expect git-core
git clone git://github.com/nono/linuxfr.org.git www
gem install vagrant
vagrant add debian_lenny http://files.vagrantup.com/contrib/debian_lenny.box
vagrant up
......@@ -27,10 +21,22 @@ Voici les instructions pour recréer la VM à partir de ce dépôt :
*Note* : le fichier `Vagrantfile` existe déjà, ce n'est donc pas la peine de faire un `vagrant init`.
Nous avons maintenant une machine virtuelle qui tourne avec un environement fonctionnel.
En particulier, vous pouvez afficher le site en tappant `http://localhost:3000` dans la barre d'adresse de votre navigateur.
En particulier, vous pouvez afficher le site en tappant `http://localhost:8080` dans la barre d'adresse de votre navigateur.
Vous pouvez également vous connecter en ssh sur la machine virtuelle avec `vagrant ssh`, ce qui peut être pratique pour débugger.
Chef
----
Nous utilisons [Chef](http://www.opscode.com/chef) comme outil de déploiement automatique.
En pratique, nous nous servons de `chef-solo`, car nous n'avons jamais à gérer plus d'une instance à la fois.
**Description et source des recipes :**
* debug : tout ce qu'il faut pour débugger (ltrace, strace, vim, etc.)
* nginx : le serveur web - http://github.com/opscode/cookbooks
* vagrant\_main : la recipe utilisée par vagrant pour (re)créer l'environnement
TODO
----
......
Vagrant::Config.run do |config|
# All Vagrant configuration is done here. For a detailed explanation
# and listing of configuration options, please check the documentation
# online.
config.vm.box = "base" # TODO "debian_lenny"
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "base"
config.chef.enabled = true
config.chef.cookbooks_path = "cookbooks"
config.vm.forward_port("web", 80, 8080)
end
package "ltrace"
package "strace"
package "vim"
= DESCRIPTION:
Installs nginx from package OR source code and sets up configuration handling similar to Debian's Apache2 scripts.
= REQUIREMENTS:
== Cookbooks:
* build-essential (for nginx::source)
== Platform:
Debian or Ubuntu though may work where 'build-essential' works, but other platforms are untested.
= ATTRIBUTES:
* version - sets the version to install.
* install_path - for nginx::source, sets the --prefix installation.
* src_binary - for nginx::source, sets the binary location.
* dir - configuration dir.
* log_dir - where logs go.
* user - user to run as.
* binary - path to nginx binary.
* configure_flags - for nginx::source, the flags to use for compilation.
* gzip* - configure the gzip module.
* keepalive - whether to use keepalive.
* keepalive_timeout
* worker_processes - number of workers to spawn.
* worker_connections - number of connections per worker.
* server_names_hash_bucket_size
= USAGE:
Provides two ways to install and configure nginx.
* Install via native package (nginx::default)
* Install via compiled source (nginx::source)
Both recipes implement configuration handling similar to the Debian Apache2 site enable/disable.
There's some redundancy in that the config handling hasn't been separated from the installation method (yet), so use only one of the recipes.
= LICENSE and AUTHOR:
Author:: Joshua Timberman (<joshua@opscode.com>)
Author:: Adam Jacob (<adam@opscode.com>)
Author:: AJ Christensen (<aj@opscode.com>)
Copyright:: 2008-2010, Opscode, Inc
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
set_unless[:nginx][:version] = "0.7.64"
set_unless[:nginx][:install_path] = "/opt/nginx-#{nginx[:version]}"
set_unless[:nginx][:src_binary] = "#{nginx[:install_path]}/sbin/nginx"
case platform
when "debian","ubuntu"
set[:nginx][:dir] = "/etc/nginx"
set[:nginx][:log_dir] = "/var/log/nginx"
set[:nginx][:user] = "www-data"
set[:nginx][:binary] = "/usr/sbin/nginx"
else
set[:nginx][:dir] = "/etc/nginx"
set[:nginx][:log_dir] = "/var/log/nginx"
set[:nginx][:user] = "www-data"
set[:nginx][:binary] = "/usr/sbin/nginx"
end
set_unless[:nginx][:configure_flags] = [
"--prefix=#{nginx[:install_path]}",
"--conf-path=#{nginx[:dir]}/nginx.conf",
"--with-http_ssl_module",
"--with-http_gzip_static_module"
]
set_unless[:nginx][:gzip] = "on"
set_unless[:nginx][:gzip_http_version] = "1.0"
set_unless[:nginx][:gzip_comp_level] = "2"
set_unless[:nginx][:gzip_proxied] = "any"
set_unless[:nginx][:gzip_types] = [
"text/plain",
"text/html",
"text/css",
"application/x-javascript",
"text/xml",
"application/xml",
"application/xml+rss",
"text/javascript"
]
set_unless[:nginx][:keepalive] = "on"
set_unless[:nginx][:keepalive_timeout] = 65
set_unless[:nginx][:worker_processes] = cpu[:total]
set_unless[:nginx][:worker_connections] = 2048
set_unless[:nginx][:server_names_hash_bucket_size] = 64
#
# Cookbook Name:: nginx
# Definition:: nginx_site
# Author:: AJ Christensen <aj@junglist.gen.nz>
#
# Copyright 2008-2009, Opscode, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
define :nginx_site, :enable => true do
if params[:enable]
execute "nxensite #{params[:name]}" do
command "/usr/sbin/nxensite #{params[:name]}"
notifies :restart, resources(:service => "nginx")
not_if do File.symlink?("#{node[:nginx][:dir]}/sites-enabled/#{params[:name]}") end
end
else
execute "nxdissite #{params[:name]}" do
command "/usr/sbin/nxdissite #{params[:name]}"
notifies :restart, resources(:service => "nginx")
only_if do File.symlink?("#{node[:nginx][:dir]}/sites-enabled/#{params[:name]}") end
end
end
end
types {
text/html html htm shtml;
text/css css;
text/xml xml;
image/gif gif;
image/jpeg jpeg jpg;
application/x-javascript js;
application/json json;
application/atom+xml atom;
application/rss+xml rss;
text/mathml mml;
text/plain txt;
text/vnd.sun.j2me.app-descriptor jad;
text/vnd.wap.wml wml;
text/x-component htc;
image/png png;
image/tiff tif tiff;
image/vnd.wap.wbmp wbmp;
image/x-icon ico;
image/x-jng jng;
image/x-ms-bmp bmp;
image/svg+xml svg;
application/java-archive jar war ear;
application/mac-binhex40 hqx;
application/msword doc;
application/pdf pdf;
application/postscript ps eps ai;
application/rtf rtf;
application/vnd.ms-excel xls;
application/vnd.ms-powerpoint ppt;
application/vnd.wap.wmlc wmlc;
application/vnd.wap.xhtml+xml xhtml;
application/vnd.google-earth.kml+xml kml;
application/vnd.google-earth.kmz kmz;
application/x-cocoa cco;
application/x-java-archive-diff jardiff;
application/x-java-jnlp-file jnlp;
application/x-makeself run;
application/x-perl pl pm;
application/x-pilot prc pdb;
application/x-rar-compressed rar;
application/x-redhat-package-manager rpm;
application/x-sea sea;
application/x-shockwave-flash swf;
application/x-stuffit sit;
application/x-tcl tcl tk;
application/x-x509-ca-cert der pem crt;
application/x-xpinstall xpi;
application/zip zip;
application/octet-stream bin exe dll;
application/octet-stream deb;
application/octet-stream dmg;
application/octet-stream eot;
application/octet-stream iso img;
application/octet-stream msi msp msm;
audio/midi mid midi kar;
audio/mpeg mp3;
audio/x-realaudio ra;
video/3gpp 3gpp 3gp;
video/mpeg mpeg mpg;
video/quicktime mov;
video/x-flv flv;
video/x-mng mng;
video/x-ms-asf asx asf;
video/x-ms-wmv wmv;
video/x-msvideo avi;
}
{
"dependencies": {
"runit": [
],
"build-essential": [
]
},
"replacing": {
},
"description": "Installs and configures nginx",
"groupings": {
},
"platforms": {
"ubuntu": [
],
"debian": [
]
},
"version": "0.10.0",
"recommendations": {
},
"name": "nginx",
"maintainer": "Opscode, Inc.",
"long_description": "",
"recipes": {
},
"suggestions": {
},
"maintainer_email": "cookbooks@opscode.com",
"attributes": {
"nginx/user": {
"calculated": false,
"default": "www-data",
"type": "string",
"choice": [
],
"description": "User nginx will run as",
"display_name": "Nginx User",
"recipes": [
],
"required": "optional"
},
"nginx/gzip_types": {
"calculated": false,
"default": [
"text/plain",
"text/html",
"text/css",
"application/x-javascript",
"text/xml",
"application/xml",
"application/xml+rss",
"text/javascript"
],
"type": "array",
"choice": [
],
"description": "Supported MIME-types for gzip",
"display_name": "Nginx Gzip Types",
"recipes": [
],
"required": "optional"
},
"nginx/gzip_proxied": {
"calculated": false,
"default": "any",
"type": "string",
"choice": [
],
"description": "Whether gzip is proxied",
"display_name": "Nginx Gzip Proxied",
"recipes": [
],
"required": "optional"
},
"nginx/dir": {
"calculated": false,
"default": "/etc/nginx",
"type": "string",
"choice": [
],
"description": "Location of nginx configuration files",
"display_name": "Nginx Directory",
"recipes": [
],
"required": "optional"
},
"nginx/keepalive_timeout": {
"calculated": false,
"default": "65",
"type": "string",
"choice": [
],
"display_name": "Nginx Keepalive Timeout",
"recipes": [
],
"required": "optional"
},
"nginx/gzip_comp_level": {
"calculated": false,
"default": "2",
"type": "string",
"choice": [
],
"description": "Amount of compression to use",
"display_name": "Nginx Gzip Compression Level",
"recipes": [
],
"required": "optional"
},
"nginx/binary": {
"calculated": false,
"default": "/usr/sbin/nginx",
"type": "string",
"choice": [
],
"description": "Location of the nginx server binary",
"display_name": "Nginx Binary",
"recipes": [
],
"required": "optional"
},
"nginx/worker_processes": {
"calculated": false,
"default": "1",
"type": "string",
"choice": [
],
"description": "Number of worker processes",
"display_name": "Nginx Worker Processes",
"recipes": [
],
"required": "optional"
},
"nginx/gzip_http_version": {
"calculated": false,
"default": "1.0",
"type": "string",
"choice": [
],
"description": "Version of HTTP Gzip",
"display_name": "Nginx Gzip HTTP Version",
"recipes": [
],
"required": "optional"
},
"nginx/server_names_hash_bucket_size": {
"calculated": false,
"default": "64",
"type": "string",
"choice": [
],
"display_name": "Nginx Server Names Hash Bucket Size",
"recipes": [
],
"required": "optional"
},
"nginx/log_dir": {
"calculated": false,
"default": "/var/log/nginx",
"type": "string",
"choice": [
],
"description": "Location for nginx logs",
"display_name": "Nginx Log Directory",
"recipes": [
],
"required": "optional"
},
"nginx/keepalive": {
"calculated": false,
"default": "on",
"type": "string",
"choice": [
],
"description": "Whether to enable keepalive",
"display_name": "Nginx Keepalive",
"recipes": [
],
"required": "optional"
},
"nginx/gzip": {
"calculated": false,
"default": "on",
"type": "string",
"choice": [
],
"description": "Whether gzip is enabled",
"display_name": "Nginx Gzip",
"recipes": [
],
"required": "optional"
},
"nginx/worker_connections": {
"calculated": false,
"default": "1024",
"type": "string",
"choice": [
],
"description": "Number of connections per worker",
"display_name": "Nginx Worker Connections",
"recipes": [
],
"required": "optional"
}
},
"conflicting": {
},
"license": "Apache 2.0",
"providing": {
}
}
\ No newline at end of file
maintainer "Opscode, Inc."
maintainer_email "cookbooks@opscode.com"
license "Apache 2.0"
description "Installs and configures nginx"
version "0.10"
%w{ ubuntu debian }.each do |os|
supports os
end
%w{ build-essential runit }.each do |cb|
depends cb
end
attribute "nginx/dir",
:display_name => "Nginx Directory",
:description => "Location of nginx configuration files",
:default => "/etc/nginx"
attribute "nginx/log_dir",
:display_name => "Nginx Log Directory",
:description => "Location for nginx logs",
:default => "/var/log/nginx"
attribute "nginx/user",
:display_name => "Nginx User",
:description => "User nginx will run as",
:default => "www-data"
attribute "nginx/binary",
:display_name => "Nginx Binary",
:description => "Location of the nginx server binary",
:default => "/usr/sbin/nginx"
attribute "nginx/gzip",
:display_name => "Nginx Gzip",
:description => "Whether gzip is enabled",
:default => "on"
attribute "nginx/gzip_http_version",
:display_name => "Nginx Gzip HTTP Version",
:description => "Version of HTTP Gzip",
:default => "1.0"
attribute "nginx/gzip_comp_level",
:display_name => "Nginx Gzip Compression Level",
:description => "Amount of compression to use",
:default => "2"
attribute "nginx/gzip_proxied",
:display_name => "Nginx Gzip Proxied",
:description => "Whether gzip is proxied",
:default => "any"
attribute "nginx/gzip_types",
:display_name => "Nginx Gzip Types",
:description => "Supported MIME-types for gzip",
:type => "array",
:default => [ "text/plain", "text/html", "text/css", "application/x-javascript", "text/xml", "application/xml", "application/xml+rss", "text/javascript" ]
attribute "nginx/keepalive",
:display_name => "Nginx Keepalive",
:description => "Whether to enable keepalive",
:default => "on"
attribute "nginx/keepalive_timeout",
:display_name => "Nginx Keepalive Timeout",
:default => "65"
attribute "nginx/worker_processes",
:display_name => "Nginx Worker Processes",
:description => "Number of worker processes",
:default => "1"
attribute "nginx/worker_connections",
:display_name => "Nginx Worker Connections",
:description => "Number of connections per worker",
:default => "1024"
attribute "nginx/server_names_hash_bucket_size",
:display_name => "Nginx Server Names Hash Bucket Size",
:default => "64"
#
# Cookbook Name:: nginx
# Recipe:: default
# Author:: AJ Christensen <aj@junglist.gen.nz>
#
# Copyright 2008-2009, Opscode, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package "nginx"
directory node[:nginx][:log_dir] do
mode 0755
owner node[:nginx][:user]
action :create
end
%w{nxensite nxdissite}.each do |nxscript|
template "/usr/sbin/#{nxscript}" do