Skip to content
This repository has been archived by the owner on Nov 23, 2017. It is now read-only.

Commit

Permalink
COOK-31, added trac support customizable via attributes.
Browse files Browse the repository at this point in the history
  * Supports SVN out of the box
  * Uses the configuration from SVN if on the node.
  * has deflate support
  * does not configure SSL out of the box
  • Loading branch information
pcross616 authored and jtimberman committed Aug 24, 2010
1 parent 1d8d06d commit c8fd674
Show file tree
Hide file tree
Showing 9 changed files with 494 additions and 0 deletions.
1 change: 1 addition & 0 deletions NOTICE
Expand Up @@ -14,3 +14,4 @@ Contributors and Copyright holders:
* Copyright 2009, Joshua Sierles <joshua@37signals.com>
* Copyright 2009, Matthew Kent <mkent@magoazul.com>
* Copyright 2010, Benjamin Black <b@b3k.us>
* Copyright 2009, Peter Crossley <peterc@xley.com>
29 changes: 29 additions & 0 deletions trac/README.rdoc
@@ -0,0 +1,29 @@
= DESCRIPTION:

Installs trac software and creates an environment with an Apache2 virtual host.

= USAGE:

Include the recipe 'trac' in the run list.

This cookbook does not:

- Set up the subversion repository

You may also need to enable the authentication mechanism of your preference in the trac.conf.erb template.

= LICENSE AND AUTHOR:

Copyright 2009, Peter Crossley <peterc@xley.com>

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.
28 changes: 28 additions & 0 deletions trac/attributes/trac.rb
@@ -0,0 +1,28 @@
# Cookbook Name:: trac
# Attribute :: trac
#
# Copyright 2009 Peter Crossley <peterc@xley.com>
#
# 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.0c
#
# 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.
#
default[:trac] = {}
default[:trac][:project_name] = "Code :: Trac"
default[:trac][:project_description] = ""
default[:trac][:basedir] = "/srv/trac"
default[:trac][:mainnav] = ["wiki","timeline","roadmap","browser","tickets","newticket","search"]
default[:trac][:metanav] = ["login","logout","prefs","help","about"]
default[:trac][:vhosts] = fqdn
default[:trac][:required_groups] = []
default[:trac][:svn_dir] = "/srv/svn/code-trac"
default[:trac][:svn_branches] = [""]
default[:trac][:svn_tags] = [""]
40 changes: 40 additions & 0 deletions trac/metadata.json
@@ -0,0 +1,40 @@
{
"recipes": {
"trac": ""
},
"replacing": {

},
"version": "0.1.0",
"platforms": {

},
"maintainer": "Peter Crossley",
"description": "Installs/Configures Trac",
"recommendations": {

},
"maintainer_email": "peterc@xley.com",
"suggestions": {

},
"conflicting": {

},
"dependencies": {
"apache2": [

]
},
"name": "trac",
"attributes": {

},
"providing": {
"trac": [

]
},
"license": "Apache 2.0",
"long_description": "= DESCRIPTION:\n\n= REQUIREMENTS:\n\n= ATTRIBUTES: \n\n= USAGE:\n\n"
}
7 changes: 7 additions & 0 deletions trac/metadata.rb
@@ -0,0 +1,7 @@
maintainer "Peter Crossley"
maintainer_email "peterc@xley.com"
license "Apache 2.0"
description "Installs/Configures Trac"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc'))
version "0.1"
depends "apache2"
113 changes: 113 additions & 0 deletions trac/recipes/default.rb
@@ -0,0 +1,113 @@
#
# Cookbook Name:: trac
# Recipe:: default
#
# Copyright 2009, Peter Crossley <peterc@xley.com>
#
# 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.
#

include_recipe "apache2"
include_recipe "apache2::mod_rewrite"
include_recipe "apache2::mod_fcgid"
include_recipe "apache2::mod_deflate"


package "trac" do
action :upgrade
end

directory node[:trac][:basedir] do
owner "root"
group "root"
mode 0755
end

directory "#{node[:trac][:basedir]}/cgi-bin" do
owner "root"
group "root"
mode 0755
end

template "trac-fcgi" do
path "#{node[:trac][:basedir]}/cgi-bin/trac.fcgi"
source "trac.fcgi.erb"
owner "root"
group "root"
mode 0755
variables(
:trac_environment => "#{node[:trac][:basedir]}/environment"
)
end

execute "trac-environment" do
command "trac-admin #{node[:trac][:basedir]}/environment initenv '#{node[:trac][:project_name]}' 'sqlite:db/trac.db' svn #{node[:trac][:svn_dir]}"
only_if "/usr/bin/test ! -d #{node[:trac][:basedir]}/environment"
end

directory "#{node[:trac][:basedir]}/environment" do
owner "www-data"
group "www-data"
recursive true
end

execute "trac-owner-change" do
command "chown -Rf www-data:www-data #{node[:trac][:basedir]}/environment"
end

template "trac-ini" do
path "#{node[:trac][:basedir]}/environment/conf/trac.ini"
source "trac.ini.erb"
owner "www-data"
group "www-data"
mode 0775
variables(
:trac_project_desc => node[:trac][:project_description],
:trac_project_name => node[:trac][:project_name],
:trac_mainnav => node[:trac][:mainnav],
:trac_metanav => node[:trac][:metanav],
:trac_url => node[:trac][:vhosts].first,
:trac_svn_branches => node[:trac][:svn_branches],
:trac_svn_tags => node[:trac][:svn_tags],
:trac_svn_repo => node[:trac][:svn_dir]
)
end

template "trac-conf" do
path "/etc/apache2/sites-available/trac.conf"
source "trac.conf.erb"
owner "root"
group "root"
mode 0644
variables(
:trac_dir => node[:trac][:basedir],
:trac_project_name => node[:trac][:project_name],
:trac_required_groups => node[:trac][:required_groups],
:trac_vhosts => node[:trac][:vhosts]
)
end

apache_site "trac.conf"

apache_site "default" do
action :disable
end

# help keep the repo in sync
cron "trac-sync" do
minute "0"
command "trac-admin #{node[:trac][:basedir]}/environment resync"
user "www-data"
only_if do File.exists?("#{node[:trac][:basedir]}/environment") end
end

51 changes: 51 additions & 0 deletions trac/templates/default/trac.conf.erb
@@ -0,0 +1,51 @@
<VirtualHost *:80>
DocumentRoot <%= @trac_dir %>
ServerAdmin ops@<%= @node[:domain] %>
ServerName <%=@trac_vhosts.first %>
<% @trac_vhosts.each do | vhost | %>
ServerAlias <%=vhost%>
<% end %>

ErrorLog /var/log/apache2/trac-error.log
TransferLog /var/log/apache2/trac-access.log

#DefaultMaxClassProcessCount 5

Alias / <%= @trac_dir %>/cgi-bin/trac.fcgi/

<IfModule mod_authnz_external.c>
AddExternalAuth pwauth /usr/sbin/pwauth
SetExternalAuthMethod pwauth pipe
SetExternalGroupMethod unixgroup environment

<Location />
AuthName "<%= @trac_project_name %>"
AuthType Basic
AuthBasicProvider external
AuthExternal pwauth
GroupExternal unixgroup
Options ExecCGI FollowSymLinks Indexes
Order allow,deny
Allow from all
<% @trac_required_groups.each do |group| %>
require ldap-group <%= group %>
<% end -%>

require valid-user
</Location>
</IfModule>

# / is aliased to fastcgi above
<Directory "/usr/share/pyshared/trac/htdocs">
Order allow,deny
Allow from all
</Directory>

<Directory "<%= @trac_dir %>/htdocs">
Order allow,deny
Allow from all
</Directory>

AddOutputFilterByType DEFLATE text/html text/plain text/xml

</VirtualHost>
38 changes: 38 additions & 0 deletions trac/templates/default/trac.fcgi.erb
@@ -0,0 +1,38 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2003-2004 Edgewall Software
# Copyright (C) 2003-2004 Jonas Borgström <jonas@edgewall.com>
# All rights reserved.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at http://trac.edgewall.org/wiki/TracLicense.
#
# This software consists of voluntary contributions made by many
# individuals. For the exact contribution history, see the revision
# history and logs, available at http://trac.edgewall.org/log/.
#
# Author: Jonas Borgström <jonas@edgewall.com>

import os
os.environ['TRAC_ENV'] = "<%= @trac_environment %>"

try:
from trac.web import fcgi_frontend
fcgi_frontend.run()
except SystemExit:
raise
except Exception, e:
print 'Content-Type: text/plain\r\n\r\n',
print 'Oops...'
print
print 'Trac detected an internal error:'
print
print e
print
import traceback
import StringIO
tb = StringIO.StringIO()
traceback.print_exc(file=tb)
print tb.getvalue()

0 comments on commit c8fd674

Please sign in to comment.