deprec 2.1.19 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. data/CHANGELOG +11 -1
  2. data/{README → README.md} +33 -68
  3. data/bin/hosts.rb +44 -0
  4. data/docs/nagios.txt +28 -0
  5. data/lib/deprec/capistrano_extensions.rb +21 -32
  6. data/lib/deprec/recipes/apache.rb +54 -73
  7. data/lib/deprec/recipes/deprec.rb +30 -48
  8. data/lib/deprec/recipes/git.rb +2 -85
  9. data/lib/deprec/recipes/haproxy.rb +3 -11
  10. data/lib/deprec/recipes/mri.rb +23 -40
  11. data/lib/deprec/recipes/mysql.rb +6 -23
  12. data/lib/deprec/recipes/nagios.rb +2 -17
  13. data/lib/deprec/recipes/nagios3.rb +180 -0
  14. data/lib/deprec/recipes/network.rb +60 -28
  15. data/lib/deprec/recipes/nrpe.rb +82 -0
  16. data/lib/deprec/recipes/passenger.rb +15 -12
  17. data/lib/deprec/recipes/postgresql.rb +2 -2
  18. data/lib/deprec/recipes/rack.rb +44 -0
  19. data/lib/deprec/recipes/rails.rb +10 -32
  20. data/lib/deprec/recipes/ree.rb +27 -18
  21. data/lib/deprec/recipes/rubygems.rb +29 -0
  22. data/lib/deprec/recipes/sqlite.rb +1 -1
  23. data/lib/deprec/recipes/ssh.rb +1 -0
  24. data/lib/deprec/recipes/svn.rb +1 -160
  25. data/lib/deprec/recipes/users.rb +19 -16
  26. data/lib/deprec/recipes_minus_rails.rb +39 -36
  27. data/lib/deprec/templates/apache/CHANGES.txt +11 -0
  28. data/lib/deprec/templates/mysql/my.cnf.erb +21 -31
  29. data/lib/deprec/templates/{nagios → nagios.old}/README +0 -0
  30. data/lib/deprec/templates/nagios.old/apache_vhost.erb +25 -0
  31. data/lib/deprec/templates/{nagios → nagios.old}/cgi.cfg.erb +0 -0
  32. data/lib/deprec/templates/nagios.old/check_linux_free_memory.pl +118 -0
  33. data/lib/deprec/templates/{nagios → nagios.old}/check_mongrel_cluster.rb +0 -0
  34. data/lib/deprec/templates/nagios.old/htpasswd.users +1 -0
  35. data/lib/deprec/templates/{nagios → nagios.old}/mrtg.cfg +0 -0
  36. data/lib/deprec/templates/{nagios → nagios.old}/nagios.cfg.erb +0 -0
  37. data/lib/deprec/templates/{nagios → nagios.old}/nrpe.cfg.erb +0 -0
  38. data/lib/deprec/templates/{nagios → nagios.old}/nrpe.xinetd.erb +0 -0
  39. data/lib/deprec/templates/{nagios → nagios.old}/objects/commands.cfg.erb +0 -0
  40. data/lib/deprec/templates/{nagios → nagios.old}/objects/contacts.cfg.erb +0 -0
  41. data/lib/deprec/templates/{nagios → nagios.old}/objects/hosts.cfg.erb +0 -0
  42. data/lib/deprec/templates/{nagios → nagios.old}/objects/localhost.cfg.erb +0 -0
  43. data/lib/deprec/templates/{nagios → nagios.old}/objects/services.cfg.erb +0 -0
  44. data/lib/deprec/templates/{nagios → nagios.old}/objects/timeperiods.cfg.erb +0 -0
  45. data/lib/deprec/templates/{nagios → nagios.old}/resource.cfg.erb +0 -0
  46. data/lib/deprec/templates/nagios/apache2.conf +55 -0
  47. data/lib/deprec/templates/nagios/cgi.cfg +25 -0
  48. data/lib/deprec/templates/nagios/commands.cfg +52 -0
  49. data/lib/deprec/templates/nagios/conf.d/contacts_nagios2.cfg +23 -0
  50. data/lib/deprec/templates/nagios/conf.d/extinfo_nagios2.cfg +13 -0
  51. data/lib/deprec/templates/nagios/conf.d/generic-host_nagios2.cfg +19 -0
  52. data/lib/deprec/templates/nagios/conf.d/generic-service_nagios2.cfg +26 -0
  53. data/lib/deprec/templates/nagios/conf.d/hostgroups_nagios2.cfg +48 -0
  54. data/lib/deprec/templates/nagios/conf.d/hosts/localhost_nagios2.cfg +59 -0
  55. data/lib/deprec/templates/nagios/conf.d/services_nagios2.cfg +45 -0
  56. data/lib/deprec/templates/nagios/conf.d/timeperiods_nagios2.cfg +50 -0
  57. data/lib/deprec/templates/nagios/host_template.erb +6 -0
  58. data/lib/deprec/templates/nagios/htpasswd.users +1 -1
  59. data/lib/deprec/templates/nagios/nagios.cfg +1326 -0
  60. data/lib/deprec/templates/nagios/nrpe.cfg +28 -0
  61. data/lib/deprec/templates/nagios/resource.cfg +31 -0
  62. data/lib/deprec/templates/passenger/apache_vhost.erb +2 -2
  63. data/lib/deprec/templates/passenger/logrotate.conf.erb +1 -1
  64. data/lib/deprec/templates/passenger/passenger.conf.erb +12 -11
  65. data/lib/deprec/templates/passenger/passenger.load.erb +1 -1
  66. metadata +43 -42
  67. data/lib/deprec/recipes/wordpress.rb +0 -96
@@ -1,4 +1,5 @@
1
1
  # Copyright 2006-2008 by Mike Bailey. All rights reserved.
2
+ require 'socket'
2
3
  Capistrano::Configuration.instance(:must_exist).load do
3
4
  namespace :deprec do
4
5
  namespace :network do
@@ -16,7 +17,11 @@ Capistrano::Configuration.instance(:must_exist).load do
16
17
  default_network = "192.168.#{iface+1}"
17
18
  result[iface] = {}
18
19
  result[iface][:address] = Capistrano::CLI.ui.ask "address" do |q|
19
- q.default = "#{default_network}.10"
20
+ if network_hostname
21
+ q.default = IPSocket.getaddress(network_hostname) rescue "#{default_network}.10"
22
+ else
23
+ q.default = "#{default_network}.10"
24
+ end
20
25
  end
21
26
  default_network = result[iface][:address].split('.').slice(0,3).join('.')
22
27
  result[iface][:netmask] = Capistrano::CLI.ui.ask "netmask" do |q|
@@ -51,19 +56,21 @@ Capistrano::Configuration.instance(:must_exist).load do
51
56
 
52
57
  # Non standard deprec!
53
58
  #
59
+ # SYSTEM_CONFIG_FILES[:network] would normally be an array
60
+ #
54
61
  # I might move to making this standard in future. It makes it easier to
55
62
  # override individual config files in local recipes. - Mike
56
63
  #
57
64
  SYSTEM_CONFIG_FILES[:network] = {
58
65
 
59
- :interfaces => {
60
- :template => "interfaces.erb",
61
- :path => '/etc/network/interfaces',
62
- :mode => 0644,
63
- :owner => 'root:root',
64
- :remote => true
66
+ :hostname => {
67
+ :template => "hostname.erb",
68
+ :path => '/etc/hostname',
69
+ :mode => 0644,
70
+ :owner => 'root:root',
71
+ :remote => true
65
72
  },
66
-
73
+
67
74
  :hosts => {
68
75
  :template => "hosts.erb",
69
76
  :path => '/etc/hosts',
@@ -72,12 +79,12 @@ Capistrano::Configuration.instance(:must_exist).load do
72
79
  :remote => true
73
80
  },
74
81
 
75
- :hostname => {
76
- :template => "hostname.erb",
77
- :path => '/etc/hostname',
78
- :mode => 0644,
79
- :owner => 'root:root',
80
- :remote => true
82
+ :interfaces => {
83
+ :template => "interfaces.erb",
84
+ :path => '/etc/network/interfaces',
85
+ :mode => 0644,
86
+ :owner => 'root:root',
87
+ :remote => true
81
88
  },
82
89
 
83
90
  :resolv => {
@@ -89,7 +96,46 @@ Capistrano::Configuration.instance(:must_exist).load do
89
96
  }
90
97
  }
91
98
 
99
+ desc "Generate and push all network config files"
100
+ task :config do
101
+ if find_servers_for_task(current_task).size != 1
102
+ puts "****************************************************"
103
+ puts "*** You must specify exactly 1 host to configure ***"
104
+ puts "****************************************************"
105
+ else
106
+ hostname
107
+ hosts
108
+ interfaces
109
+ resolv
110
+ restart
111
+ end
112
+ end
92
113
 
114
+ desc "Restart networking "
115
+ task :restart do
116
+ # This is the only task that is designed to 'fail'
117
+ # Solutions to this problem welcome!
118
+ servers = find_servers_for_task(current_task).join(',')
119
+ puts
120
+ puts "About to restart networking on #{servers}"
121
+ # In an effort to appeal to younger devs we're using 'street talk'
122
+ input = Capistrano::CLI.ui.ask "Are you 'down with that'?" do |q|
123
+ q.default = 'y'
124
+ end
125
+ if input =~ /y/i
126
+ run "#{sudo} /etc/init.d/networking restart"
127
+ else
128
+ puts "You can always do it later with"
129
+ puts
130
+ puts " cap deprec:network:restart HOSTS=#{servers}"
131
+ puts
132
+ end
133
+ end
134
+
135
+ # Create individual tasks to generate remote config files
136
+ #
137
+ # e.g. cap deprec:network:hostname
138
+ #
93
139
  SYSTEM_CONFIG_FILES[:network].each do |file, details|
94
140
  desc "Generate and push #{details[:path]}"
95
141
  task file.to_sym do
@@ -97,20 +143,6 @@ Capistrano::Configuration.instance(:must_exist).load do
97
143
  run "#{sudo} hostname #{network_hostname}" if file == :hostname
98
144
  end
99
145
  end
100
-
101
- # XXX need to set the order for these as it breaks sudo currently
102
- desc "Update system networking configuration"
103
- task :config do
104
- network_hostname # get user input upfront
105
- SYSTEM_CONFIG_FILES[:network].values.each do |file|
106
- deprec2.render_template(:network, file.merge(:remote=>true))
107
- end
108
- end
109
-
110
- desc "Restart network interface"
111
- task :restart do
112
- sudo '/etc/init.d/networking restart'
113
- end
114
146
 
115
147
  end
116
148
  end
@@ -0,0 +1,82 @@
1
+ # Copyright 2006-2011 by Mike Bailey. All rights reserved.
2
+ require 'socket'
3
+ Capistrano::Configuration.instance(:must_exist).load do
4
+ namespace :deprec do
5
+ namespace :nrpe do
6
+
7
+ set(:nrpe_allowed_hosts) {
8
+ Capistrano::CLI.ui.ask("Address(es) of Nagios server(s) (comma sep)")
9
+ }
10
+
11
+ desc 'Install NRPE'
12
+ task :install, :roles => :nrpe do
13
+ apt.install( {:base => %w(nagios-nrpe-server nagios-plugins
14
+ nagios-nrpe-plugin)}, :stable )
15
+ config
16
+ end
17
+
18
+ SYSTEM_CONFIG_FILES[:nrpe] = [
19
+
20
+ {
21
+ :path => "/etc/nagios/nrpe.cfg",
22
+ :template => "nrpe.cfg",
23
+ :mode => 0644,
24
+ :owner => 'root:root'
25
+ }
26
+
27
+ ]
28
+
29
+ desc "Generate configuration file(s) for nrpe from template(s)"
30
+ task :config_gen do
31
+ SYSTEM_CONFIG_FILES[:nrpe].each do |file|
32
+ deprec2.render_template(:nagios, file)
33
+ end
34
+ end
35
+
36
+ desc "Push nrpe config files to server"
37
+ task :config, :roles => :nrpe do
38
+ deprec2.push_configs(:nagios, SYSTEM_CONFIG_FILES[:nrpe])
39
+ reload
40
+ test_local
41
+ end
42
+
43
+ # Control
44
+
45
+ desc "Start NRPE"
46
+ task :start, :roles => :nrpe do
47
+ send(run_method, "/etc/init.d/nagios-nrpe-server start")
48
+ end
49
+
50
+ desc "Stop NRPE"
51
+ task :stop, :roles => :nrpe do
52
+ send(run_method, "/etc/init.d/nagios-nrpe-server stop")
53
+ end
54
+
55
+ desc "Restart NRPE"
56
+ task :restart, :roles => :nrpe do
57
+ send(run_method, "/etc/init.d/nagios-nrpe-server restart")
58
+ end
59
+
60
+ desc "Reload NRPE"
61
+ task :reload, :roles => :nrpe do
62
+ send(run_method, "/etc/init.d/nagios-nrpe-server reload")
63
+ end
64
+
65
+ # Extras
66
+
67
+ desc "Test whether NRPE is listening on client"
68
+ task :test_local, :roles => :nrpe do
69
+ puts "Testing that NRPE is listening on client"
70
+ run "/usr/lib/nagios/plugins/check_nrpe -H localhost"
71
+ end
72
+
73
+ desc "Test whether nagios server can query client via NRPE"
74
+ task :test_remote, :roles => :nagios do
75
+ target_host = Capistrano::CLI.ui.ask "target hostname"
76
+ run "/usr/lib/nagios/plugins/check_nrpe -H #{IPSocket.getaddress(target_host)}"
77
+ end
78
+
79
+ end
80
+
81
+ end
82
+ end
@@ -3,9 +3,10 @@ Capistrano::Configuration.instance(:must_exist).load do
3
3
  namespace :deprec do
4
4
  namespace :passenger do
5
5
 
6
- set :passenger_version, '2.2.14'
7
- set :passenger_install_dir, "/usr/local/lib/ruby/gems/1.8/gems/passenger-#{passenger_version}"
8
-
6
+ set :passenger_version, '3.0.7'
7
+ set(:passenger_root) { capture("passenger-config --root").chomp }
8
+ set(:passenger_ruby) { capture("which ruby").chomp }
9
+
9
10
  # Default settings for Passenger config files
10
11
  set(:passenger_document_root) { "#{current_path}/public" }
11
12
  set :passenger_rails_allow_mod_rewrite, 'off'
@@ -19,18 +20,17 @@ Capistrano::Configuration.instance(:must_exist).load do
19
20
  set :passenger_rails_autodetect, 'on'
20
21
  set :passenger_rails_spawn_method, 'smart' # smart | conservative
21
22
 
22
- desc "Install passenger"
23
+ desc "Install Passenger"
23
24
  task :install, :roles => :app do
24
25
  install_deps
25
26
  gem2.install 'passenger', passenger_version
26
- sudo "passenger-install-apache2-module _#{passenger_version}_ -a"
27
+ run "#{sudo} passenger-install-apache2-module _#{passenger_version}_ --auto"
27
28
  config_system
28
- activate_system
29
29
  end
30
30
 
31
31
  # Install dependencies for Passenger
32
32
  task :install_deps, :roles => :app do
33
- apt.install( {:base => %w(apache2-mpm-prefork apache2-prefork-dev rsync)}, :stable )
33
+ apt.install( {:base => %w(libcurl4-openssl-dev apache2-mpm-prefork apache2-prefork-dev libapr1-dev libaprutil1-dev rsync)}, :stable )
34
34
  end
35
35
 
36
36
  SYSTEM_CONFIG_FILES[:passenger] = [
@@ -63,15 +63,18 @@ Capistrano::Configuration.instance(:must_exist).load do
63
63
 
64
64
  desc "Generate Passenger apache configs (system & project level)."
65
65
  task :config_gen do
66
- config_gen_system
66
+ # config_gen_system
67
67
  config_gen_project
68
68
  end
69
69
 
70
- desc "Generate Passenger apache configs (system level) from template."
70
+ # desc "Generate Passenger apache configs (system level) from template."
71
+ # We can't generate passenger configs because we need to contact remote system
72
+ # to find out gem location & ruby version.
71
73
  task :config_gen_system do
72
- SYSTEM_CONFIG_FILES[:passenger].each do |file|
73
- deprec2.render_template(:passenger, file)
74
- end
74
+ puts "We don't generate local Passenger system files"
75
+ # SYSTEM_CONFIG_FILES[:passenger].each do |file|
76
+ # deprec2.render_template(:passenger, file)
77
+ # end
75
78
  end
76
79
 
77
80
  desc "Generate Passenger apache configs (project level) from template."
@@ -94,11 +94,11 @@ Capistrano::Configuration.instance(:must_exist).load do
94
94
  sudo "su - postgres -c \'createdb -O #{db_user} #{db_name}\'"
95
95
  end
96
96
 
97
- desc "Grant user access to Database"
97
+ # "Grant user access to Database"
98
98
  task :grant_user_access_to_database, :roles => :db do
99
99
  # sudo "what's the command for this using #{db_user} #{db_name}\'"
100
100
  end
101
101
 
102
102
  end
103
103
  end
104
- end
104
+ end
@@ -0,0 +1,44 @@
1
+ # Copyright 2006-2011 by Mike Bailey. All rights reserved.
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+ namespace :deprec do
4
+ namespace :rack do
5
+
6
+ set :rack_env, 'production'
7
+
8
+ desc "Install Rack stack on Ubuntu server (8.04, 10.04)"
9
+ task :install_stack do
10
+ top.deprec.git.install
11
+ top.deprec.ruby.install # Uses ruby_vm_type
12
+ gem2.install 'bundler'
13
+ # Some things Rails needs
14
+ apt.install( { :base => %w(libmysqlclient15-dev sqlite3 libsqlite3-ruby libsqlite3-dev libpq-dev) }, :stable)
15
+
16
+ top.deprec.web.install # Uses web_server_type
17
+ top.deprec.app.install # Uses app_server_type
18
+ # top.deprec.rails.install
19
+ top.deprec.logrotate.install
20
+ # top.deprec.monit.install # Not using monit lately
21
+ end
22
+
23
+ desc "Generate config files for rack app."
24
+ task :config_gen do
25
+ top.deprec.web.config_gen_project
26
+ top.deprec.app.config_gen_project
27
+ end
28
+
29
+ desc "Push out config files for rack app."
30
+ task :config do
31
+ top.deprec.web.config_project
32
+ top.deprec.app.config_project
33
+ end
34
+
35
+ desc "Install debs listed in :packages_for_project"
36
+ task :install_packages, :roles => :app do
37
+ if packages_for_project
38
+ apt.install({ :base => packages_for_project }, :stable)
39
+ end
40
+ end
41
+
42
+ end
43
+ end
44
+ end
@@ -47,15 +47,21 @@ Capistrano::Configuration.instance(:must_exist).load do
47
47
  namespace :rails do
48
48
 
49
49
  task :install, :roles => :app do
50
- install_deps
51
- gem2.install 'rails'
50
+ apt.install( { :base => %w(libmysqlclient15-dev sqlite3 libsqlite3-ruby libsqlite3-dev libpq-dev) }, :stable)
52
51
  gem2.install 'bundler'
53
52
  end
54
53
 
55
- task :install_deps do
56
- apt.install( {:base => %w(libmysqlclient15-dev sqlite3 libsqlite3-ruby libsqlite3-dev libpq-dev)}, :stable )
54
+ desc "Install Ruby on Rails stack on Ubuntu server (8.04, 10.04)"
55
+ task :install_stack do
56
+ puts "deprecated: renamed to deprec:rack:install_stack"
57
+ top.deprec.rack.install_stack
57
58
  end
58
59
 
60
+ task :install_rails_stack do
61
+ puts "deprecated: renamed to deprec:rack:install_stack"
62
+ top.deprec.rack.install_stack
63
+ end
64
+
59
65
  #
60
66
  # If database.yml is not kept in scm and it is present in local
61
67
  # config dir then push it out to server.
@@ -73,34 +79,6 @@ Capistrano::Configuration.instance(:must_exist).load do
73
79
  end
74
80
  end
75
81
 
76
- desc <<-DESC
77
- Install full rails stack on a stock standard ubuntu server (7.10, 8.04)
78
- DESC
79
- task :install_stack do
80
-
81
- top.deprec.ruby.install
82
- top.deprec.rails.install
83
- top.deprec.svn.install
84
- top.deprec.git.install
85
- top.deprec.web.install # Uses value of web_server_type
86
- top.deprec.app.install # Uses value of app_server_type
87
- top.deprec.monit.install
88
- top.deprec.logrotate.install
89
-
90
- # We not longer install database server as part of this task.
91
- # There is too much danger that someone will wreck an existing
92
- # shared database.
93
- #
94
- # Install database server with:
95
- #
96
- # cap deprec:db:install
97
- end
98
-
99
- task :install_rails_stack do
100
- puts "deprecated: this task is now called install_stack"
101
- install_stack
102
- end
103
-
104
82
  desc "Generate config files for rails app."
105
83
  task :config_gen do
106
84
  top.deprec.web.config_gen_project
@@ -3,27 +3,36 @@ Capistrano::Configuration.instance(:must_exist).load do
3
3
  namespace :deprec do
4
4
  namespace :ree do
5
5
 
6
- set :ree_install_dir, "/usr/local"
7
-
8
- SRC_PACKAGES[:ree] = {
9
- :md5sum => "62e7ee838532744d5a155a16571f782e ruby-enterprise_1.8.7-2010.02_i386_ubuntu8.04.deb",
10
- :url => "http://rubyforge.org/frs/download.php/71097/ruby-enterprise_1.8.7-2010.02_amd64_ubuntu8.04.deb",
6
+ SRC_PACKAGES[:ree_lucid] = {
7
+ :md5sum => "ec29e25e93ac642212790b0ca22e09f9 ruby-enterprise_1.8.7-2011.03_amd64_ubuntu10.04.deb",
8
+ :url => "http://rubyenterpriseedition.googlecode.com/files/ruby-enterprise_1.8.7-2011.03_amd64_ubuntu10.04.deb",
11
9
  :download_method => :deb
12
10
  }
13
-
11
+
12
+ SRC_PACKAGES[:ree_lucid32] = {
13
+ :md5sum => "bf31bd7cba14ac76b49c3394114b2d31 ruby-enterprise_1.8.7-2011.03_i386_ubuntu10.04.deb",
14
+ :url => "http://rubyenterpriseedition.googlecode.com/files/ruby-enterprise_1.8.7-2011.03_i386_ubuntu10.04.deb",
15
+ :download_method => :deb
16
+ }
17
+
18
+ SRC_PACKAGES[:ree_src] = {
19
+ :md5sum => "038604ce25349e54363c5df9cd535ec8 ruby-enterprise-1.8.7-2011.03.tar.gz",
20
+ :url => "http://rubyenterpriseedition.googlecode.com/files/ruby-enterprise-1.8.7-2011.03.tar.gz",
21
+ :deps => %w(zlib1g-dev libssl-dev libreadline5-dev),
22
+ :configure => '',
23
+ :make => '',
24
+ :install => "#{src_dir}/ruby-enterprise-1.8.7-2011.03/installer --auto /usr --dont-install-useful-gems --no-dev-docs"
25
+ }
26
+
27
+ src_package_options = SRC_PACKAGES.keys.select{|k| k.to_s.match /^ree_/ }
28
+ set(:ree_src_package) { Capistrano::CLI.ui.choose *src_package_options }
29
+
30
+ desc "Install Ruby Enterprise Edition"
14
31
  task :install do
15
- install_deps
16
- deprec2.download_src(SRC_PACKAGES[:ree], src_dir)
17
- deprec2.install_from_src(SRC_PACKAGES[:ree], src_dir)
18
- gem2.update_system # Install latest rubygems
32
+ deprec2.download_src(SRC_PACKAGES[ree_src_package])
33
+ deprec2.install_from_src(SRC_PACKAGES[ree_src_package])
19
34
  end
20
-
21
- task :install_deps do
22
- # not required with new deb package?
23
- # apt.install({:base => %w(libssl-dev libmysqlclient15-dev libreadline5-dev)}, :stable)
24
- end
25
-
26
- end
27
-
35
+
36
+ end
28
37
  end
29
38
  end