centostrano 0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. data/CHANGELOG +215 -0
  2. data/COPYING +19 -0
  3. data/LICENSE +339 -0
  4. data/README +166 -0
  5. data/THANKS +5 -0
  6. data/bin/centify +137 -0
  7. data/docs/ANNOUNCE.deprec2 +47 -0
  8. data/docs/README.install +88 -0
  9. data/docs/README.nagios +28 -0
  10. data/docs/README.rails +20 -0
  11. data/docs/README.svn +31 -0
  12. data/docs/ROADMAP.txt +74 -0
  13. data/docs/deprec-1.x/deprec-1.x.quickstart +50 -0
  14. data/docs/deprec-1.x/notes.txt +12 -0
  15. data/docs/deprec_banner.gif +0 -0
  16. data/lib/centostrano.rb +9 -0
  17. data/lib/deprec/capistrano_extensions.rb +391 -0
  18. data/lib/deprec/centostrano.rb +46 -0
  19. data/lib/deprec/recipes/apache.rb +188 -0
  20. data/lib/deprec/recipes/canonical.rb +57 -0
  21. data/lib/deprec/recipes/deprec.rb +188 -0
  22. data/lib/deprec/recipes/deprecated.rb +71 -0
  23. data/lib/deprec/recipes/example.rb +115 -0
  24. data/lib/deprec/recipes/git.rb +106 -0
  25. data/lib/deprec/recipes/gitosis.rb +134 -0
  26. data/lib/deprec/recipes/logrotate.rb +54 -0
  27. data/lib/deprec/recipes/memcache.rb +53 -0
  28. data/lib/deprec/recipes/merb.rb +57 -0
  29. data/lib/deprec/recipes/mongrel.rb +220 -0
  30. data/lib/deprec/recipes/monit.rb +139 -0
  31. data/lib/deprec/recipes/mysql.rb +147 -0
  32. data/lib/deprec/recipes/nginx.rb +172 -0
  33. data/lib/deprec/recipes/postgresql.rb +132 -0
  34. data/lib/deprec/recipes/rails.rb +297 -0
  35. data/lib/deprec/recipes/ruby.rb +71 -0
  36. data/lib/deprec/recipes/sphinx.rb +89 -0
  37. data/lib/deprec/recipes/ssh.rb +93 -0
  38. data/lib/deprec/recipes/svn.rb +167 -0
  39. data/lib/deprec/recipes/users.rb +90 -0
  40. data/lib/deprec/recipes.rb +33 -0
  41. data/lib/deprec/templates/aoe/aoe-init +55 -0
  42. data/lib/deprec/templates/aoe/fence_aoemask +351 -0
  43. data/lib/deprec/templates/apache/httpd-vhost-app.conf.erb +144 -0
  44. data/lib/deprec/templates/apache/httpd.conf +465 -0
  45. data/lib/deprec/templates/apache/index.html.erb +37 -0
  46. data/lib/deprec/templates/apache/master.css +72 -0
  47. data/lib/deprec/templates/centos/repository.erb +6 -0
  48. data/lib/deprec/templates/coraid/aoe-init +55 -0
  49. data/lib/deprec/templates/deprec/caprc.erb +14 -0
  50. data/lib/deprec/templates/heartbeat/authkeys.erb +2 -0
  51. data/lib/deprec/templates/heartbeat/ha.cf.erb +15 -0
  52. data/lib/deprec/templates/heartbeat/haresources.erb +1 -0
  53. data/lib/deprec/templates/logrotate/logrotate.conf.erb +32 -0
  54. data/lib/deprec/templates/mongrel/logrotate.conf.erb +11 -0
  55. data/lib/deprec/templates/mongrel/logrotate.erb +0 -0
  56. data/lib/deprec/templates/mongrel/mongrel_cluster-init-script +54 -0
  57. data/lib/deprec/templates/mongrel/mongrel_cluster.logrotate.d +14 -0
  58. data/lib/deprec/templates/mongrel/mongrel_cluster.yml.erb +10 -0
  59. data/lib/deprec/templates/mongrel/monit.conf.erb +17 -0
  60. data/lib/deprec/templates/monit/monit-init-script +104 -0
  61. data/lib/deprec/templates/monit/monitrc.erb +227 -0
  62. data/lib/deprec/templates/monit/nothing +0 -0
  63. data/lib/deprec/templates/mysql/create_databases.sql +20 -0
  64. data/lib/deprec/templates/mysql/database.yml.prod +6 -0
  65. data/lib/deprec/templates/mysql/database.yml.stage +6 -0
  66. data/lib/deprec/templates/mysql/my.cnf.erb +140 -0
  67. data/lib/deprec/templates/mysql/sphinx.conf.prod +542 -0
  68. data/lib/deprec/templates/mysql/sphinx.conf.stage +542 -0
  69. data/lib/deprec/templates/nagios/cgi.cfg.erb +321 -0
  70. data/lib/deprec/templates/nagios/commands.cfg.erb +240 -0
  71. data/lib/deprec/templates/nagios/contacts.cfg.erb +57 -0
  72. data/lib/deprec/templates/nagios/hosts.cfg.erb +143 -0
  73. data/lib/deprec/templates/nagios/htpasswd.users +1 -0
  74. data/lib/deprec/templates/nagios/localhost.cfg.erb +157 -0
  75. data/lib/deprec/templates/nagios/nagios.cfg.erb +1274 -0
  76. data/lib/deprec/templates/nagios/nagios_apache_vhost.conf.erb +45 -0
  77. data/lib/deprec/templates/nagios/nrpe.cfg.erb +210 -0
  78. data/lib/deprec/templates/nagios/nrpe.xinetd.erb +16 -0
  79. data/lib/deprec/templates/nagios/resource.cfg.erb +34 -0
  80. data/lib/deprec/templates/nagios/services.cfg.erb +79 -0
  81. data/lib/deprec/templates/nagios/templates.cfg.erb +9 -0
  82. data/lib/deprec/templates/nagios/timeperiods.cfg.erb +94 -0
  83. data/lib/deprec/templates/network/hostname.erb +1 -0
  84. data/lib/deprec/templates/network/hosts.erb +2 -0
  85. data/lib/deprec/templates/network/interfaces.erb +22 -0
  86. data/lib/deprec/templates/nginx/logrotate.conf.erb +13 -0
  87. data/lib/deprec/templates/nginx/logrotate.erb +0 -0
  88. data/lib/deprec/templates/nginx/mime.types.erb +70 -0
  89. data/lib/deprec/templates/nginx/nginx-init-script +109 -0
  90. data/lib/deprec/templates/nginx/nginx.conf.erb +120 -0
  91. data/lib/deprec/templates/nginx/nginx.logrotate.d +12 -0
  92. data/lib/deprec/templates/nginx/nothing.conf +1 -0
  93. data/lib/deprec/templates/nginx/rails_nginx_vhost.conf.erb +41 -0
  94. data/lib/deprec/templates/ntp/ntp.conf.erb +42 -0
  95. data/lib/deprec/templates/postfix/aliases.erb +3 -0
  96. data/lib/deprec/templates/postfix/dynamicmaps.cf.erb +8 -0
  97. data/lib/deprec/templates/postfix/main.cf.erb +41 -0
  98. data/lib/deprec/templates/postfix/master.cf.erb +77 -0
  99. data/lib/deprec/templates/postgresql/pg_hba.conf.erb +76 -0
  100. data/lib/deprec/templates/sphinx/monit.conf.erb +5 -0
  101. data/lib/deprec/templates/ssh/ssh_config.erb +50 -0
  102. data/lib/deprec/templates/ssh/sshd_config.erb +78 -0
  103. data/lib/deprec/templates/subversion/svn.apache.vhost.erb +43 -0
  104. data/lib/deprec/templates/trac/apache_vhost.conf.erb +24 -0
  105. data/lib/deprec/templates/trac/trac.ini.erb +106 -0
  106. data/lib/deprec/templates/trac/trac_deprec.png +0 -0
  107. data/lib/deprec/templates/trac/tracd-init.erb +43 -0
  108. data/lib/deprec/templates/xen/15-disable-hwclock +40 -0
  109. data/lib/deprec/templates/xen/network-bridge-wrapper +3 -0
  110. data/lib/deprec/templates/xen/xen-tools.conf.erb +220 -0
  111. data/lib/deprec/templates/xen/xend-config.sxp.erb +195 -0
  112. data/lib/deprec/templates/xen/xend-init.erb +69 -0
  113. data/lib/deprec/templates/xen/xendomains.erb +137 -0
  114. data/lib/deprec/templates/xen/xm.tmpl.erb +85 -0
  115. data/lib/deprec_cmd_completion.sh +26 -0
  116. data/lib/vmbuilder_plugins/all.rb +20 -0
  117. data/lib/vmbuilder_plugins/apt.rb +93 -0
  118. data/lib/vmbuilder_plugins/emerge.rb +76 -0
  119. data/lib/vmbuilder_plugins/gem.rb +90 -0
  120. data/lib/vmbuilder_plugins/std.rb +203 -0
  121. metadata +207 -0
@@ -0,0 +1,93 @@
1
+ # Copyright 2006-2008 by Mike Bailey. All rights reserved.
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+ namespace :centos do
4
+ namespace :ssh do
5
+
6
+ SYSTEM_CONFIG_FILES[:ssh] = [
7
+
8
+ {:template => "sshd_config.erb",
9
+ :path => '/etc/ssh/sshd_config',
10
+ :mode => 0644,
11
+ :owner => 'root:root'},
12
+
13
+ {:template => "ssh_config.erb",
14
+ :path => '/etc/ssh/ssh_config',
15
+ :mode => 0644,
16
+ :owner => 'root:root'}
17
+ ]
18
+
19
+ task :config_gen do
20
+ SYSTEM_CONFIG_FILES[:ssh].each do |file|
21
+ deprec2.render_template(:ssh, file)
22
+ end
23
+ auth_keys_dir = 'config/ssh/authorized_keys'
24
+ if ! File.directory?(auth_keys_dir)
25
+ puts "Creating #{auth_keys_dir}"
26
+ Dir.mkdir(auth_keys_dir)
27
+ end
28
+ end
29
+
30
+ desc "Push ssh config files to server"
31
+ task :config do
32
+ deprec2.push_configs(:ssh, SYSTEM_CONFIG_FILES[:ssh])
33
+ restart
34
+ end
35
+
36
+ desc "Start ssh"
37
+ task :start do
38
+ send(run_method, "/etc/init.d/sshd reload")
39
+ end
40
+
41
+ desc "Stop ssh"
42
+ task :stop do
43
+ send(run_method, "/etc/init.d/sshd reload")
44
+ end
45
+
46
+ desc "Restart ssh"
47
+ task :restart do
48
+ send(run_method, "/etc/init.d/sshd restart")
49
+ end
50
+
51
+ desc "Reload ssh"
52
+ task :reload do
53
+ send(run_method, "/etc/init.d/sshd reload")
54
+ end
55
+
56
+ desc "Sets up authorized_keys file on remote server"
57
+ task :setup_keys do
58
+
59
+ default(:target_user) {
60
+ Capistrano::CLI.ui.ask "Setup keys for which user?" do |q|
61
+ q.default = user
62
+ end
63
+ }
64
+
65
+ if target_user == user
66
+
67
+ unless ssh_options[:keys]
68
+ puts <<-ERROR
69
+
70
+ You need to define the name of your SSH key(s)
71
+ e.g. ssh_options[:keys] = %w(/Users/your_username/.ssh/id_rsa)
72
+
73
+ You can put this in your .caprc file in your home directory.
74
+
75
+ ERROR
76
+ exit
77
+ 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 )
81
+
82
+ else
83
+
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"
87
+
88
+ end
89
+ end
90
+
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,167 @@
1
+ # Copyright 2006-2008 by Mike Bailey. All rights reserved.
2
+ require 'fileutils'
3
+ require 'uri'
4
+
5
+ # http://svnbook.red-bean.com/en/1.4/svn-book.html#svn.serverconfig.choosing.apache
6
+
7
+ Capistrano::Configuration.instance(:must_exist).load do
8
+ namespace :centos do namespace :svn do
9
+
10
+ set :scm_group, 'scm'
11
+
12
+ # Extract svn attributes from :repository URL
13
+ #
14
+ # Two examples of :repository entries are:
15
+ #
16
+ # set :repository, 'svn+ssh://scm.deprecated.org/var/svn/deprec/trunk'
17
+ # set :repository, 'file:///tmp/svn/deprec/trunk'
18
+ #
19
+ # This has only been tested with svn+ssh but file: should work.
20
+ #
21
+ set (:svn_scheme) { URI.parse(repository).scheme }
22
+ set (:svn_host) { URI.parse(repository).host }
23
+ set (:repos_path) { URI.parse(repository).path }
24
+ set (:repos_root) {
25
+ URI.parse(repository).path.sub(/\/(trunk|tags|branches)$/, '')
26
+ }
27
+
28
+ # account name to perform actions on (such as granting access to an account)
29
+ # this is a hack to allow us to optionally pass a variable to tasks
30
+ set (:svn_account) do
31
+ Capistrano::CLI.ui.ask 'account name'
32
+ end
33
+
34
+ set(:svn_backup_dir) { File.join(backup_dir, 'svn') }
35
+
36
+ desc "Install Subversion"
37
+ task :install, :roles => :scm do
38
+ install_deps
39
+ # XXX should really check if apache has already been installed
40
+ # XXX can do that when we move to rake
41
+ # deprec2.download_src(src_package, src_dir)
42
+ # deprec2.install_from_src(src_package, src_dir)
43
+ end
44
+
45
+ desc "install dependencies for Subversion"
46
+ task :install_deps do
47
+ yum.enable_repository(:rpmforge)
48
+ apt.install( {:base => %w(subversion)}, :stable )
49
+ # XXX deprec1 - was building from source to get subversion-1.4.5 onto dapper. Compiled swig bindings for trac
50
+ # apt.install( {:base => %w(build-essential wget libneon25 libneon25-dev swig python-dev libexpat1-dev)}, :stable )
51
+ end
52
+
53
+ desc "grant a user access to svn repos"
54
+ task :grant_user_access, :roles => :scm do
55
+ # creates account, scm_group and adds account to group
56
+ deprec2.useradd(svn_account)
57
+ deprec2.groupadd(scm_group)
58
+ deprec2.add_user_to_group(svn_account, scm_group)
59
+ end
60
+
61
+ desc "Create subversion repository and import project into it"
62
+ task :setup, :roles => :scm do
63
+ create_repos
64
+ import
65
+ end
66
+
67
+ desc "Create a subversion repository"
68
+ task :create_repos, :roles => :scm do
69
+ set :svn_account, top.user
70
+ grant_user_access
71
+ deprec2.mkdir(repos_root, :mode => 02775, :group => scm_group, :via => :sudo)
72
+ sudo "svnadmin verify #{repos_root} > /dev/null 2>&1 || sudo svnadmin create #{repos_root}"
73
+ sudo "chmod -R g+w #{repos_root}"
74
+ end
75
+
76
+ # Adapted from code in Bradley Taylors RailsMachine gem
77
+ desc "Import project into subversion repository."
78
+ task :import, :roles => :scm do
79
+ new_path = "../#{application}"
80
+ tags = repository.sub("trunk", "tags")
81
+ branches = repository.sub("trunk", "branches")
82
+ puts "Adding branches and tags"
83
+ system "svn mkdir -m 'Adding tags and branches directories' #{tags} #{branches}"
84
+ puts "Importing application."
85
+ system "svn import #{repository} -m 'Import'"
86
+ cwd = Dir.getwd
87
+ puts "Moving application to new directory"
88
+ Dir.chdir '../'
89
+ system "mv #{cwd} #{cwd}.imported"
90
+ puts "Checking out application."
91
+ system "svn co #{repository} #{application}"
92
+ Dir.chdir application
93
+ remove_log_and_tmp
94
+ puts "Your repository is: #{repository}"
95
+ end
96
+
97
+ # Lifted from Bradley Taylors RailsMachine gem
98
+ desc "remove and ignore log files and tmp from subversion"
99
+ task :remove_log_and_tmp, :roles => :scm do
100
+ puts "removing log directory contents from svn"
101
+ system "svn remove log/*"
102
+ puts "ignoring log directory"
103
+ system "svn propset svn:ignore '*.log' log/"
104
+ system "svn update log/"
105
+ puts "removing contents of tmp sub-directorys from svn"
106
+ system "svn remove tmp/cache/*"
107
+ system "svn remove tmp/pids/*"
108
+ system "svn remove tmp/sessions/*"
109
+ system "svn remove tmp/sockets/*"
110
+ puts "ignoring tmp directory"
111
+ system "svn propset svn:ignore '*' tmp/cache"
112
+ system "svn propset svn:ignore '*' tmp/pids"
113
+ system "svn propset svn:ignore '*' tmp/sessions"
114
+ system "svn propset svn:ignore '*' tmp/sockets"
115
+ system "svn update tmp/"
116
+ puts "committing changes"
117
+ system "svn commit -m 'Removed and ignored log files and tmp'"
118
+ end
119
+
120
+ # desc "Cache svn name and password on the server. Useful for http-based repositories."
121
+ task :cache_credentials do
122
+ run_with_input "svn list #{repository}"
123
+ end
124
+
125
+ desc "create backup of trac repository"
126
+ task :backup, :roles => :scm do
127
+ # http://svnbook.red-bean.com/nightly/en/svn.reposadmin.maint.html#svn.reposadmin.maint.backup
128
+ # XXX do we need this? insane!
129
+ # echo "REPOS_BASE=/var/svn" > ~/.svntoolsrc
130
+ timestamp = Time.now.utc.strftime("%Y%m%d%H%M%S")
131
+ dest_dir = File.join(svn_backup_dir, "svn_#{application}_#{timestamp}")
132
+ run "svn-dump #{application} #{dest_dir}"
133
+ end
134
+
135
+ task :restore, :roles => :scm do
136
+ # prompt user to select from list of locally stored backups
137
+ # tracd_stop
138
+ # copy out backup
139
+ end
140
+
141
+
142
+ # XXX TODO
143
+ # desc "backup repository"
144
+ # task :svn_backup_respository, :roles => :scm do
145
+ # puts "read http://svnbook.red-bean.com/nightly/en/svn-book.html#svn.reposadmin.maint.backup"
146
+ # end
147
+
148
+ end end
149
+ end
150
+
151
+ # svnserve setup
152
+ # I've previously used ssh exclusively I've decided svnserve is a reasonable choice for collaboration on open source projects.
153
+ # It's easier to setup than apache/ssl webdav access.
154
+ #
155
+ # sudo useradd svn
156
+ # sudo mkdir -p /var/svn/deprec_svnserve_root
157
+ # sudo ln -sf /var/www/apps/deprec/repos /var/svn/deprec_svnserve_root/deprec
158
+ # sudo chown -R svn /var/svn/deprec_svnserve_root/deprec
159
+
160
+ #
161
+ # XXX put password file into svn and command to push it
162
+ #
163
+ # # run svnserve
164
+ # sudo -u svn svnserve --daemon --root /var/svn/deprec_svnserve_root
165
+ #
166
+ # # check it out now
167
+ # svn co svn://scm.deprecated.org/deprec/trunk deprec
@@ -0,0 +1,90 @@
1
+ # Copyright 2006-2008 by Mike Bailey. All rights reserved.
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+ namespace :centos do
4
+ namespace :users do
5
+
6
+ # desc "Create user account"
7
+ # task :add do
8
+ # target_user = Capistrano::CLI.ui.ask "Enter userid for new user" do |q|
9
+ # q.default = user
10
+ # end
11
+ # deprec2.useradd(target_user, :shell => '/bin/bash')
12
+ # puts "Setting password for new account"
13
+ # deprec2.invoke_with_input("passwd #{target_user}", /UNIX password/)
14
+ # end
15
+
16
+ desc "Create account"
17
+ task :add do
18
+ target_user = Capistrano::CLI.ui.ask "Enter userid for new user" do |q|
19
+ q.default = user
20
+ end
21
+ make_admin = Capistrano::CLI.ui.ask "Should this be an admin account?" do |q|
22
+ q.default = 'no'
23
+ end
24
+ copy_keys = false
25
+ if File.readable?("config/ssh/authorized_keys/#{target_user}")
26
+ copy_keys = Capistrano::CLI.ui.ask "I've found an authorized_keys file for #{target_user}. Should I copy it out?" do |q|
27
+ q.default = 'yes'
28
+ end
29
+ end
30
+
31
+ new_password = Capistrano::CLI.ui.ask("Enter new password for #{target_user}") { |q| q.echo = false }
32
+
33
+ deprec2.useradd(target_user, :shell => '/bin/bash')
34
+
35
+ deprec2.invoke_with_input("passwd #{target_user}", /UNIX password/, new_password)
36
+
37
+ if make_admin.grep(/y/i)
38
+ deprec2.groupadd('admin')
39
+ deprec2.add_user_to_group(target_user, 'admin')
40
+ deprec2.append_to_file_if_missing('/etc/sudoers', '%admin ALL=(ALL) ALL')
41
+ end
42
+
43
+ if copy_keys && copy_keys.grep(/y/i)
44
+ set :target_user, target_user
45
+ top.centos.ssh.setup_keys
46
+ end
47
+
48
+ end
49
+
50
+ desc "Create account"
51
+ task :add_admin do
52
+ puts 'deprecated! use deprec:users:add'
53
+ add
54
+ end
55
+
56
+ desc "Change user password"
57
+ task :passwd do
58
+ target_user = Capistrano::CLI.ui.ask "Enter user to change password for" do |q|
59
+ q.default = user if user.is_a?(String)
60
+ end
61
+ new_password = Capistrano::CLI.ui.ask("Enter new password for #{target_user}") { |q| q.echo = false }
62
+
63
+ deprec2.invoke_with_input("passwd #{target_user}", /UNIX password/, new_password)
64
+ end
65
+
66
+ desc "Add user to group"
67
+ task :add_user_to_group do
68
+ target_user = Capistrano::CLI.ui.ask "Which user?" do |q|
69
+ q.default = user if user.is_a?(String)
70
+ end
71
+ target_group = Capistrano::CLI.ui.ask "Add to which group?" do |q|
72
+ q.default = 'deploy'
73
+ end
74
+ deprec2.add_user_to_group(target_user, target_group)
75
+ end
76
+
77
+ # desc "Create group"
78
+ # task :add_group do
79
+ # target_group = Capistrano::CLI.ui.ask "Enter name for new group"
80
+ # deprec2.groupadd(target_group)
81
+ # end
82
+ #
83
+ # desc "Add user to group"
84
+ # task :add_user_to_group do
85
+ # # XXX not yet implemented
86
+ # end
87
+
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,33 @@
1
+ # Copyright 2006-2008 by Mike Bailey. All rights reserved.
2
+ unless Capistrano::Configuration.respond_to?(:instance)
3
+ abort "Centostrano requires Capistrano 2"
4
+ end
5
+ require "#{File.dirname(__FILE__)}/recipes/deprec"
6
+ require "#{File.dirname(__FILE__)}/recipes/deprecated"
7
+ # require "#{File.dirname(__FILE__)}/recipes/canonical"
8
+ require "#{File.dirname(__FILE__)}/recipes/users"
9
+ require "#{File.dirname(__FILE__)}/recipes/ssh"
10
+ require "#{File.dirname(__FILE__)}/recipes/nginx"
11
+ require "#{File.dirname(__FILE__)}/recipes/apache"
12
+ #require "#{File.dirname(__FILE__)}/recipes/php"
13
+ require "#{File.dirname(__FILE__)}/recipes/svn"
14
+ #require "#{File.dirname(__FILE__)}/recipes/trac"
15
+ require "#{File.dirname(__FILE__)}/recipes/ruby"
16
+ require "#{File.dirname(__FILE__)}/recipes/rails"
17
+ require "#{File.dirname(__FILE__)}/recipes/mongrel"
18
+ require "#{File.dirname(__FILE__)}/recipes/mysql"
19
+ #require "#{File.dirname(__FILE__)}/recipes/postfix"
20
+ require "#{File.dirname(__FILE__)}/recipes/memcache"
21
+ require "#{File.dirname(__FILE__)}/recipes/monit"
22
+ #require "#{File.dirname(__FILE__)}/recipes/network"
23
+ #require "#{File.dirname(__FILE__)}/recipes/aoe"
24
+ #require "#{File.dirname(__FILE__)}/recipes/ntp"
25
+ #require "#{File.dirname(__FILE__)}/recipes/nagios"
26
+ #require "#{File.dirname(__FILE__)}/recipes/heartbeat"
27
+ #require "#{File.dirname(__FILE__)}/recipes/xen"
28
+ require "#{File.dirname(__FILE__)}/recipes/sphinx"
29
+ require "#{File.dirname(__FILE__)}/recipes/git"
30
+ require "#{File.dirname(__FILE__)}/recipes/gitosis"
31
+ require "#{File.dirname(__FILE__)}/recipes/postgresql"
32
+ require "#{File.dirname(__FILE__)}/recipes/logrotate"
33
+ require "#{File.dirname(__FILE__)}/recipes/merb"
@@ -0,0 +1,55 @@
1
+ #! /bin/sh
2
+ # aoe-init - example init script for ATA over Ethernet storage
3
+ #
4
+ # Edit this script for your purposes. (Changing "eth1" to the
5
+ # appropriate interface name, adding commands, etc.) You might
6
+ # need to tune the sleep times.
7
+ #
8
+ # Install this script in /etc/init.d with the other init scripts.
9
+ #
10
+ # Make it executable:
11
+ # chmod 755 /etc/init.d/aoe-init
12
+ #
13
+ # Install symlinks for boot time:
14
+ # cd /etc/rc3.d && ln -s ../init.d/aoe-init S99aoe-init
15
+ # cd /etc/rc5.d && ln -s ../init.d/aoe-init S99aoe-init
16
+ #
17
+ # Install symlinks for shutdown time:
18
+ # cd /etc/rc0.d && ln -s ../init.d/aoe-init K01aoe-init
19
+ # cd /etc/rc1.d && ln -s ../init.d/aoe-init K01aoe-init
20
+ # cd /etc/rc2.d && ln -s ../init.d/aoe-init K01aoe-init
21
+ # cd /etc/rc6.d && ln -s ../init.d/aoe-init K01aoe-init
22
+ #
23
+
24
+ case "$1" in
25
+ "start")
26
+ # load any needed network drivers here
27
+
28
+ # replace "eth1" with your aoe network interface
29
+ ifconfig eth1 up
30
+
31
+ # time for network interface to come up
32
+ sleep 4
33
+
34
+ modprobe aoe
35
+
36
+ # time for AoE discovery and udev
37
+ sleep 7
38
+
39
+ # add your raid assemble commands here
40
+ # add any LVM commands if needed (e.g. vgchange)
41
+ # add your filesystem mount commands here
42
+
43
+ test -d /var/lock/subsys && touch /var/lock/subsys/aoe-init
44
+ ;;
45
+ "stop")
46
+ # add your filesystem umount commands here
47
+ # deactivate LVM volume groups if needed
48
+ # add your raid stop commands here
49
+ rmmod aoe
50
+ rm -f /var/lock/subsys/aoe-init
51
+ ;;
52
+ *)
53
+ echo "usage: `basename $0` {start|stop}" 1>&2
54
+ ;;
55
+ esac
@@ -0,0 +1,351 @@
1
+ #!/usr/bin/perl
2
+
3
+ #
4
+ # Wrapper to aoemask for use in a cluster fence.
5
+ # Copyright (C) 2007 Brian Weck (bweck@weck.net)
6
+ #
7
+ # This script utilizes the 'aoemask' utility from:
8
+ # http://www.coraid.com/support/sr/
9
+ # which is written by Sam Hopkins.
10
+ #
11
+ # =======================================================================
12
+ # This program is free software; you can redistribute it and/or modify
13
+ # it under the terms of the GNU General Public License as published by
14
+ # the Free Software Foundation; either version 2 of the License, or
15
+ # (at your option) any later version.
16
+ #
17
+ # This program is distributed in the hope that it will be useful,
18
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
+ # GNU General Public License for more details.
21
+ #
22
+ # You should have received a copy of the GNU General Public License
23
+ # along with this program; if not, write to the Free Software
24
+ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25
+ # =======================================================================
26
+ #
27
+ # ~~~~~ REVISION HISTORY ~~~~~
28
+ # 2007-08-17 - v1 - Brian Weck
29
+ # Initial release.
30
+ #
31
+ # ~~~~~ OVERVIEW ~~~~~
32
+ # Initial mask settings on the AoE device should contain the set of all
33
+ # MAC addresses using the AoE device from the cluster.
34
+ #
35
+ # When a fence operation occurs on a node, the fenced node's mac address is
36
+ # removed from the mask list on the AoE device. This method is conceptually
37
+ # the same as fencing via a fabric switch.
38
+ #
39
+ # Once a node is fenced, the MAC address is removed from the mask list on
40
+ # the AoE device. When the fenced node is ready to rejoin the cluster,
41
+ # the MAC address must be added to the device's mask list using this
42
+ # script or using aoemask.
43
+ #
44
+ # Script returns 0 on SUCCESS and non-zero otherwise.
45
+ #
46
+ # ~~~~~ INSTALLATION ~~~~~
47
+ # Add this file as /sbin/fence_aoemask directory and ensure the file has
48
+ # simliar permissions as the other fence_* agents.
49
+ #
50
+ # ~~~~~ CONFIGURATION ~~~~~
51
+ # This software operates on a single shelf / slot at a time. In order to
52
+ # fence multiple shelf and slots the user should create multiple fences.
53
+ #
54
+ # e.g. a cluster.conf snippet.
55
+ # <clusternode name="node1-name" nodeid="1" votes="1">
56
+ # <fence>
57
+ # <method name="1">
58
+ # <device name="fence-e0.0" mac="56:f7:0c:da:e2:2f" />
59
+ # <device name="fence-e0.1" mac="56:f7:0c:da:e2:2f" />
60
+ # </method>
61
+ # </fence>
62
+ # </clusternode>
63
+ # <clusternode name="node2-name" nodeid="2" votes="1">
64
+ # <fence>
65
+ # <method name="1">
66
+ # <device name="fence-e0.0" mac="ec:fc:96:3b:69:5a" />
67
+ # <device name="fence-e0.1" mac="ec:fc:96:3b:69:5a" />
68
+ # </method>
69
+ # </fence>
70
+ # </clusternode>
71
+ # <fencedevices>
72
+ # <fencedevice agent="fence_aoemask" name="fence-e0.0" shelf="0" slot="0" interface="eth1"/>
73
+ # <fencedevice agent="fence_aoemask" name="fence-e0.1" shelf="0" slot="1" interface="eth1"/>
74
+ # </fencedevices>
75
+ #
76
+ #
77
+ # Command line options:
78
+ # see man aoemask.8
79
+ #
80
+ # stdin options (passed from fenced):
81
+ # shelf=<num> |
82
+ # slot=<num> |
83
+ # interface=<if-name> |
84
+ # mac=<mac-addr> |
85
+ # [ action=(disable|enable) ] | default is defined in $opt_action
86
+ # [ debug=<ignored-value> ] |
87
+ # [ exclusive=<ignored-value> ] |
88
+ # [ list=<ignored-value> ] |
89
+ # [ spoof=<mac-addr> ] | Spoof behavior is to assume success always.
90
+ # [ timeout=<wait-seconds> ] |
91
+ # [ verbose=<ignored-value> ] | Option is used to increase logging of fence agent.
92
+ #
93
+
94
+ # Define where you aoemask binary lives if it is not in the path.
95
+ my $aoemask_prog="/usr/local/sbin/aoemask";
96
+ my $opt_action = 'disable'; # Default fence action
97
+
98
+ # Get the script name from $0 and strip directory names
99
+ $_=$0;
100
+ s/.*\///;
101
+ my $proggy = $_;
102
+
103
+ #
104
+ #
105
+ #
106
+ my $aoemask=$aoemask_prog;
107
+ my $opt_list = 1;
108
+ my $opt_debug = 1;
109
+ my $opt_verbose = 0;
110
+
111
+ #
112
+ sub _log
113
+ {
114
+ ($msg)=@_;
115
+ print STDOUT $msg;
116
+ }
117
+
118
+ #
119
+ sub exit_success
120
+ {
121
+ my $rc = 0;
122
+ _log "$proggy returning $rc\n" if $opt_verbose;
123
+ exit $rc;
124
+ }
125
+
126
+ #
127
+ sub exit_fail
128
+ {
129
+ my $rc = 1;
130
+ _log "$proggy returning $rc\n" if $opt_verbose;
131
+ exit $rc;
132
+ }
133
+
134
+ #
135
+ sub fail_usage
136
+ {
137
+ ($msg)=@_;
138
+ _log $msg."\n" if $msg;
139
+ _log "Please use see usage.\n";
140
+ exit_fail();
141
+ }
142
+
143
+ #
144
+ # If running command line, pass args as specified directly to aoemask
145
+ if (@ARGV > 0)
146
+ {
147
+ # Check for min number of args, 5
148
+ if( @ARGV < 5 )
149
+ {
150
+ $aoemask .= " -h";
151
+ }
152
+ else
153
+ {
154
+ # stub in the args
155
+ foreach $i (0 .. $#ARGV)
156
+ {
157
+ $aoemask .= " $ARGV[$i]";
158
+ }
159
+ }
160
+ }
161
+ else # Running via fenced, read the args in from stdin
162
+ {
163
+ read_stdin_as_options();
164
+
165
+ # validate required args are present
166
+ fail_usage "No shelf specified." unless defined $opt_shelf;
167
+ fail_usage "No slot specified." unless defined $opt_slot;
168
+ fail_usage "No interface specified." unless defined $opt_interface;
169
+ fail_usage "No mac specified." unless defined $opt_mac;
170
+
171
+ $aoemask .= " -d" if defined $opt_debug;
172
+ $aoemask .= " -e" if defined $opt_exclusive;
173
+ $aoemask .= " -l" if defined $opt_list;
174
+ $aoemask .= " -s $opt_spoof" if defined $opt_spoof;
175
+ $aoemask .= " -w $opt_timeout" if defined $opt_timeout;
176
+ $aoemask .= " $opt_shelf $opt_slot $opt_interface";
177
+
178
+ $_=$opt_action;
179
+ if (/enable/) { $aoemask .= " +$opt_mac"; }
180
+ elsif (/disable/) { $aoemask .= " -$opt_mac"; }
181
+ else
182
+ {
183
+ # This would only be reached if in the cluster.conf one specified action=
184
+ fail_usage "Unknown action: $_";
185
+ }
186
+ }
187
+
188
+ _log "$proggy executing '$aoemask'\n" if $opt_verbose;
189
+
190
+ #
191
+ # aoemask (release 1) always returns an exit code of 1
192
+ # if aoemask returned success or failure based on the response; could as follows:
193
+ #
194
+ # system($aoemask);
195
+ # $rc = ($? >> 8) & 0xff;
196
+ # exit $rc;
197
+ #
198
+
199
+ # therefore, we must ensure the listing function is performed and grep'd
200
+ open(FH, "$aoemask 2>&1 |");
201
+ @lines = <FH>;
202
+ close FH;
203
+
204
+ #
205
+ if ($opt_verbose)
206
+ {
207
+ _log "-- begin read response --\n";
208
+ foreach $line (@lines) { chop $line; _log "$line\n"; }
209
+ _log "-- end read response --\n";
210
+ }
211
+
212
+ #
213
+ if ($opt_user_says_list)
214
+ {
215
+ @x = grep { /$opt_shelf\.$opt_slot/ } @lines;
216
+ _log foreach @x;
217
+ }
218
+
219
+ #
220
+ # If spoofing, nothing is returned, we assume success.
221
+ exit_success() if $opt_spoof;
222
+
223
+ # check output of aoemask for proper values depending on action.
224
+ if( ($opt_action =~ /enable/) && (grep { /$opt_mac/ } @lines) )
225
+ {
226
+ _log "action is to enable and found mac $opt_mac in list"."\n" if $opt_verbose;
227
+ exit_success();
228
+ }
229
+ elsif( ($opt_action =~ /disable/) && !(grep { /$opt_mac/ } @lines) )
230
+ {
231
+ # here's a caveat .. which requires the debug flag to be on.
232
+ # if one is performing a disable, and specify an invalid slot / shelf / interface
233
+ # a grep for the mac will not show and therfore a return success.
234
+ #
235
+ # Workaround: need to check for an additional string, of:
236
+ # read -1 bytes
237
+ #
238
+ if( ! grep { /read -1 bytes/} @lines )
239
+ {
240
+ # did not read that string; all is ok.
241
+ _log "action is to disable and did not find mac $opt_mac in list"."\n" if $opt_verbose;
242
+ exit_success();
243
+ }
244
+ else
245
+ {
246
+ _log "No bytes were read from '$aoemask'.\n";
247
+ _log "Check the slot|shelf|interface configs.\n"
248
+ }
249
+ }
250
+
251
+ # If none of the above matched, we failed.
252
+ exit_fail();
253
+
254
+
255
+ #
256
+ # Parse the stdin options
257
+ #
258
+ sub read_stdin_as_options()
259
+ {
260
+ my $opt;
261
+ my $line = 0;
262
+ while( defined($in = <>) )
263
+ {
264
+ $_ = $in;
265
+ chomp;
266
+
267
+ # strip leading and trailing whitespace
268
+ s/^\s*//;
269
+ s/\s*$//;
270
+
271
+ # skip any comments
272
+ next if /^#/;
273
+
274
+ $line+=1;
275
+ $opt=$_;
276
+ next unless $opt;
277
+
278
+ ($name,$val)=split /\s*=\s*/, $opt;
279
+
280
+ if ( $name eq "" )
281
+ {
282
+ _log "parse error: illegal name in option $line\n";
283
+ exit_fail();
284
+ }
285
+
286
+ # shelf=<num>
287
+ # slot=<num>
288
+ # interface=<if-name>
289
+ # mac=<mac-addr>
290
+ # action=(disable|enable)
291
+ elsif ($name eq "shelf" )
292
+ {
293
+ $opt_shelf = $val;
294
+ }
295
+ elsif ($name eq "slot" )
296
+ {
297
+ $opt_slot = $val;
298
+ }
299
+ elsif ($name eq "interface" )
300
+ {
301
+ $opt_interface = $val;
302
+ }
303
+ elsif ($name eq "mac" )
304
+ {
305
+ $opt_mac = $val;
306
+ # pull out any ':' if configured as such.
307
+ # (even though aoemask can handle it)
308
+ $opt_mac =~ s/://g;
309
+ # uppercase the alphas
310
+ $opt_mac =~ tr/a-z/A-Z/;
311
+ }
312
+ elsif ($name eq "action")
313
+ {
314
+ $opt_action = $val;
315
+ }
316
+
317
+ # debug=<ignored-value>
318
+ # exclusive=<ignored-value>
319
+ # list=<ignored-value>
320
+ # spoof=<mac-addr>
321
+ # timeout=<wait-seconds>
322
+ elsif ($name eq "debug" )
323
+ {
324
+ $opt_debug = 1;
325
+ }
326
+ elsif ($name eq "exclusive" )
327
+ {
328
+ $opt_exclusive = 1;
329
+ }
330
+ elsif ($name eq "list" )
331
+ {
332
+ $opt_list = 1;
333
+ $opt_user_says_list = 1;
334
+ }
335
+ elsif ($name eq "spoof" )
336
+ {
337
+ $opt_spoof = $val;
338
+ }
339
+ elsif ($name eq "timeout" )
340
+ {
341
+ $opt_timeout = $val;
342
+ }
343
+
344
+ # verbose=<ignored-value>
345
+ elsif ($name eq "verbose" )
346
+ {
347
+ $opt_verbose = 1;
348
+ }
349
+ }
350
+ }
351
+