From c8fd674ed2d198188a93cb532516ab2844d46bd9 Mon Sep 17 00:00:00 2001 From: Peter Crossley Date: Fri, 30 Oct 2009 14:13:48 -0700 Subject: [PATCH] COOK-31, added trac support customizable via attributes. * 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 --- NOTICE | 1 + trac/README.rdoc | 29 +++++ trac/attributes/trac.rb | 28 ++++ trac/metadata.json | 40 ++++++ trac/metadata.rb | 7 + trac/recipes/default.rb | 113 ++++++++++++++++ trac/templates/default/trac.conf.erb | 51 ++++++++ trac/templates/default/trac.fcgi.erb | 38 ++++++ trac/templates/default/trac.ini.erb | 187 +++++++++++++++++++++++++++ 9 files changed, 494 insertions(+) create mode 100644 trac/README.rdoc create mode 100644 trac/attributes/trac.rb create mode 100644 trac/metadata.json create mode 100644 trac/metadata.rb create mode 100644 trac/recipes/default.rb create mode 100644 trac/templates/default/trac.conf.erb create mode 100644 trac/templates/default/trac.fcgi.erb create mode 100644 trac/templates/default/trac.ini.erb diff --git a/NOTICE b/NOTICE index 25814dcb6..6a6c8e2a5 100644 --- a/NOTICE +++ b/NOTICE @@ -14,3 +14,4 @@ Contributors and Copyright holders: * Copyright 2009, Joshua Sierles * Copyright 2009, Matthew Kent * Copyright 2010, Benjamin Black + * Copyright 2009, Peter Crossley diff --git a/trac/README.rdoc b/trac/README.rdoc new file mode 100644 index 000000000..cbd3e2fc3 --- /dev/null +++ b/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 + +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. diff --git a/trac/attributes/trac.rb b/trac/attributes/trac.rb new file mode 100644 index 000000000..15f6637b9 --- /dev/null +++ b/trac/attributes/trac.rb @@ -0,0 +1,28 @@ +# Cookbook Name:: trac +# Attribute :: trac +# +# Copyright 2009 Peter Crossley +# +# 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] = [""] diff --git a/trac/metadata.json b/trac/metadata.json new file mode 100644 index 000000000..b5f1fabcd --- /dev/null +++ b/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" +} diff --git a/trac/metadata.rb b/trac/metadata.rb new file mode 100644 index 000000000..24e9e1dd4 --- /dev/null +++ b/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" diff --git a/trac/recipes/default.rb b/trac/recipes/default.rb new file mode 100644 index 000000000..398cec132 --- /dev/null +++ b/trac/recipes/default.rb @@ -0,0 +1,113 @@ +# +# Cookbook Name:: trac +# Recipe:: default +# +# Copyright 2009, Peter Crossley +# +# 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 + diff --git a/trac/templates/default/trac.conf.erb b/trac/templates/default/trac.conf.erb new file mode 100644 index 000000000..ce1d88cd3 --- /dev/null +++ b/trac/templates/default/trac.conf.erb @@ -0,0 +1,51 @@ + + 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/ + + + AddExternalAuth pwauth /usr/sbin/pwauth + SetExternalAuthMethod pwauth pipe + SetExternalGroupMethod unixgroup environment + + + 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 + + + + # / is aliased to fastcgi above + + Order allow,deny + Allow from all + + + /htdocs"> + Order allow,deny + Allow from all + + + AddOutputFilterByType DEFLATE text/html text/plain text/xml + + diff --git a/trac/templates/default/trac.fcgi.erb b/trac/templates/default/trac.fcgi.erb new file mode 100644 index 000000000..ae5932fd8 --- /dev/null +++ b/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 +# 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 + +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() diff --git a/trac/templates/default/trac.ini.erb b/trac/templates/default/trac.ini.erb new file mode 100644 index 000000000..06358746b --- /dev/null +++ b/trac/templates/default/trac.ini.erb @@ -0,0 +1,187 @@ +# -*- coding: utf-8 -*- + +[attachment] +max_size = 262144 +render_unsafe_content = false + +[browser] +color_scale = True +downloadable_paths = * +hide_properties = svk:merge +intermediate_color = +intermediate_point = +newest_color = (255, 136, 136) +oldest_color = (136, 136, 255) +oneliner_properties = trac:summary +render_unsafe_content = false +wiki_properties = trac:description + +[changeset] +max_diff_bytes = 10000000 +max_diff_files = 0 +wiki_format_messages = true + +[header_logo] +alt = (please configure the [header_logo] section in trac.ini) +height = -1 +link = +src = site/your_project_logo.png +width = -1 + +[inherit] +plugins_dir = +templates_dir = + +[logging] +log_file = trac.log +# log_format = +log_level = DEBUG +log_type = none + +[milestone] +stats_provider = DefaultTicketGroupStatsProvider + +[mimeviewer] +enscript_modes = text/x-dylan:dylan:4 +enscript_path = enscript +max_preview_size = 262144 +mime_map = text/x-dylan:dylan,text/x-idl:ice,text/x-ada:ads:adb +php_path = php +pygments_default_style = trac +pygments_modes = +tab_width = 8 +treat_as_binary = application/octet-stream,application/pdf,application/postscript,application/rtf + +[notification] +admit_domains = +always_notify_owner = false +always_notify_reporter = false +always_notify_updater = true +ignore_domains = +mime_encoding = none +smtp_always_bcc = +smtp_always_cc = +smtp_default_domain = +smtp_enabled = false +smtp_from = trac@<%= @node[:domain] %> +smtp_from_name = +smtp_password = +smtp_port = 25 +smtp_replyto = trac@<%= @node[:domain] %> +smtp_server = localhost +smtp_subject_prefix = __default__ +smtp_user = +ticket_subject_template = $prefix #$ticket.id: $summary +use_public_cc = false +use_short_addr = false +use_tls = false + +[project] +admin = +admin_trac_url = . +descr = <%= @trac_project_desc %> +footer = Visit the Trac open source project at
http://trac.edgewall.org/ +icon = common/trac.ico +name = <%= @trac_project_name %> +url = <%= @trac_url %> + +[query] +default_anonymous_query = status!=closed&cc~=$USER +default_query = status!=closed&owner=$USER +items_per_page = 100 + +[report] +items_per_page = 100 +items_per_page_rss = 0 + +[revisionlog] +default_log_limit = 100 + +[roadmap] +stats_provider = DefaultTicketGroupStatsProvider + +[search] +min_query_length = 3 + +[svn] +branches = <%= @trac_svn_branches.join(',') %> +tags = <%= @trac_svn_tags.join(',') %> + +[ticket] +default_cc = +default_component = +default_description = +default_keywords = +default_milestone = +default_owner = +default_priority = major +default_resolution = fixed +default_severity = +default_summary = +default_type = defect +default_version = +max_comment_size = 262144 +max_description_size = 262144 +preserve_newlines = default +restrict_owner = false +workflow = ConfigurableTicketWorkflow + +[ticket-workflow] +accept = new,assigned,accepted,reopened -> accepted +accept.operations = set_owner_to_self +accept.permissions = TICKET_MODIFY +leave = * -> * +leave.default = 1 +leave.operations = leave_status +reassign = new,assigned,accepted,reopened -> assigned +reassign.operations = set_owner +reassign.permissions = TICKET_MODIFY +reopen = closed -> reopened +reopen.operations = del_resolution +reopen.permissions = TICKET_CREATE +resolve = new,assigned,accepted,reopened -> closed +resolve.operations = set_resolution +resolve.permissions = TICKET_MODIFY + +[timeline] +abbreviated_messages = True +changeset_collapse_events = false +changeset_long_messages = false +changeset_show_files = 0 +default_daysback = 30 +max_daysback = 90 +newticket_formatter = oneliner +ticket_show_details = false + +[trac] +authz_file = +authz_module_name = +auto_reload = False +backup_dir = db +base_url = +check_auth_ip = false +database = sqlite:db/trac.db +debug_sql = False +default_charset = iso-8859-15 +htdocs_location = +ignore_auth_case = false +mainnav = <%= @trac_mainnav.join(',') %> +metanav = <%= @trac_metanav.join(',') %> +mysqldump_path = mysqldump +permission_policies = DefaultPermissionPolicy, LegacyAttachmentPolicy +permission_store = DefaultPermissionStore +pg_dump_path = pg_dump +repository_dir = <%= @trac_svn_repo %> +repository_type = svn +secure_cookies = False +show_email_addresses = false +show_ip_addresses = false +timeout = 20 +use_base_url_for_redirect = False + +[wiki] +ignore_missing_pages = false +max_size = 262144 +render_unsafe_content = false +split_page_names = false +