deprec 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,5 +1,20 @@
1
1
  == git
2
2
 
3
+ == 2.0.2 (March 3, 2009)
4
+
5
+ * Change owner of config/environment.rb to the value of app_user after deploy
6
+ so Passenger will run app as this user [mbailey]
7
+
8
+ * bugfix: set homedir for app_user account to value of deploy_to.
9
+ Passenger complains if homedir for user it runs as doesn't exist. [mbailey]
10
+
11
+ * Run the database rake tasks on the app server, not the db server. [mbailey]
12
+ e.g. cap deprec:database:schema_load
13
+
14
+ * Updated to ruby-enterprise-1.8.6-20090201
15
+
16
+ * Scan for ssh public key if not provided locally
17
+
3
18
 
4
19
  == 2.0.1 (February 20, 2009)
5
20
 
@@ -61,13 +61,13 @@ Capistrano::Configuration.instance(:must_exist).load do
61
61
  :mode => 0644,
62
62
  :owner => 'root:root'},
63
63
 
64
- {:template => 'nginx_vhost.erb',
64
+ {:template => 'nginx_vhost.conf.erb',
65
65
  :path => "nginx_vhost.conf",
66
66
  :mode => 0644,
67
67
  :owner => 'root:root'},
68
68
 
69
- {:template => 'apache_vhost.erb',
70
- :path => "apache_vhost",
69
+ {:template => 'apache_vhost.conf.erb',
70
+ :path => "apache_vhost.conf",
71
71
  :mode => 0644,
72
72
  :owner => 'root:root'}
73
73
 
@@ -111,11 +111,11 @@ Capistrano::Configuration.instance(:must_exist).load do
111
111
  end
112
112
 
113
113
  task :symlink_apache_vhost, :roles => :app do
114
- sudo "ln -sf #{deploy_to}/mongrel/apache_vhost #{apache_vhost_dir}/#{application}"
114
+ sudo "ln -sf #{deploy_to}/mongrel/apache_vhost.conf #{apache_vhost_dir}/#{application}.conf"
115
115
  end
116
116
 
117
117
  task :symlink_nginx_vhost, :roles => :app do
118
- sudo "ln -sf #{deploy_to}/mongrel/nginx_vhost #{nginx_vhost_dir}/#{application}"
118
+ sudo "ln -sf #{deploy_to}/mongrel/nginx_vhost.conf #{nginx_vhost_dir}/#{application}.conf"
119
119
  end
120
120
 
121
121
  task :symlink_monit_config, :roles => :app do
@@ -134,8 +134,13 @@ Capistrano::Configuration.instance(:must_exist).load do
134
134
  deprec2.push_configs(:passenger, PROJECT_CONFIG_FILES[:passenger])
135
135
  symlink_apache_vhost
136
136
  activate_project
137
+ set_ownership_of_environment_rb
137
138
  end
138
-
139
+
140
+ task :set_ownership_of_environment_rb, :roles => :app do
141
+ sudo "chown #{app_user} #{current_path}/config/environment.rb"
142
+ end
143
+
139
144
  task :symlink_apache_vhost, :roles => :app do
140
145
  sudo "ln -sf #{deploy_to}/passenger/apache_vhost #{apache_vhost_dir}/#{application}"
141
146
  end
@@ -62,19 +62,19 @@ Capistrano::Configuration.instance(:must_exist).load do
62
62
  # end
63
63
 
64
64
  default(:application) do
65
- Capistrano::CLI.ui.ask "enter name of project(no spaces)" do |q|
65
+ Capistrano::CLI.ui.ask "Enter name of project(no spaces)" do |q|
66
66
  q.validate = /^[0-9a-z_]*$/
67
67
  end
68
68
  end
69
69
 
70
70
  default(:domain) do
71
- Capistrano::CLI.ui.ask "enter domain name for project" do |q|
71
+ Capistrano::CLI.ui.ask "Enter domain name for project" do |q|
72
72
  q.validate = /^[0-9a-z_\.]*$/
73
73
  end
74
74
  end
75
75
 
76
76
  default(:repository) do
77
- Capistrano::CLI.ui.ask "enter repository URL for project" do |q|
77
+ Capistrano::CLI.ui.ask "Enter repository URL for project" do |q|
78
78
  # q.validate = //
79
79
  end
80
80
  end
@@ -39,7 +39,7 @@ Capistrano::Configuration.instance(:must_exist).load do
39
39
  deprec2.groupadd(nagios_cmd_group)
40
40
  deprec2.add_user_to_group(nagios_user, nagios_cmd_group)
41
41
  # Add apache user to nagios group to permit commands via web interface
42
- deprec2.add_user_to_group(apache_user, nagios_cmd_group)
42
+ deprec2.add_user_to_group('daemon', nagios_cmd_group)
43
43
  end
44
44
 
45
45
  # Install dependencies for nagios
@@ -125,7 +125,7 @@ Capistrano::Configuration.instance(:must_exist).load do
125
125
 
126
126
  desc "Push nagios config files to server"
127
127
  task :config, :roles => :nagios do
128
- set :application, 'nagios'
128
+ default :application, 'nagios'
129
129
  deprec2.push_configs(:nagios, SYSTEM_CONFIG_FILES[:nagios])
130
130
  sudo "ln -sf #{deploy_to}/nagios/conf/nagios_apache_vhost.conf /usr/local/apache2/conf/apps"
131
131
  config_check
@@ -302,4 +302,4 @@ Capistrano::Configuration.instance(:must_exist).load do
302
302
 
303
303
 
304
304
  end
305
- end
305
+ end
@@ -5,6 +5,7 @@ Capistrano::Configuration.instance(:must_exist).load do
5
5
  set(:app_user) { app_user_prefix + application }
6
6
  set :app_group_prefix, 'app_'
7
7
  set(:app_group) { app_group_prefix + application }
8
+ set(:app_user_homedir) { deploy_to }
8
9
  set :database_yml_in_scm, true
9
10
  set :app_symlinks, nil
10
11
  set :rails_env, 'production'
@@ -40,10 +41,8 @@ Capistrano::Configuration.instance(:must_exist).load do
40
41
  set_owner_of_environment_rb if web_server_type.to_s == 'passenger'
41
42
  end
42
43
 
43
- after :deploy, :roles => :app do
44
- deploy.cleanup
45
- end
46
-
44
+ after :deploy, "deploy:cleanup"
45
+
47
46
  namespace :deprec do
48
47
  namespace :rails do
49
48
 
@@ -163,7 +162,7 @@ Capistrano::Configuration.instance(:must_exist).load do
163
162
  deprec2.useradd(app_user, :group => app_group, :homedir => false)
164
163
  # Set the primary group for the user the application runs as (in case
165
164
  # user already existed when previous command was run)
166
- sudo "usermod --gid #{app_group} #{app_user}"
165
+ sudo "usermod --gid #{app_group} --home #{app_user_homedir} #{app_user}"
167
166
  end
168
167
 
169
168
  task :set_perms_on_shared_and_releases, :roles => :app do
@@ -294,22 +293,22 @@ Capistrano::Configuration.instance(:must_exist).load do
294
293
  namespace :database do
295
294
 
296
295
  desc "Create database"
297
- task :create, :roles => :db do
296
+ task :create, :roles => :app do
298
297
  run "cd #{deploy_to}/current && rake db:create RAILS_ENV=#{rails_env}"
299
298
  end
300
299
 
301
300
  desc "Run database migrations"
302
- task :migrate, :roles => :db do
301
+ task :migrate, :roles => :app do
303
302
  run "cd #{deploy_to}/current && rake db:migrate RAILS_ENV=#{rails_env}"
304
303
  end
305
304
 
306
305
  desc "Run database migrations"
307
- task :schema_load, :roles => :db do
306
+ task :schema_load, :roles => :app do
308
307
  run "cd #{deploy_to}/current && rake db:schema:load RAILS_ENV=#{rails_env}"
309
308
  end
310
309
 
311
310
  desc "Roll database back to previous migration"
312
- task :rollback, :roles => :db do
311
+ task :rollback, :roles => :app do
313
312
  run "cd #{deploy_to}/current && rake db:rollback RAILS_ENV=#{rails_env}"
314
313
  end
315
314
 
@@ -3,13 +3,13 @@ Capistrano::Configuration.instance(:must_exist).load do
3
3
  namespace :deprec do
4
4
  namespace :ree do
5
5
 
6
- set :ree_version, 'ruby-enterprise-1.8.6-20090113'
6
+ set :ree_version, 'ruby-enterprise-1.8.6-20090201'
7
7
  set :ree_install_dir, "/opt/#{ree_version}"
8
8
  set :ree_short_path, '/opt/ruby-enterprise'
9
9
 
10
10
  SRC_PACKAGES[:ree] = {
11
- :md5sum => "e8d796a5bae0ec1029a88ba95c5d901d #{ree_version}.tar.gz",
12
- :url => "http://rubyforge.org/frs/download.php/50087/#{ree_version}.tar.gz",
11
+ :md5sum => "a965e6789b553efaed72191825b13713 #{ree_version}.tar.gz",
12
+ :url => "http://rubyforge.org/frs/download.php/51100/#{ree_version}.tar.gz",
13
13
  :configure => '',
14
14
  :make => '',
15
15
  :install => "./installer --auto /opt/#{ree_version}"
@@ -62,9 +62,26 @@ Capistrano::Configuration.instance(:must_exist).load do
62
62
  end
63
63
  }
64
64
 
65
- if target_user == user
65
+ # If we have an authorized keys file for this user
66
+ # then copy that out
67
+ if File.exists?("config/ssh/authorized_keys/#{target_user}")
68
+ deprec2.mkdir "/home/#{target_user}/.ssh", :mode => 0700, :owner => "#{target_user}.users", :via => :sudo
69
+ std.su_put File.read("config/ssh/authorized_keys/#{target_user}"), "/home/#{target_user}/.ssh/authorized_keys", '/tmp/', :mode => 0600
70
+ sudo "chown #{target_user}.users /home/#{target_user}/.ssh/authorized_keys"
71
+
72
+ elsif target_user == user
73
+
74
+ # If the user has specified a key Capistrano should use
75
+ if ssh_options[:keys]
76
+ deprec2.mkdir '.ssh', :mode => 0700
77
+ put(ssh_options[:keys].collect{|key| File.read(key)}.join("\n"), '.ssh/authorized_keys', :mode => 0600 )
66
78
 
67
- unless ssh_options[:keys]
79
+ # Try to find the current users public key
80
+ elsif keys = %w[id_rsa id_dsa identity].collect { |f| "#{ENV['HOME']}/.ssh/#{f}.pub" if File.exists?("#{ENV['HOME']}/.ssh/#{f}.pub") }.compact
81
+ deprec2.mkdir '.ssh', :mode => 0700
82
+ put(keys.collect{|key| File.read(key)}.join("\n"), '.ssh/authorized_keys', :mode => 0600 )
83
+
84
+ else
68
85
  puts <<-ERROR
69
86
 
70
87
  You need to define the name of your SSH key(s)
@@ -75,17 +92,18 @@ Capistrano::Configuration.instance(:must_exist).load do
75
92
  ERROR
76
93
  exit
77
94
  end
78
-
79
- deprec2.mkdir '.ssh', :mode => 0700
80
- put(ssh_options[:keys].collect{|key| File.read(key+'.pub')}.join("\n"), '.ssh/authorized_keys', :mode => 0600 )
95
+ else
96
+ puts <<-ERROR
81
97
 
82
- else
98
+ Could not find ssh public key(s) for user #{user}
83
99
 
84
- deprec2.mkdir "/home/#{target_user}/.ssh", :mode => 0700, :owner => "#{target_user}.users", :via => :sudo
85
- std.su_put File.read("config/ssh/authorized_keys/#{target_user}"), "/home/#{target_user}/.ssh/authorized_keys", '/tmp/', :mode => 0600
86
- sudo "chown #{target_user}.users /home/#{target_user}/.ssh/authorized_keys"
100
+ Please create file containing ssh public keys in:
87
101
 
102
+ config/ssh/authorized_keys/#{target_user}
103
+
104
+ ERROR
88
105
  end
106
+
89
107
  end
90
108
 
91
109
  end
@@ -2,19 +2,34 @@
2
2
  Capistrano::Configuration.instance(:must_exist).load do
3
3
  namespace :deprec do
4
4
  namespace :ubuntu do
5
-
5
+
6
+ desc "apt-get update. Resynchronize the package index files from their sources."
6
7
  task :update do
7
8
  apt.update
8
9
  end
9
10
 
11
+ desc "apt-get upgrade. Install the newest versions of all packages currently
12
+ installed on the system from the sources enumerated in /etc/apt/sources.list.."
10
13
  task :upgrade do
11
14
  apt.upgrade
12
15
  end
13
16
 
17
+ desc "reboot the server"
14
18
  task :restart do
15
19
  sudo "reboot"
16
20
  end
17
21
 
22
+ desc "shut down the server"
23
+ task :shutdown do
24
+ sudo "shutdown -h now"
25
+ end
26
+
27
+ desc "Remove locks from aborted apt-get command."
28
+ task :remove_locks do
29
+ sudo "rm /var/lib/apt/lists/lock"
30
+ # XXX There's one more - add it!
31
+ end
32
+
18
33
  end
19
34
  end
20
- end
35
+ end
@@ -3,7 +3,7 @@ Capistrano::Configuration.instance(:must_exist).load do
3
3
 
4
4
  require 'digest'
5
5
 
6
- set :application, 'wordpress'
6
+ default :application, 'wordpress'
7
7
  set(:wordpress_domain) { Capistrano::CLI.ui.ask 'Enter domain wordpress will be served on' }
8
8
  set :db_name, 'wordpress'
9
9
  set :db_user, 'wordpress'
@@ -15,17 +15,20 @@ Capistrano::Configuration.instance(:must_exist).load do
15
15
  desc "Install Xen"
16
16
  task :install, :roles => :dom0 do
17
17
  install_deps
18
+ top.deprec.xentools.install
18
19
  disable_apparmour
19
20
  disable_tls
20
- enable_hardy_domu
21
+ # enable_hardy_domu Should only be run on gutsy
21
22
  initial_config
22
23
  end
23
24
 
24
25
  task :install_deps, :roles => :dom0 do
25
26
  # for amd64 version of ubuntu 7.10
26
- apt.install( {:base => %w(linux-image-xen bridge-utils libxen3.1 python-xen-3.1 xen-docs-3.1 xen-hypervisor-3.1 xen-ioemu-3.1 xen-tools xen-utils-3.1 lvm2)}, :stable )
27
+ # apt.install( {:base => %w(linux-image-xen bridge-utils libxen3.1 python-xen-3.1 xen-docs-3.1 xen-hypervisor-3.1 xen-ioemu-3.1 xen-tools xen-utils-3.1 lvm2)}, :stable )
27
28
  # alternatively, for x86 version of ubuntu:
28
29
  # apt-get install ubuntu-xen-server libc6-xen lvm2
30
+ apt.install( {:base => %w(ubuntu-xen-server libc6-xen lvm2)}, :stable )
31
+
29
32
  end
30
33
 
31
34
  task :disable_apparmour, :roles => :dom0 do
@@ -39,27 +42,27 @@ Capistrano::Configuration.instance(:must_exist).load do
39
42
 
40
43
  SYSTEM_CONFIG_FILES[:xen] = [
41
44
 
42
- {:template => "xend-config.sxp.erb",
43
- :path => '/etc/xen/xend-config.sxp',
44
- :mode => 0644,
45
- :owner => 'root:root'},
46
-
47
- {:template => "xendomains.erb",
48
- :path => '/etc/default/xendomains',
49
- :mode => 0755,
50
- :owner => 'root:root'},
51
-
45
+ # {:template => "xend-config.sxp.erb",
46
+ # :path => '/etc/xen/xend-config.sxp',
47
+ # :mode => 0644,
48
+ # :owner => 'root:root'},
49
+ #
50
+ # {:template => "xendomains.erb",
51
+ # :path => '/etc/default/xendomains',
52
+ # :mode => 0755,
53
+ # :owner => 'root:root'},
54
+ #
52
55
  # This gives you a second network bridge on second ethernet device
53
56
  {:template => "network-bridge-wrapper",
54
57
  :path => '/etc/xen/scripts/network-bridge-wrapper',
55
58
  :mode => 0755,
56
59
  :owner => 'root:root'},
57
-
58
- # Bugfix for gutsy - xendomains fails to shut down domains on system shutdown
59
- {:template => "xend-init.erb",
60
- :path => '/etc/init.d/xend',
61
- :mode => 0755,
62
- :owner => 'root:root'}
60
+ #
61
+ # # Bugfix for gutsy - xendomains fails to shut down domains on system shutdown
62
+ # {:template => "xend-init.erb",
63
+ # :path => '/etc/init.d/xend',
64
+ # :mode => 0755,
65
+ # :owner => 'root:root'}
63
66
 
64
67
  ]
65
68
 
@@ -68,7 +71,7 @@ Capistrano::Configuration.instance(:must_exist).load do
68
71
  # Non-standard! We're pushing these straight out
69
72
  SYSTEM_CONFIG_FILES[:xen].each do |file|
70
73
  deprec2.render_template(:xen, file.merge(:remote => true))
71
- end
74
+ end
72
75
  end
73
76
 
74
77
  desc "Generate configuration file(s) for Xen from template(s)"
@@ -87,7 +90,7 @@ Capistrano::Configuration.instance(:must_exist).load do
87
90
  # xen-create-image --force --ip=192.168.1.31 --hostname=x1 --mac=00:16:3E:11:12:31
88
91
 
89
92
  # Start a virtual image (and open console to it)
90
- # xm create -c /etc/xen/x1.cfg
93
+ # xm create /etc/xen/x1.cfg -c
91
94
 
92
95
  desc "Start Xen"
93
96
  task :start, :roles => :dom0 do
@@ -6,7 +6,7 @@ upstream <%= application %> {
6
6
 
7
7
  server {
8
8
  listen 80;
9
- server_name <%= domain %> <% 4.times do |counter| %> <%= domain.sub(/.*?\./, "assets#{counter}.") %><% end %>;
9
+ server_name <%= application %> <%= domain %> <% 4.times do |counter| %> <%= domain.sub(/.*?\./, "assets#{counter}.") %><% end %>;
10
10
  root <%= deploy_to %>/current/public;
11
11
  access_log <%= deploy_to %>/shared/log/<%= domain %>-access.log;
12
12
  error_log <%= deploy_to %>/shared/log/<%= domain %>-error.log;
@@ -2,6 +2,9 @@
2
2
  <IfModule passenger_module>
3
3
  <VirtualHost *:80>
4
4
  ServerName <%= domain %>
5
+ <%- 4.times do |counter| -%>
6
+ ServerAlias <%= domain.sub(/.*?\./, "assets#{counter}.") %>
7
+ <%- end %>
5
8
  DocumentRoot "<%= passenger_document_root %>"
6
9
  RailsEnv <%= rails_env %>
7
10
  # RailsAllowModRewrite <%= passenger_rails_allow_mod_rewrite %>
@@ -257,7 +257,7 @@ reiser_options = defaults
257
257
  # serial_device = hvc0 #default
258
258
  # serial_device = tty1
259
259
  #
260
- # disk_device = xvda #default
260
+ disk_device = xvda #default
261
261
  # disk_device = sda
262
262
  #
263
263
 
@@ -273,4 +273,4 @@ reiser_options = defaults
273
273
  #
274
274
  # output = /etc/xen
275
275
  # extension = .cfg
276
- #
276
+ #
@@ -135,4 +135,4 @@ on_crash = 'restart'
135
135
  }
136
136
  }
137
137
 
138
- extra = ' TERM=xterm xencons=tty console=tty1'
138
+ extra = '2 console=xvc0'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deprec
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Bailey
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-20 00:00:00 +11:00
12
+ date: 2009-03-03 00:00:00 +11:00
13
13
  default_executable: depify
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -125,12 +125,12 @@ files:
125
125
  - lib/deprec/templates/logrotate
126
126
  - lib/deprec/templates/logrotate/logrotate.conf.erb
127
127
  - lib/deprec/templates/mongrel
128
- - lib/deprec/templates/mongrel/apache_vhost.erb
128
+ - lib/deprec/templates/mongrel/apache_vhost.conf.erb
129
129
  - lib/deprec/templates/mongrel/logrotate.conf.erb
130
130
  - lib/deprec/templates/mongrel/mongrel_cluster-init-script
131
131
  - lib/deprec/templates/mongrel/mongrel_cluster.yml.erb
132
132
  - lib/deprec/templates/mongrel/monit.conf.erb
133
- - lib/deprec/templates/mongrel/nginx_vhost.erb
133
+ - lib/deprec/templates/mongrel/nginx_vhost.conf.erb
134
134
  - lib/deprec/templates/monit
135
135
  - lib/deprec/templates/monit/monit-init-script
136
136
  - lib/deprec/templates/monit/monitrc.erb