Permalink
Browse files

Merge branch 'master' of git://github.com/mbailey/deprec into mbailey…

…/master
  • Loading branch information...
thewoolleyman committed Oct 19, 2008
2 parents 9841762 + 873678a commit 110d67535bcd9a5649b746899ab0981aec9f42b1
View
@@ -1,5 +1,32 @@
-== SVN
+== git
+* Restricted tasks to roles. [mbailey]
+ http://github.com/mbailey/deprec/commit/d103dda7ee3f7696007d230c76c7739dd57115ec
+
+* Extend capistrano_extensions.rb to allow install from git sources. [jasherai]
+
+* Updated git to 1.6.0.1 [thornysun]
+
+== 1.99.27 (August 27, 2008)
+
+* Bugfix: Add configure and make options to src_package for rubygems to
+ override defaults. [jasherai]
+
+* Change: We now setup postfix as a satellite mail server. This is designed
+ to listen only on the local network interface and non-local mail to a relay
+ host. [mbailey]
+
+== 1.99.26 (August 22, 2008)
+
+* added vnstat recipes - measure and report traffic on interface counters [mbailey]
+* upgrade ruby to 1.8.6-p287 [Isaac Kearse]
+* upgrade to rubygems 1.2.0 - addresses memory utilization issues on
+ low-memory boxes (half-gig or less) [thewoolleyman]
+* deprec:rails:install_stack now installs mysql [mbailey]
+* turned tcp_nopush back on [mbailey]
+* Correctly handle tarballs with .tgz extension [mbailey]
+* Generate default remote config on install [mbailey]
+
== 1.99.24 (July 7, 2008)
* I've rejigged things to make it easier to install a service without having
View
@@ -2,7 +2,7 @@ require 'rubygems'
SPEC = Gem::Specification.new do |s|
s.name = 'deprec'
- s.version = '1.99.25'
+ s.version = '1.99.27'
s.authors = ['Mike Bailey']
s.description = <<-EOF
@@ -4,12 +4,24 @@
module Deprec2
- # Temporarly set ROLES to something different
+ # Temporarily modify ROLES if HOSTS not set
+ # Capistrano's default behaviour is for HOSTS to override ROLES
def for_roles(roles)
old_roles = ENV['ROLES']
- ENV['ROLES'] = roles
+ ENV['ROLES'] = roles.to_s unless ENV['HOSTS']
+ yield
+ ENV['ROLES'] = old_roles.to_s unless ENV['HOSTS']
+ end
+
+ # Temporarily ignore ROLES and HOSTS
+ def ignoring_roles_and_hosts
+ old_roles = ENV['ROLES']
+ old_hosts = ENV['HOSTS']
+ ENV['ROLES'] = nil
+ ENV['HOSTS'] = nil
yield
ENV['ROLES'] = old_roles
+ ENV['HOSTS'] = old_hosts
end
DEPREC_TEMPLATES_BASE = File.join(File.dirname(__FILE__), 'templates')
@@ -242,35 +254,63 @@ def download_src(src_package, src_dir)
if defined?(src_package[:md5sum])
md5_clause = " && echo '#{src_package[:md5sum]}' | md5sum -c - "
end
- apt.install( {:base => %w(wget)}, :stable )
- # XXX replace with invoke_command
- run "cd #{src_dir} && test -f #{src_package[:filename]} #{md5_clause} || #{sudo} wget --quiet --timestamping #{src_package[:url]}"
+ case src_package[:download_method]
+ # when getting source with git
+ when :git
+ # ensure git is installed
+ apt.install( {:base => %w(git-core)}, :stable) #TODO fix this to test ubuntu version <hardy might need specific git version for full git submodules support
+ package_dir = File.join(src_dir, src_package[:dir])
+ run "if [ -d #{package_dir} ]; then cd #{package_dir} && #{sudo} git pull && #{sudo} git submodule init && #{sudo} git submodule update; else #{sudo} git clone #{src_package[:url]} #{package_dir} && cd #{package_dir} && #{sudo} git submodule init && #{sudo} git submodule update ; fi"
+ # Checkout the revision wanted if defined
+ invoke_command "cd #{package_dir} && git co #{src_package[:version]}", :via => :via if src_package[:version]
+ # when getting source with wget
+ when :http
+ # ensure wget is installed
+ apt.install( {:base => %w(wget)}, :stable )
+ # XXX replace with invoke_command
+ run "cd #{src_dir} && test -f #{src_package[:filename]} #{md5_clause} || #{sudo} wget --quiet --timestamping #{src_package[:url]}"
+ else
+ puts "DOWNLOAD SRC: Download method not recognised. src_package[:download_method]: #{src_package[:download_method]}"
+ end
end
# unpack src and make it writable by the group
def unpack_src(src_package, src_dir)
set_package_defaults(src_package)
package_dir = File.join(src_dir, src_package[:dir])
- # XXX replace with invoke_command
+ case src_package[:download_method]
+ # when unpacking git sources - nothing to do
+ when :git
+ puts "UNPACK SRC: nothing to do for git installs"
+ when :http
+ sudo <<-EOF
+ bash -c '
+ cd #{src_dir};
+ test -d #{package_dir}.old && rm -fr #{package_dir}.old;
+ test -d #{package_dir} && mv #{package_dir} #{package_dir}.old;
+ #{src_package[:unpack]}
+ '
+ EOF
+ else
+ puts "UNPACK SRC: Download method not recognised. src_package[:download_method]: #{src_package[:download_method]} "
+ end
sudo <<-EOF
bash -c '
cd #{src_dir};
- test -d #{package_dir}.old && rm -fr #{package_dir}.old;
- test -d #{package_dir} && mv #{package_dir} #{package_dir}.old;
- #{src_package[:unpack]}
chgrp -R #{group} #{package_dir};
chmod -R g+w #{package_dir};
'
EOF
end
-
+
def set_package_defaults(pkg)
- pkg[:filename] ||= File.basename(pkg[:url])
- pkg[:dir] ||= pkg[:filename].sub(/(\.tgz|\.tar\.gz)/,'')
- pkg[:unpack] ||= "tar zxf #{pkg[:filename]};"
- pkg[:configure] ||= './configure ;'
- pkg[:make] ||= 'make;'
- pkg[:install] ||= 'make install;'
+ pkg[:filename] ||= File.basename(pkg[:url])
+ pkg[:dir] ||= pkg[:filename].sub(/(\.tgz|\.tar\.gz)/,'')
+ pkg[:download_method] ||= :http
+ pkg[:unpack] ||= "tar zxf #{pkg[:filename]};"
+ pkg[:configure] ||= './configure ;'
+ pkg[:make] ||= 'make;'
+ pkg[:install] ||= 'make install;'
end
# install package from source
@@ -388,4 +428,4 @@ def handle_command_with_input(local_run_method, shell_command, input_query, resp
end
-Capistrano.plugin :deprec2, Deprec2
+Capistrano.plugin :deprec2, Deprec2
View
@@ -32,6 +32,8 @@
require "#{File.dirname(__FILE__)}/recipes/logrotate"
require "#{File.dirname(__FILE__)}/recipes/utils"
require "#{File.dirname(__FILE__)}/recipes/git"
+require "#{File.dirname(__FILE__)}/recipes/apt_mirror"
# require "#{File.dirname(__FILE__)}/recipes/pdns"
require "#{File.dirname(__FILE__)}/recipes/gitosis"
+require "#{File.dirname(__FILE__)}/recipes/wordpress"
require "#{File.dirname(__FILE__)}/recipes/ar_sendmail"
View
@@ -2,75 +2,74 @@
Capistrano::Configuration.instance(:must_exist).load do
SRC_PACKAGES[:aoe] = {
- :filename => 'aoe6-56.tar.gz',
- :md5sum => "93689aaad32f647a788c15c82bd0158e aoe6-56.tar.gz",
- :dir => 'aoe6-56',
- :url => "http://www.coraid.com/support/linux/aoe6-56.tar.gz",
- :unpack => "tar zxf aoe6-56.tar.gz;",
- :make => 'make;',
- :install => 'make install;'
+ :url => "http://support.coraid.com/support/linux/aoe6-64.tar.gz",
+ :md5sum => "c5e1ebb734e3b29c0a3d886a700ca44a aoe6-64.tar.gz",
+ :configure => ''
+ }
+
+ SRC_PACKAGES[:cec] = {
+ :url => "http://easynews.dl.sourceforge.net/sourceforge/aoetools/cec-8.tgz",
+ :md5sum => "7899dc549f9a368e532f9c39ed819f71 cec-8.tgz",
+ :configure => '',
+ :install => "test -f /usr/sbin/cec && rm /usr/sbin/cec; make install;"
+ }
+
+ SRC_PACKAGES[:ddt] = {
+ :url => "http://support.coraid.com/support/sr/ddt-8.tgz",
+ :md5sum => "256a58aba5e05f9995fb9de6aadadf92 ddt-8.tgz"
+ }
+
+ SRC_PACKAGES[:aoemask] = {
+ :url => "http://support.coraid.com/support/sr/aoemask-1.tgz",
+ :md5sum => "379461a28d511e269f4593b846bd1288 aoemask-1.tgz"
}
namespace :deprec do
namespace :aoe do
-
+
desc "Install aoe drivers required to mount Coraid block devices"
- task :install do
+ task :install, :roles => :aoe do
install_deps
deprec2.download_src(SRC_PACKAGES[:aoe], src_dir)
deprec2.install_from_src(SRC_PACKAGES[:aoe], src_dir)
end
- task :install_deps do
+ task :install_deps, :roles => :aoe do
apt.install( {:base => %w(build-essential linux-headers-$(uname -r) vblade aoetools)}, :stable )
end
-
+
+ desc "Install all AoE related software"
+ task :install_all, :roles => :aoe do
+ top.deprec.aoe.install
+ top.deprec.cec.install
+ top.deprec.ddt.install
+ top.deprec.aoemask.install
+ end
+
end
-
- SRC_PACKAGES[:cec] = {
- :url => "http://easynews.dl.sourceforge.net/sourceforge/aoetools/cec-8.tgz",
- :md5sum => "7899dc549f9a368e532f9c39ed819f71 cec-8.tgz"
- }
-
namespace :cec do
-
desc "install CEC (Coraid Ethernet Console)"
- task :install do
+ task :install, :roles => :aoe do
deprec2.download_src(SRC_PACKAGES[:cec], src_dir)
deprec2.install_from_src(SRC_PACKAGES[:cec], src_dir)
end
-
end
- SRC_PACKAGES[:ddt] = {
- :url => "http://support.coraid.com/support/sr/ddt-6.tgz",
- :md5sum => "5e1e8a58a8621b93440be605113f7bc0 ddt-6.tgz"
- }
-
namespace :ddt do
-
desc "install DDT (tool for testing performance)"
- task :install do
+ task :install, :roles => :aoe do
deprec2.download_src(SRC_PACKAGES[:ddt], src_dir)
deprec2.install_from_src(SRC_PACKAGES[:ddt], src_dir)
end
-
end
- SRC_PACKAGES[:aoemask] = {
- :url => "http://support.coraid.com/support/sr/aoemask-1.tgz",
- :md5sum => "379461a28d511e269f4593b846bd1288 aoemask-1.tgz"
- }
-
namespace :aoemask do
-
desc "install aoemask"
- task :install do
+ task :install, :roles => :aoe do
deprec2.download_src(SRC_PACKAGES[:aoemask], src_dir)
deprec2.install_from_src(SRC_PACKAGES[:aoemask], src_dir)
end
-
end
end
@@ -0,0 +1,99 @@
+# Copyright 2006-2008 by Mike Bailey. All rights reserved.
+Capistrano::Configuration.instance(:must_exist).load do
+ # ref: http://www.howtoforge.com/local_debian_ubuntu_mirror
+ namespace :deprec do
+
+ set :apt_mirror_hostname, 'archive.ubuntu.com'
+ set :apt_releases_to_mirror, %w(gutsy)
+
+ namespace :apt_normal do # XXX Find a better name
+ # :apt was clashing with the vmbuilder plugin
+
+ SYSTEM_CONFIG_FILES[:apt] = [
+
+ {:template => 'sources.list',
+ :path => '/etc/apt/sources.list',
+ :mode => 0755,
+ :owner => 'root:root'}
+ ]
+
+ desc <<-DESC
+ Generate apt config from template. Note that this does not
+ push the config to the server, it merely generates required
+ configuration files. These should be kept under source control.
+ The can be pushed to the server with the :config task.
+ DESC
+ task :config_gen do
+ SYSTEM_CONFIG_FILES[:apt].each do |file|
+ deprec2.render_template(:apt, file)
+ end
+ end
+
+ desc "Push apt_mirror config files to server"
+ task :config do
+ deprec2.push_configs(:apt, SYSTEM_CONFIG_FILES[:apt])
+ end
+
+ end
+
+ namespace :apt_mirror do
+
+ desc "Install apt-mirror"
+ task :install, :roles => :apt_mirror do
+ install_deps
+ SYSTEM_CONFIG_FILES[:apt_mirror].each do |file|
+ deprec2.render_template(:apt_mirror, file.merge(:remote => true))
+ end
+ activate
+ end
+
+ # install dependencies for apt_mirror
+ task :install_deps do
+ apt.install( {:base => %w(apt-mirror apache2 cron)}, :stable )
+ end
+
+ SYSTEM_CONFIG_FILES[:apt_mirror] = [
+
+ {:template => 'mirror.list',
+ :path => '/etc/apt/mirror.list',
+ :mode => 0755,
+ :owner => 'root:root'},
+
+ {:template => 'apt-mirror-cron',
+ :path => '/etc/cron.d/apt-mirror',
+ :mode => 0755,
+ :owner => 'root:root'}
+ ]
+
+ desc <<-DESC
+ Generate apt_mirror config from template. Note that this does not
+ push the config to the server, it merely generates required
+ configuration files. These should be kept under source control.
+ The can be pushed to the server with the :config task.
+ DESC
+ task :config_gen do
+ SYSTEM_CONFIG_FILES[:apt_mirror].each do |file|
+ deprec2.render_template(:apt_mirror, file)
+ end
+ end
+
+ desc "Push apt_mirror config files to server"
+ task :config, :roles => :apt_mirror do
+ deprec2.push_configs(:apt_mirror, SYSTEM_CONFIG_FILES[:apt_mirror])
+ end
+
+ # Create mirror for the first time
+ #
+ # su - apt-mirror -c apt-mirror
+
+ # Add cron job to update
+
+ # Symlink for apache
+ # ln -s /var/spool/apt-mirror/mirror/de.archive.ubuntu.com/ubuntu /var/www/ubuntu
+
+ # Update sources.list on all hosts:
+ # deb http://192.168.0.100/ubuntu/ gutsy main restricted universe
+
+ end
+ end
+end
Oops, something went wrong.

0 comments on commit 110d675

Please sign in to comment.