deprec 2.0.13 → 2.0.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. data/CHANGELOG +8 -0
  2. data/lib/deprec/recipes/app/passenger.rb +12 -1
  3. data/lib/deprec/recipes/collectd.rb +112 -0
  4. data/lib/deprec/recipes/nagios.rb +82 -75
  5. data/lib/deprec/recipes/rails.rb +5 -0
  6. data/lib/deprec/recipes/utils.rb +17 -17
  7. data/lib/deprec/recipes/web/apache.rb +1 -0
  8. data/lib/deprec/recipes/xen.rb +6 -5
  9. data/lib/deprec/recipes_minus_rails.rb +1 -0
  10. data/lib/deprec/templates/nagios/README +32 -0
  11. data/lib/deprec/templates/nagios/cgi.cfg +332 -0
  12. data/lib/deprec/templates/nagios/htpasswd.users +0 -1
  13. data/lib/deprec/templates/nagios/mrtg.cfg +180 -0
  14. data/lib/deprec/templates/nagios/{nagios.cfg.erb → nagios.cfg} +37 -14
  15. data/lib/deprec/templates/nagios/objects/commands.cfg +240 -0
  16. data/lib/deprec/templates/nagios/objects/contacts.cfg +55 -0
  17. data/lib/deprec/templates/nagios/{localhost.cfg.erb → objects/localhost.cfg} +0 -0
  18. data/lib/deprec/templates/nagios/objects/templates.cfg +190 -0
  19. data/lib/deprec/templates/nagios/{timeperiods.cfg.erb → objects/timeperiods.cfg} +0 -0
  20. data/lib/deprec/templates/nagios/resource.cfg +34 -0
  21. data/lib/deprec/templates/nagios_config.tgz +0 -0
  22. data/lib/deprec/templates/{nagios/nagios_apache_vhost.conf.erb → old/apache_vhost.erb} +0 -0
  23. data/lib/deprec/templates/{nagios → old}/cgi.cfg.erb +0 -0
  24. data/lib/deprec/templates/{nagios → old}/commands.cfg.erb +0 -0
  25. data/lib/deprec/templates/{nagios → old}/contacts.cfg.erb +0 -0
  26. data/lib/deprec/templates/old/htpasswd.users +1 -0
  27. data/lib/deprec/templates/old/localhost.cfg.erb +157 -0
  28. data/lib/deprec/templates/{nagios → old}/resource.cfg.erb +0 -0
  29. data/lib/deprec/templates/{nagios → old}/templates.cfg.erb +0 -0
  30. data/lib/deprec/templates/old/timeperiods.cfg.erb +94 -0
  31. data/lib/deprec/templates/passenger/apache_vhost.erb +3 -0
  32. data/lib/deprec/templates/passenger/logrotate.conf.erb +12 -0
  33. metadata +24 -11
data/CHANGELOG CHANGED
@@ -1,5 +1,13 @@
1
1
  == git
2
2
 
3
+ == 2.0.15 (August 10, 2009)
4
+
5
+ * Moved apache logs for vhosts into /var/log/apache2 (override by setting :apache_log_dir)
6
+
7
+ == 2.0.14 (August 10, 2009)
8
+
9
+ * Added logrotate config for passenger
10
+
3
11
  == 2.0.13 (July 5, 2009)
4
12
 
5
13
  * Bugfix: updated url for REE (old one went away)
@@ -16,6 +16,7 @@ Capistrano::Configuration.instance(:must_exist).load do
16
16
  set :passenger_rails_allow_mod_rewrite, 'off'
17
17
  # Default settings for Passenger config files
18
18
  set :passenger_log_level, 0
19
+ set(:passenger_log_dir) { "#{shared_path}/log"}
19
20
  set :passenger_user_switching, 'on'
20
21
  set :passenger_default_user, 'nobody'
21
22
  set :passenger_max_pool_size, 6
@@ -95,7 +96,12 @@ Capistrano::Configuration.instance(:must_exist).load do
95
96
  { :template => 'apache_vhost.erb',
96
97
  :path => "apache_vhost",
97
98
  :mode => 0755,
98
- :owner => 'root:root'}
99
+ :owner => 'root:root'},
100
+
101
+ {:template => 'logrotate.conf.erb',
102
+ :path => "logrotate.conf",
103
+ :mode => 0644,
104
+ :owner => 'root:root'}
99
105
 
100
106
  ]
101
107
 
@@ -136,6 +142,11 @@ Capistrano::Configuration.instance(:must_exist).load do
136
142
  deprec2.push_configs(:passenger, PROJECT_CONFIG_FILES[:passenger])
137
143
  symlink_apache_vhost
138
144
  activate_project
145
+ symlink_logrotate_config
146
+ end
147
+
148
+ task :symlink_logrotate_config, :roles => :app do
149
+ sudo "ln -sf #{deploy_to}/passenger/logrotate.conf /etc/logrotate.d/passenger-#{application}"
139
150
  end
140
151
 
141
152
  # Passenger runs Rails as the owner of this file.
@@ -0,0 +1,112 @@
1
+ # Copyright 2006-2009 by Mike Bailey. All rights reserved.
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+ namespace :deprec do
4
+ namespace :collectd do
5
+
6
+ # latest rrdtool
7
+ # apt-get install intltool
8
+ # wget http://oss.oetiker.ch/rrdtool/pub/rrdtool.tar.gz
9
+ # tar zxf rrdtool.tar.gz
10
+ # cd rrdtool
11
+ # ./configure --prefix=/usr/local
12
+ # make
13
+ # sudo make install
14
+ #
15
+ # wget http://oss.oetiker.ch/rrdtool/pub/contrib/ruby-rrd-1.1.tar.gz
16
+ # tar zxf ruby-rrd-1.1.tar.gz
17
+ # cd ruby-rrd-1.1
18
+ # ruby extconf.rb
19
+ # make
20
+ # make install
21
+
22
+ # Ruby bindings
23
+ # RRD.so
24
+
25
+
26
+
27
+ SRC_PACKAGES[:collectd] = {
28
+ :url => "http://collectd.org/files/collectd-4.7.1.tar.gz",
29
+ :md5sum => "9ec7f111e74dc55ad2aa9fcc11b8221c collectd-4.7.1.tar.gz",
30
+ :configure => "./configure --prefix=/usr/local"
31
+ }
32
+
33
+ desc "Install collectd"
34
+ task :install do
35
+ install_deps
36
+ deprec2.download_src(SRC_PACKAGES[:collectd], src_dir)
37
+ deprec2.install_from_src(SRC_PACKAGES[:collectd], src_dir)
38
+ end
39
+
40
+ # install dependencies for nginx
41
+ task :install_deps do
42
+ apt.install( {:base => %w(liboping-dev libperl-dev libdbi0-dev libesmtp-dev libganglia1-dev libmemcache-dev libnet1-dev libnotify-dev libopenipmi-dev liboping-dev libpcap-dev libperl-dev librrd2-dev libsensors-dev libstatgrab-dev nut-dev libvirt-dev)}, :stable )
43
+ apt.install( {:base => %w(rrdtool librrd2-dev librrds-perl libconfig-general-perl libhtml-parser-perl libregexp-common-perl)}, :stable )
44
+ end
45
+
46
+ # "Start git server in local directory"
47
+ task :serve do
48
+ cmd = "git-daemon --verbose --port=#{git_port} --base-path=#{Dir.pwd} --base-path-relaxed"
49
+ puts cmd
50
+ `#{cmd}`
51
+ end
52
+
53
+ desc "Create git repos for current dir"
54
+ task :init do
55
+ `git init`
56
+ create_gitignore
57
+ create_files_in_empty_dirs
58
+ `git add . && git commit -m 'initial import'`
59
+ end
60
+
61
+ task :create_gitignore do
62
+ system("echo '.DS_Store' >> .gitignore") # files sometimes created by OSX
63
+ system("echo 'log/*' >> .gitignore") if File.directory?('log')
64
+ system("echo 'tmp/**/*' >> .gitignore") if File.directory?('tmp')
65
+ end
66
+
67
+ task :create_files_in_empty_dirs do
68
+ %w(log tmp).each { |dir|
69
+ system("touch #{dir}/.gitignore") if File.directory?(dir)
70
+ }
71
+ end
72
+
73
+ desc "Create remote origin for current dir"
74
+ task :create_remote_origin do
75
+ File.directory?('.git') || init
76
+
77
+ # Push to remote git repo
78
+ hostname = capture "echo $CAPISTRANO:HOST$"
79
+ system "git remote add origin git@#{hostname.chomp}:#{application}"
80
+ system "git push origin master:refs/heads/master"
81
+
82
+ puts
83
+ puts "New remote Git repo: #{git_user}@#{hostname.chomp}:#{application}"
84
+ puts
85
+
86
+ # File.open('.git/config', 'w') do |c|
87
+ # c.write 'Add the following to .git/config'
88
+ # c.write '[branch "master"]'
89
+ # c.write ' remote = origin'
90
+ # c.write ' merge = refs/heads/master'
91
+ # end
92
+
93
+ end
94
+
95
+ # Create root dir for git repositories
96
+ task :create_git_root do
97
+ deprec2.mkdir(git_root, :mode => 02775, :owner => git_user, :group => git_group, :via => :sudo)
98
+ sudo "chmod -R g+w #{git_root}"
99
+ end
100
+
101
+ # regenerate git authorized keys file from users file in same dir
102
+ task :regenerate_authorized_keys do
103
+ sudo "echo '' > #{git_keys_file}"
104
+ sudo "for file in `ls #{git_keys_file}-*`; do cat $file >> #{git_keys_file}; echo \"\n\" >> #{git_keys_file} ; done"
105
+ sudo "chown #{git_user}.#{git_group} #{git_keys_file}"
106
+ sudo "chmod 0600 #{git_keys_file}"
107
+ end
108
+
109
+
110
+ end
111
+ end
112
+ end
@@ -6,54 +6,81 @@ Capistrano::Configuration.instance(:must_exist).load do
6
6
  set :nagios_user, 'nagios'
7
7
  set :nagios_group, 'nagios'
8
8
  set(:nagios_host) { Capistrano::CLI.ui.ask "Enter hostname of nagios server" }
9
- set :nagios_cmd_group, 'nagcmd' # Allow external commands to be submitted through the web interface
10
- default :application, 'nagios'
9
+ set(:nagios_admin_pass) { Capistrano::CLI.ui.ask "Enter password for nagiosadmin user" }
10
+ set :nagios_cmd_group, 'nagcmd' # Submit external commands through the web interface
11
+ set :nagios_htpasswd_file, '/usr/local/nagios/etc/htpasswd.users'
12
+ # default :application, 'nagios'
11
13
 
12
14
  SRC_PACKAGES[:nagios] = {
13
- :url => "http://internap.dl.sourceforge.net/sourceforge/nagios/nagios-3.0.2.tar.gz",
14
- :md5sum => "008d71aac08660bc007f7130ea82ab80 nagios-3.0.2.tar.gz",
15
+ :url => "http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.0.6.tar.gz",
16
+ :md5sum => "900e3f4164f4b2a18485420eeaefe812 nagios-3.0.6.tar.gz",
15
17
  :configure => %w(
16
18
  ./configure
17
19
  --with-command-group=nagcmd
18
20
  ;
19
21
  ).reject{|arg| arg.match '#'}.join(' '),
20
22
  :make => 'make all;',
21
- :install => 'make install install-init install-commandmode'
23
+ :install => 'make fullinstall'
22
24
  }
23
25
 
26
+ task :install_all do
27
+ install
28
+ config_gen
29
+ htpass
30
+ config
31
+ end
32
+
24
33
  desc "Install nagios"
25
34
  task :install do
26
35
  install_deps
27
36
  create_nagios_user
28
- deprec2.add_user_to_group(nagios_user, apache_user)
29
- deprec2.mkdir('/usr/local/nagios/etc', :owner => "#{nagios_user}.#{nagios_group}", :via => :sudo)
30
- deprec2.mkdir('/usr/local/nagios/objects', :owner => "#{nagios_user}.#{nagios_group}", :via => :sudo)
37
+ # deprec2.mkdir('/usr/local/nagios/etc', :owner => "#{nagios_user}.#{nagios_group}", :via => :sudo)
38
+ # deprec2.mkdir('/usr/local/nagios/objects', :owner => "#{nagios_user}.#{nagios_group}", :via => :sudo)
31
39
  deprec2.download_src(SRC_PACKAGES[:nagios], src_dir)
32
40
  deprec2.install_from_src(SRC_PACKAGES[:nagios], src_dir)
33
41
  activate
34
42
  end
35
43
 
44
+ # Install dependencies for nagios
45
+ task :install_deps do
46
+ apt.install( {:base => %w(mailx)}, :stable )
47
+ end
48
+
36
49
  task :create_nagios_user do
37
50
  deprec2.groupadd(nagios_group)
38
51
  deprec2.useradd(nagios_user, :group => nagios_group, :homedir => false)
52
+ # deprec2.add_user_to_group(nagios_user, apache_user)
39
53
  deprec2.groupadd(nagios_cmd_group)
40
54
  deprec2.add_user_to_group(nagios_user, nagios_cmd_group)
41
- # Add apache user to nagios group to permit commands via web interface
42
- deprec2.add_user_to_group('daemon', nagios_cmd_group)
55
+ deprec2.add_user_to_group(apache_user, nagios_cmd_group)
43
56
  end
44
-
45
- # Install dependencies for nagios
46
- task :install_deps do
47
- apt.install( {:base => %w(mailx)}, :stable )
57
+
58
+ desc "Grant a user access to the web interface"
59
+ task :htpass, :roles => :nagios do
60
+ target_user = Capistrano::CLI.ui.ask "Userid" do |q|
61
+ q.default = 'nagiosadmin'
62
+ end
63
+ system "htpasswd config/nagios/usr/local/nagios/etc/htpasswd.users #{target_user}"
48
64
  end
49
65
 
66
+ # desc "Set password for web based access"
67
+ # task :htpass do
68
+ # target_user = Capistrano::CLI.ui.ask "Userid" do |q|
69
+ # q.default = 'nagiosadmin'
70
+ # end
71
+ # newpass = Capistrano::CLI.ui.ask "new password" do |q|
72
+ # q.echo = false
73
+ # end
74
+ # sudo "htpasswd -b #{htpasswd_file} #{target_user} #{newpass}"
75
+ # end
76
+
50
77
  SYSTEM_CONFIG_FILES[:nagios] = [
51
78
 
52
79
  {:template => 'nagios.cfg.erb',
53
80
  :path => '/usr/local/nagios/etc/nagios.cfg',
54
81
  :mode => 0664,
55
82
  :owner => 'nagios:nagios'},
56
-
83
+
57
84
  {:template => 'resource.cfg.erb',
58
85
  :path => '/usr/local/nagios/etc/resource.cfg',
59
86
  :mode => 0660,
@@ -63,56 +90,46 @@ Capistrano::Configuration.instance(:must_exist).load do
63
90
  :path => '/usr/local/nagios/etc/cgi.cfg',
64
91
  :mode => 0664,
65
92
  :owner => 'nagios:nagios'},
66
-
93
+
67
94
  {:template => 'htpasswd.users',
68
95
  :path => '/usr/local/nagios/etc/htpasswd.users',
69
- :mode => 0664,
70
- :owner => 'nagios:nagios'},
71
-
72
- {:template => 'templates.cfg.erb',
73
- :path => '/usr/local/nagios/etc/objects/templates.cfg',
74
- :mode => 0664,
96
+ :mode => 0660,
75
97
  :owner => 'nagios:nagios'},
76
98
 
77
- {:template => 'commands.cfg.erb',
99
+ {:template => 'objects/commands.cfg',
78
100
  :path => '/usr/local/nagios/etc/objects/commands.cfg',
79
101
  :mode => 0664,
80
- :owner => 'nagios:nagios'},
81
-
82
- {:template => 'timeperiods.cfg.erb',
83
- :path => '/usr/local/nagios/etc/objects/timeperiods.cfg',
84
- :mode => 0664,
85
- :owner => 'nagios:nagios'},
86
-
87
- {:template => 'localhost.cfg.erb',
88
- :path => '/usr/local/nagios/etc/objects/localhost.cfg',
89
- :mode => 0664,
90
- :owner => 'nagios:nagios'},
91
-
92
- {:template => 'contacts.cfg.erb',
93
- :path => '/usr/local/nagios/etc/objects/contacts.cfg',
94
- :mode => 0664,
95
- :owner => 'nagios:nagios'},
96
-
97
- {:template => 'hosts.cfg.erb',
98
- :path => '/usr/local/nagios/etc/objects/hosts.cfg',
99
- :mode => 0664,
100
- :owner => 'nagios:nagios'},
101
-
102
- {:template => 'services.cfg.erb',
103
- :path => '/usr/local/nagios/etc/objects/services.cfg',
104
- :mode => 0664,
105
- :owner => 'nagios:nagios'},
102
+ :owner => 'nagios:nagios'}# ,
106
103
 
107
- {:template => 'localhost.cfg.erb',
108
- :path => '/usr/local/nagios/etc/objects/localhost.cfg',
109
- :mode => 0664,
110
- :owner => 'nagios:nagios'},
111
-
112
- {:template => 'nagios_apache_vhost.conf.erb',
113
- :path => "conf/nagios_apache_vhost.conf",
114
- :mode => 0644,
115
- :owner => 'root:root'}
104
+ # {:template => 'contacts.cfg.erb',
105
+ # :path => '/usr/local/nagios/etc/objects/contacts.cfg',
106
+ # :mode => 0664,
107
+ # :owner => 'nagios:nagios'},
108
+ #
109
+ # {:template => 'localhost.cfg.erb',
110
+ # :path => '/usr/local/nagios/etc/objects/localhost.cfg',
111
+ # :mode => 0664,
112
+ # :owner => 'nagios:nagios'},
113
+ #
114
+ # {:template => 'hosts.cfg.erb',
115
+ # :path => '/usr/local/nagios/etc/objects/hosts.cfg',
116
+ # :mode => 0664,
117
+ # :owner => 'nagios:nagios'},
118
+ #
119
+ # {:template => 'services.cfg.erb',
120
+ # :path => '/usr/local/nagios/etc/objects/services.cfg',
121
+ # :mode => 0664,
122
+ # :owner => 'nagios:nagios'},
123
+ #
124
+ # {:template => 'templates.cfg.erb',
125
+ # :path => '/usr/local/nagios/etc/objects/templates.cfg',
126
+ # :mode => 0664,
127
+ # :owner => 'nagios:nagios'},
128
+ #
129
+ # {:template => 'timeperiods.cfg.erb',
130
+ # :path => '/usr/local/nagios/etc/objects/timeperiods.cfg',
131
+ # :mode => 0664,
132
+ # :owner => 'nagios:nagios'}
116
133
 
117
134
  ]
118
135
 
@@ -127,7 +144,6 @@ Capistrano::Configuration.instance(:must_exist).load do
127
144
  task :config, :roles => :nagios do
128
145
  default :application, 'nagios'
129
146
  deprec2.push_configs(:nagios, SYSTEM_CONFIG_FILES[:nagios])
130
- sudo "ln -sf #{deploy_to}/nagios/conf/nagios_apache_vhost.conf /usr/local/apache2/conf/apps"
131
147
  config_check
132
148
  restart
133
149
  end
@@ -140,14 +156,15 @@ Capistrano::Configuration.instance(:must_exist).load do
140
156
  desc "Set Nagios to start on boot"
141
157
  task :activate, :roles => :nagios do
142
158
  send(run_method, "update-rc.d nagios defaults")
143
- sudo "ln -sf #{deploy_to}/nagios/conf/nagios_apache_vhost.conf /usr/local/apache2/conf/apps"
159
+ sudo "a2ensite nagios"
160
+ top.deprec.apache.reload
144
161
  end
145
162
 
146
163
  desc "Set Nagios to not start on boot"
147
164
  task :deactivate, :roles => :nagios do
148
165
  send(run_method, "update-rc.d -f nagios remove")
149
- link = "#{apache_vhost_dir}/nagios_#{application}.conf"
150
- sudo "test -h #{link} && sudo unlink #{link} || true"
166
+ sudo "a2dissite nagios"
167
+ top.deprec.apache.reload
151
168
  end
152
169
 
153
170
  # Control
@@ -179,19 +196,6 @@ Capistrano::Configuration.instance(:must_exist).load do
179
196
  task :restore, :roles => :web do
180
197
  # not yet implemented
181
198
  end
182
-
183
- #
184
- # Service specific tasks
185
- #
186
-
187
- # XXX quick and dirty - clean up later
188
- desc "Grant a user access to the web interface"
189
- task :htpass, :roles => :nagios do
190
- target_user = Capistrano::CLI.ui.ask "Userid" do |q|
191
- q.default = 'nagiosadmin'
192
- end
193
- system "htpasswd config/nagios/usr/local/nagios/etc/htpasswd.users #{target_user}"
194
- end
195
199
 
196
200
  end
197
201
 
@@ -300,6 +304,9 @@ Capistrano::Configuration.instance(:must_exist).load do
300
304
 
301
305
  end
302
306
 
307
+ # PHP4nagios
308
+ # http://downloads.sourceforge.net/sourceforge/pnp4nagios/pnp-0.4.14.tar.gz?use_mirror=internode
309
+
303
310
 
304
311
  end
305
312
  end
@@ -50,6 +50,11 @@ Capistrano::Configuration.instance(:must_exist).load do
50
50
  end
51
51
  end
52
52
  end
53
+ namespace :db do
54
+ task :migrate, :roles => :db do
55
+ run "cd #{current_path} && #{sudo} rake gems:install"
56
+ end
57
+ end
53
58
 
54
59
  namespace :deprec do
55
60
  namespace :rails do
@@ -1,14 +1,14 @@
1
1
  # Copyright 2006-2008 by Mike Bailey. All rights reserved.
2
- Capistrano::Configuration.instance(:must_exist).load do
3
- namespace :deprec do
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+ namespace :deprec do
4
4
  namespace :utils do
5
-
5
+
6
6
  SRC_PACKAGES[:daemonize] = {
7
- :filename => 'daemonize-1.5.2.tar.gz',
8
- :md5sum => "c016f1a17f03ec976873d0a283a1a038 daemonize-1.5.2.tar.gz",
9
- :dir => 'daemonize-1.5.2',
10
- :url => "http://www.clapper.org/software/daemonize/daemonize-1.5.2.tar.gz",
11
- :unpack => "tar zxf daemonize-1.5.2.tar.gz;",
7
+ :filename => 'daemonize-1.5.6.tar.gz',
8
+ :md5sum => "2f5fbb8788ebe803ccaff3cd4b5c3188 daemonize-1.5.6.tar.gz",
9
+ :dir => 'daemonize-1.5.6',
10
+ :url => "http://www.clapper.org/software/daemonize/daemonize-1.5.6.tar.gz",
11
+ :unpack => "tar zxf daemonize-1.5.6.tar.gz;",
12
12
  :configure => %w(
13
13
  ./configure
14
14
  ;
@@ -16,43 +16,43 @@ Capistrano::Configuration.instance(:must_exist).load do
16
16
  :make => 'make;',
17
17
  :install => 'make install;'
18
18
  }
19
-
19
+
20
20
  namespace :daemonize do
21
-
21
+
22
22
  desc "Install daemonize"
23
23
  task :install do
24
24
  deprec2.download_src(SRC_PACKAGES[:daemonize], src_dir)
25
25
  deprec2.install_from_src(SRC_PACKAGES[:daemonize], src_dir)
26
26
  end
27
-
27
+
28
28
  end
29
-
29
+
30
30
  desc "Install some useful network utils"
31
31
  task :net do
32
32
  apps = %w(lynx nmap netcat telnet dnsutils rsync curl wget)
33
33
  apt.install( {:base => apps}, :stable )
34
34
  end
35
-
35
+
36
36
  desc "Install some useful mail utils"
37
37
  task :mail do
38
38
  apps = %w(mailx mutt)
39
39
  apt.install( {:base => apps}, :stable )
40
40
  end
41
-
41
+
42
42
  desc "Install some useful utils"
43
43
  task :other do
44
44
  apps = %w(vim-full tree)
45
45
  apt.install( {:base => apps}, :stable )
46
46
  end
47
-
47
+
48
48
  desc "Install handy utils"
49
49
  task :handy do
50
50
  net
51
51
  mail
52
52
  other
53
53
  end
54
-
55
- end
54
+
55
+ end
56
56
  end
57
57
  end
58
58