Browse files

cleanup crosscutting templates (monit, munin, collectd) to be self co…

…ntained
  • Loading branch information...
1 parent ab42c82 commit 46993e2ed5a5523eaedf0b41eb04982400b2017d Matt Conway committed Jan 19, 2012
Showing with 53 additions and 20 deletions.
  1. +26 −0 lib/rubber/commands/vulcanize.rb
  2. +1 −0 templates/collectd/templates.yml
  3. +3 −3 templates/monit/config/rubber/deploy-monit.rb
  4. 0 templates/{apache → monit}/config/rubber/role/apache/monit-apache.conf
  5. 0 templates/{cassandra → monit}/config/rubber/role/cassandra/monit-cassandra.conf
  6. 0 templates/{graphite → monit}/config/rubber/role/graphite_server/monit-graphite_server.conf
  7. 0 templates/{haproxy → monit}/config/rubber/role/haproxy/monit-haproxy.conf
  8. 0 templates/{jetty → monit}/config/rubber/role/jetty/monit-jetty.conf
  9. 0 ...nfig/rubber/role/mongodb/monit-mongodb.cnf → monit/config/rubber/role/mongodb/monit-mongodb.conf}
  10. 0 templates/{mongrel → monit}/config/rubber/role/mongrel/monit-mongrel.conf
  11. 0 templates/monit/config/rubber/{common → role/monit}/monit-default.conf
  12. 0 templates/{munin/config/rubber/common → monit/config/rubber/role/monit}/monit-munin.conf
  13. 0 templates/{base/config/rubber/common → monit/config/rubber/role/monit}/monit-postfix.conf
  14. 0 templates/monit/config/rubber/{common → role/monit}/monit.conf
  15. 0 ...s/{mysql/config/rubber/role/db/monit-mysql.cnf → monit/config/rubber/role/mysql/monit-mysql.conf}
  16. 0 ...ubber/common/monit-mysql_proxy.cnf → monit/config/rubber/role/mysql_proxy/monit-mysql_proxy.conf}
  17. 0 ...enger_nginx/config/rubber/role/passenger_nginx → monit/config/rubber/role/nginx}/monit-nginx.conf
  18. 0 ...ates/{nginx/config/rubber/role/nginx → monit/config/rubber/role/passenger_nginx}/monit-nginx.conf
  19. 0 ...es/{postgresql/config/rubber/role/db → monit/config/rubber/role/postgresql}/monit-postgresql.conf
  20. 0 templates/{redis → monit}/config/rubber/role/redis/monit-redis.conf
  21. 0 templates/{resque → monit}/config/rubber/role/resque_web/monit-resque_web.conf
  22. 0 templates/{resque → monit}/config/rubber/role/resque_worker/monit-resque_worker.conf
  23. 0 templates/{sphinx → monit}/config/rubber/role/sphinx/monit-sphinx.conf
  24. +6 −1 templates/monit/config/rubber/rubber-monit.yml
  25. +1 −0 templates/monit/templates.yml
  26. +4 −4 templates/munin/config/rubber/deploy-munin.rb
  27. 0 templates/munin/config/rubber/{common → role/munin}/munin-node.conf
  28. 0 templates/munin/config/rubber/{common → role/munin}/munin-plugins.conf
  29. +4 −1 templates/munin/config/rubber/rubber-munin.yml
  30. +1 −0 templates/munin/templates.yml
  31. +0 −10 templates/mysql_cluster/config/rubber/role/mysql_sql/monit-mysql_cluster_sql.cnf
  32. +3 −0 templates/mysql_cluster/config/rubber/rubber-mysql_cluster.yml
  33. 0 templates/mysql_proxy/config/rubber/{common → mysql_proxy}/database.yml
  34. 0 templates/mysql_proxy/config/rubber/{common → mysql_proxy}/mysql-proxy
  35. 0 templates/mysql_proxy/config/rubber/{common → mysql_proxy}/mysql-proxy.conf
  36. 0 templates/mysql_proxy/config/rubber/{common → mysql_proxy}/mysql-proxy.lua
  37. +3 −0 templates/mysql_proxy/config/rubber/rubber-mysql_proxy.yml
  38. +1 −1 templates/resque/config/rubber/deploy-resque.rb
View
26 lib/rubber/commands/vulcanize.rb
@@ -90,6 +90,22 @@ def vulcanize(template_names)
protected
+ def project_roles
+ return @project_roles if @project_roles
+
+ @project_roles = Dir["#{destination_root}/config/rubber/role/*"].collect {|f| File.basename(f) }
+ @template_dependencies.each do |name|
+ template_dir = File.join(self.class.source_root, name, '')
+ Dir["#{template_dir}/config/rubber/rubber*.yml"].each do |yml|
+ rubber_yml = YAML.load(File.read(yml)) rescue {}
+ @project_roles.concat(rubber_yml['roles'].keys) rescue nil
+ @project_roles.concat(rubber_yml['role_dependencies'].keys) rescue nil
+ @project_roles.concat(rubber_yml['role_dependencies'].values) rescue nil
+ end
+ end
+ @project_roles = @project_roles.flatten.uniq
+ end
+
def find_dependencies(name)
template_dir = File.join(self.class.source_root, name, '')
unless File.directory?(template_dir)
@@ -124,6 +140,16 @@ def apply_template(name)
source_rel = f.gsub(/#{self.class.source_root}\//, '')
dest_rel = source_rel.gsub(/^#{name}\//, '')
+ if template_conf['skip_unknown_roles']
+ if f =~ /config\/rubber\/role\/([^\/]*)/
+ role = $1
+ if ! project_roles.include?(role)
+ say_status :skipping, dest_rel, :yellow
+ Find.prune
+ end
+ end
+ end
+
# Only include optional files when their conditions eval to true
optional = template_conf['optional'][template_rel] rescue nil
Find.prune if optional && ! eval(optional)
View
1 templates/collectd/templates.yml
@@ -1 +1,2 @@
description: The collectd monitoring module
+skip_unknown_roles: true
View
6 templates/monit/config/rubber/deploy-monit.rb
@@ -13,17 +13,17 @@
after "rubber:post_restart", "rubber:monit:start"
desc "Start monit daemon monitoring"
- task :start do
+ task :start, :roles => :monit do
rsudo "service monit start"
end
desc "Stop monit daemon monitoring"
- task :stop do
+ task :stop, :roles => :monit do
rsudo "service monit stop; exit 0"
end
desc "Restart monit daemon monitoring"
- task :restart do
+ task :restart, :roles => :monit do
stop
start
end
View
0 ...nfig/rubber/role/apache/monit-apache.conf → ...nfig/rubber/role/apache/monit-apache.conf
File renamed without changes.
View
0 ...ubber/role/cassandra/monit-cassandra.conf → ...ubber/role/cassandra/monit-cassandra.conf
File renamed without changes.
View
0 ...raphite_server/monit-graphite_server.conf → ...raphite_server/monit-graphite_server.conf
File renamed without changes.
View
0 ...ig/rubber/role/haproxy/monit-haproxy.conf → ...ig/rubber/role/haproxy/monit-haproxy.conf
File renamed without changes.
View
0 ...config/rubber/role/jetty/monit-jetty.conf → ...config/rubber/role/jetty/monit-jetty.conf
File renamed without changes.
View
0 ...fig/rubber/role/mongodb/monit-mongodb.cnf → ...ig/rubber/role/mongodb/monit-mongodb.conf
File renamed without changes.
View
0 ...ig/rubber/role/mongrel/monit-mongrel.conf → ...ig/rubber/role/mongrel/monit-mongrel.conf
File renamed without changes.
View
0 ...t/config/rubber/common/monit-default.conf → ...nfig/rubber/role/monit/monit-default.conf
File renamed without changes.
View
0 ...nin/config/rubber/common/monit-munin.conf → ...config/rubber/role/monit/monit-munin.conf
File renamed without changes.
View
0 ...e/config/rubber/common/monit-postfix.conf → ...nfig/rubber/role/monit/monit-postfix.conf
File renamed without changes.
View
0 ...tes/monit/config/rubber/common/monit.conf → ...monit/config/rubber/role/monit/monit.conf
File renamed without changes.
View
0 ...sql/config/rubber/role/db/monit-mysql.cnf → ...config/rubber/role/mysql/monit-mysql.conf
File renamed without changes.
View
0 ...onfig/rubber/common/monit-mysql_proxy.cnf → ...r/role/mysql_proxy/monit-mysql_proxy.conf
File renamed without changes.
View
0 ...ber/role/passenger_nginx/monit-nginx.conf → ...config/rubber/role/nginx/monit-nginx.conf
File renamed without changes.
View
0 ...config/rubber/role/nginx/monit-nginx.conf → ...ber/role/passenger_nginx/monit-nginx.conf
File renamed without changes.
View
0 ...nfig/rubber/role/db/monit-postgresql.conf → ...ber/role/postgresql/monit-postgresql.conf
File renamed without changes.
View
0 ...config/rubber/role/redis/monit-redis.conf → ...config/rubber/role/redis/monit-redis.conf
File renamed without changes.
View
0 ...ber/role/resque_web/monit-resque_web.conf → ...ber/role/resque_web/monit-resque_web.conf
File renamed without changes.
View
0 ...le/resque_worker/monit-resque_worker.conf → ...le/resque_worker/monit-resque_worker.conf
File renamed without changes.
View
0 ...nfig/rubber/role/sphinx/monit-sphinx.conf → ...nfig/rubber/role/sphinx/monit-sphinx.conf
File renamed without changes.
View
7 templates/monit/config/rubber/rubber-monit.yml
@@ -2,5 +2,10 @@
monit_admin_port: 2812
-packages: [monit]
+role_dependencies:
+ common: [monit]
+
+roles:
+ monit:
+ packages: [monit]
View
1 templates/monit/templates.yml
@@ -1 +1,2 @@
description: The monit module
+skip_unknown_roles: true
View
8 templates/munin/config/rubber/deploy-munin.rb
@@ -13,7 +13,7 @@
desc <<-DESC
Reconfigures munin
DESC
- task :install do
+ task :install, :roles => [:munin] do
rubber.sudo_script 'setup_munin_plugins', <<-ENDSCRIPT
munin-node-configure --shell --remove-also > /tmp/setup-munin-plugins 2> /dev/null || true
sh /tmp/setup-munin-plugins
@@ -61,17 +61,17 @@
# after "deploy:restart", "rubber:munin:restart"
desc "Start munin system monitoring"
- task :start do
+ task :start, :roles => :munin do
rsudo "service munin-node start"
end
desc "Stop munin system monitoring"
- task :stop do
+ task :stop, :roles => :munin do
rsudo "service munin-node stop; exit 0"
end
desc "Restart munin system monitoring"
- task :restart do
+ task :restart, :roles => :munin do
stop
start
end
View
0 ...unin/config/rubber/common/munin-node.conf → .../config/rubber/role/munin/munin-node.conf
File renamed without changes.
View
0 ...n/config/rubber/common/munin-plugins.conf → ...nfig/rubber/role/munin/munin-plugins.conf
File renamed without changes.
View
5 templates/munin/config/rubber/rubber-munin.yml
@@ -1,8 +1,11 @@
# Uses admin_email from base
-packages: [munin-node, munin-plugins-extra, heirloom-mailx]
+role_dependencies:
+ common: [munin]
roles:
+ munin:
+ packages: [munin-node, munin-plugins-extra, heirloom-mailx]
web_tools:
packages: [munin]
mysql:
View
1 templates/munin/templates.yml
@@ -1 +1,2 @@
description: The munin module
+skip_unknown_roles: true
View
10 templates/mysql_cluster/config/rubber/role/mysql_sql/monit-mysql_cluster_sql.cnf
@@ -1,10 +0,0 @@
-<%
- @path = '/etc/monit/monit.d/monit-mysql_cluster_sql.conf'
-%>
-
-check process mysql_cluster_sql with pidfile /var/lib/mysql/<%= rubber_env.full_host %>.pid
- group mysql_cluster_sql-<%= RUBBER_ENV %>
- start program = "/usr/bin/env service mysql start"
- stop program = "/usr/bin/env service mysql stop"
- if failed host 127.0.0.1 port 3306 protocol mysql then alert
- if 5 restarts within 5 cycles then timeout
View
3 templates/mysql_cluster/config/rubber/rubber-mysql_cluster.yml
@@ -20,6 +20,9 @@ db_restore_cmd: "zcat - | mysql -h %host% -u %user% --password=%pass% %name%"
#
db_data_dir: /mnt/mysql_cluster_data
+role_dependencies:
+ mysql_sql: [mysql]
+
packages: [mysql-client, libmysql-ruby]
View
0 ...l_proxy/config/rubber/common/database.yml → ...xy/config/rubber/mysql_proxy/database.yml
File renamed without changes.
View
0 ...ql_proxy/config/rubber/common/mysql-proxy → ...oxy/config/rubber/mysql_proxy/mysql-proxy
File renamed without changes.
View
0 ...oxy/config/rubber/common/mysql-proxy.conf → ...onfig/rubber/mysql_proxy/mysql-proxy.conf
File renamed without changes.
View
0 ...roxy/config/rubber/common/mysql-proxy.lua → ...config/rubber/mysql_proxy/mysql-proxy.lua
File renamed without changes.
View
3 templates/mysql_proxy/config/rubber/rubber-mysql_proxy.yml
@@ -8,4 +8,7 @@
# or 'mysql_master' for just master
mysql_proxy_role: mysql_sql
+role_dependencies:
+ common: [mysql_proxy]
+
packages: [mysql-proxy]
View
2 templates/resque/config/rubber/deploy-resque.rb
@@ -29,7 +29,7 @@
end
# pauses deploy until all workers up so monit doesn't try and start them
- before "rubber:monit:start", "rubber:resque:worker:wait_start"
+ before "rubber:post_start", "rubber:resque:worker:wait_start"
task :wait_start, :roles => :resque_worker do
logger.info "Waiting for resque worker pid files to show up"

0 comments on commit 46993e2

Please sign in to comment.