auser-poolparty 0.1.2 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (199) hide show
  1. data/History.txt +22 -0
  2. data/License.txt +20 -0
  3. data/README.txt +52 -0
  4. data/Rakefile +4 -109
  5. data/bin/cloud +31 -0
  6. data/bin/cloud-add-keypair +23 -0
  7. data/bin/cloud-configure +35 -0
  8. data/bin/cloud-contract +27 -0
  9. data/bin/cloud-expand +27 -0
  10. data/bin/cloud-list +32 -0
  11. data/bin/cloud-maintain +36 -0
  12. data/bin/cloud-provision +30 -0
  13. data/bin/cloud-reconfigure +24 -0
  14. data/bin/cloud-ssh +18 -0
  15. data/bin/cloud-start +29 -0
  16. data/bin/pool +23 -75
  17. data/bin/pool-console +12 -0
  18. data/bin/pool-describe +9 -0
  19. data/bin/pool-list +28 -0
  20. data/bin/pool-provision +34 -0
  21. data/bin/pool-spec +17 -0
  22. data/bin/pool-start +32 -0
  23. data/examples/basic.rb +20 -0
  24. data/examples/plugin_without_plugin_directory.rb +13 -0
  25. data/examples/poolparty.rb +12 -0
  26. data/examples/with_apache_plugin.rb +22 -0
  27. data/generators/poolspec/USAGE +5 -0
  28. data/generators/poolspec/poolspec_generator.rb +65 -0
  29. data/generators/poolspec/templates/pool_spec_template.erb +9 -0
  30. data/lib/erlang/eb_server.erl +27 -0
  31. data/lib/poolparty.rb +40 -116
  32. data/lib/poolparty/base_packages/haproxy.rb +41 -0
  33. data/lib/poolparty/base_packages/heartbeat.rb +43 -0
  34. data/lib/poolparty/base_packages/poolparty.rb +18 -0
  35. data/lib/poolparty/base_packages/ruby.rb +27 -0
  36. data/lib/poolparty/core/array.rb +24 -0
  37. data/lib/{core → poolparty/core}/exception.rb +0 -0
  38. data/lib/{core → poolparty/core}/float.rb +0 -0
  39. data/lib/poolparty/core/hash.rb +29 -0
  40. data/lib/poolparty/core/kernel.rb +34 -0
  41. data/lib/{core → poolparty/core}/module.rb +18 -0
  42. data/lib/poolparty/core/my_open_struct.rb +18 -0
  43. data/lib/poolparty/core/object.rb +54 -0
  44. data/lib/poolparty/core/proc.rb +2 -0
  45. data/lib/poolparty/core/string.rb +72 -0
  46. data/lib/poolparty/core/symbol.rb +8 -0
  47. data/lib/{core → poolparty/core}/time.rb +15 -0
  48. data/lib/poolparty/exceptions/RemoteException.rb +12 -0
  49. data/lib/poolparty/exceptions/ResourceException.rb +7 -0
  50. data/lib/poolparty/exceptions/RuntimeException.rb +7 -0
  51. data/lib/poolparty/exceptions/SpecException.rb +7 -0
  52. data/lib/poolparty/exceptions/TemplateNotFound.rb +7 -0
  53. data/lib/poolparty/helpers/binary.rb +30 -0
  54. data/lib/poolparty/helpers/console.rb +30 -0
  55. data/lib/poolparty/helpers/display.rb +25 -0
  56. data/lib/poolparty/helpers/optioner.rb +61 -0
  57. data/lib/poolparty/helpers/provisioner_base.rb +226 -0
  58. data/lib/poolparty/helpers/provisioners/master.rb +120 -0
  59. data/lib/poolparty/helpers/provisioners/slave.rb +52 -0
  60. data/lib/poolparty/modules/cloud_resourcer.rb +72 -0
  61. data/lib/poolparty/modules/configurable.rb +34 -0
  62. data/lib/poolparty/modules/definable_resource.rb +59 -0
  63. data/lib/poolparty/modules/file_writer.rb +55 -0
  64. data/lib/poolparty/modules/method_missing_sugar.rb +17 -0
  65. data/lib/poolparty/modules/output.rb +13 -0
  66. data/lib/poolparty/modules/pretty_printer.rb +38 -0
  67. data/lib/{core/string.rb → poolparty/modules/s3_string.rb} +5 -29
  68. data/lib/{modules → poolparty/modules}/safe_instance.rb +0 -0
  69. data/lib/poolparty/monitors/base_monitor.rb +16 -0
  70. data/lib/poolparty/net/remote.rb +35 -0
  71. data/lib/poolparty/net/remote_bases/ec2.rb +145 -0
  72. data/lib/poolparty/net/remote_instance.rb +68 -0
  73. data/lib/poolparty/net/remoter.rb +209 -0
  74. data/lib/poolparty/net/remoter_base.rb +117 -0
  75. data/lib/poolparty/plugins/gem_package.rb +39 -0
  76. data/lib/poolparty/plugins/line.rb +76 -0
  77. data/lib/poolparty/plugins/svn.rb +48 -0
  78. data/lib/poolparty/pool/base.rb +74 -0
  79. data/lib/poolparty/pool/cloud.rb +132 -0
  80. data/lib/poolparty/pool/custom_resource.rb +61 -0
  81. data/lib/poolparty/pool/loggable.rb +29 -0
  82. data/lib/poolparty/pool/plugin.rb +42 -0
  83. data/lib/poolparty/pool/plugin_model.rb +48 -0
  84. data/lib/poolparty/pool/pool.rb +55 -0
  85. data/lib/poolparty/pool/resource.rb +235 -0
  86. data/lib/poolparty/pool/resources/class_package.rb +60 -0
  87. data/lib/poolparty/pool/resources/cron.rb +14 -0
  88. data/lib/poolparty/pool/resources/directory.rb +23 -0
  89. data/lib/poolparty/pool/resources/exec.rb +26 -0
  90. data/lib/poolparty/pool/resources/file.rb +23 -0
  91. data/lib/poolparty/pool/resources/gem.rb +14 -0
  92. data/lib/poolparty/pool/resources/host.rb +14 -0
  93. data/lib/poolparty/pool/resources/package.rb +14 -0
  94. data/lib/poolparty/pool/resources/remote_file.rb +20 -0
  95. data/lib/poolparty/pool/resources/service.rb +21 -0
  96. data/lib/poolparty/pool/resources/sshkey.rb +19 -0
  97. data/lib/poolparty/pool/resources/variable.rb +27 -0
  98. data/lib/poolparty/pool/script.rb +21 -0
  99. data/{config/heartbeat_authkeys.conf → lib/poolparty/templates/authkeys} +0 -0
  100. data/lib/poolparty/templates/cib.xml +1 -0
  101. data/lib/poolparty/templates/fileserver.conf +4 -0
  102. data/{config/heartbeat.conf → lib/poolparty/templates/ha.cf} +3 -1
  103. data/{config → lib/poolparty/templates}/haproxy.conf +13 -6
  104. data/lib/poolparty/templates/namespaceauth.conf +19 -0
  105. data/lib/poolparty/templates/puppet.conf +13 -0
  106. data/lib/poolparty/version.rb +9 -0
  107. data/lib/poolpartycl.rb +3 -0
  108. data/script/destroy +14 -0
  109. data/script/generate +14 -0
  110. data/script/txt2html +82 -0
  111. data/{lib/poolparty/tasks → tasks}/cloud.rake +1 -1
  112. data/tasks/deployment.rake +34 -0
  113. data/tasks/development.rake +78 -0
  114. data/{lib/poolparty/tasks → tasks}/ec2.rake +1 -1
  115. data/tasks/environment.rake +7 -0
  116. data/{lib/poolparty/tasks → tasks}/instance.rake +0 -0
  117. data/{lib/poolparty/tasks → tasks}/server.rake +0 -0
  118. data/tasks/spec.rake +17 -0
  119. data/tasks/website.rake +17 -0
  120. metadata +154 -249
  121. data/CHANGELOG +0 -23
  122. data/LICENSE +0 -22
  123. data/README +0 -139
  124. data/assets/clouds.png +0 -0
  125. data/bin/instance +0 -68
  126. data/bin/poolnotify +0 -34
  127. data/config/cloud_master_takeover +0 -17
  128. data/config/create_proxy_ami.sh +0 -582
  129. data/config/installers/ubuntu_install.sh +0 -77
  130. data/config/monit.conf +0 -9
  131. data/config/monit/haproxy.monit.conf +0 -8
  132. data/config/monit/nginx.monit.conf +0 -0
  133. data/config/nginx.conf +0 -24
  134. data/config/reconfigure_instances_script.sh +0 -37
  135. data/config/sample-config.yml +0 -23
  136. data/config/scp_instances_script.sh +0 -12
  137. data/lib/core/array.rb +0 -16
  138. data/lib/core/hash.rb +0 -11
  139. data/lib/core/kernel.rb +0 -12
  140. data/lib/core/object.rb +0 -21
  141. data/lib/core/proc.rb +0 -15
  142. data/lib/helpers/plugin_spec_helper.rb +0 -58
  143. data/lib/modules/callback.rb +0 -133
  144. data/lib/modules/ec2_wrapper.rb +0 -108
  145. data/lib/modules/file_writer.rb +0 -38
  146. data/lib/modules/sprinkle_overrides.rb +0 -27
  147. data/lib/modules/vlad_override.rb +0 -83
  148. data/lib/poolparty/application.rb +0 -199
  149. data/lib/poolparty/init.rb +0 -6
  150. data/lib/poolparty/master.rb +0 -492
  151. data/lib/poolparty/monitors.rb +0 -11
  152. data/lib/poolparty/monitors/cpu.rb +0 -23
  153. data/lib/poolparty/monitors/memory.rb +0 -33
  154. data/lib/poolparty/monitors/web.rb +0 -29
  155. data/lib/poolparty/optioner.rb +0 -20
  156. data/lib/poolparty/plugin.rb +0 -78
  157. data/lib/poolparty/provider.rb +0 -104
  158. data/lib/poolparty/provider/essential.rb +0 -6
  159. data/lib/poolparty/provider/git.rb +0 -8
  160. data/lib/poolparty/provider/haproxy.rb +0 -9
  161. data/lib/poolparty/provider/heartbeat.rb +0 -6
  162. data/lib/poolparty/provider/rsync.rb +0 -8
  163. data/lib/poolparty/provider/ruby.rb +0 -65
  164. data/lib/poolparty/provider/s3fuse.rb +0 -22
  165. data/lib/poolparty/remote_instance.rb +0 -250
  166. data/lib/poolparty/remoter.rb +0 -171
  167. data/lib/poolparty/remoting.rb +0 -137
  168. data/lib/poolparty/scheduler.rb +0 -93
  169. data/lib/poolparty/tasks.rb +0 -47
  170. data/lib/poolparty/tasks/development.rake +0 -78
  171. data/lib/poolparty/tasks/plugins.rake +0 -30
  172. data/lib/poolparty/thread_pool.rb +0 -94
  173. data/lib/s3/s3_object_store_folders.rb +0 -44
  174. data/poolparty.gemspec +0 -71
  175. data/spec/files/describe_response +0 -37
  176. data/spec/files/multi_describe_response +0 -69
  177. data/spec/files/remote_desc_response +0 -37
  178. data/spec/helpers/ec2_mock.rb +0 -57
  179. data/spec/lib/core/core_spec.rb +0 -26
  180. data/spec/lib/core/kernel_spec.rb +0 -24
  181. data/spec/lib/core/string_spec.rb +0 -28
  182. data/spec/lib/modules/callback_spec.rb +0 -213
  183. data/spec/lib/modules/file_writer_spec.rb +0 -74
  184. data/spec/lib/poolparty/application_spec.rb +0 -135
  185. data/spec/lib/poolparty/ec2_wrapper_spec.rb +0 -110
  186. data/spec/lib/poolparty/master_spec.rb +0 -479
  187. data/spec/lib/poolparty/optioner_spec.rb +0 -34
  188. data/spec/lib/poolparty/plugin_spec.rb +0 -115
  189. data/spec/lib/poolparty/poolparty_spec.rb +0 -60
  190. data/spec/lib/poolparty/provider_spec.rb +0 -74
  191. data/spec/lib/poolparty/remote_instance_spec.rb +0 -178
  192. data/spec/lib/poolparty/remoter_spec.rb +0 -72
  193. data/spec/lib/poolparty/remoting_spec.rb +0 -148
  194. data/spec/lib/poolparty/scheduler_spec.rb +0 -70
  195. data/spec/monitors/cpu_monitor_spec.rb +0 -39
  196. data/spec/monitors/memory_spec.rb +0 -51
  197. data/spec/monitors/misc_monitor_spec.rb +0 -51
  198. data/spec/monitors/web_spec.rb +0 -40
  199. data/spec/spec_helper.rb +0 -53
data/CHANGELOG DELETED
@@ -1,23 +0,0 @@
1
- v0.1.2 * Added development tasks for easy setup
2
- v0.1.1 * Updated Scheduler to include ThreadPool for threaded safety
3
- v0.1.0 * Added poolnotify
4
- * Updating gem on github
5
- v0.0.9 * Changed configuration style to rsync all files across every instance
6
- * Moved configuration back to a configure scrip
7
- * Added in vlad configuration
8
- * Added plugin ability to install custom software
9
- * Updated configuration style
10
- * Added cloud_list to pool
11
- * Changed listing of the clouds through pool
12
- v0.0.8 * Added plugin_manager
13
- * Moved remoting to rake remote task (from vlad)
14
- * Changed configuration from instance-based to cloud-based
15
- v0.0.7 * Updated source
16
- v0.0.6 * Plugin support
17
- * Cleaned up base
18
- * Extensible monitoring
19
- v0.0.5 Initial launched release
20
- v0.0.4 Rewrite before release - with haproxy, heartbeat, hosts and s3fuse
21
- v0.0.3 Rewrite - Cleanup
22
- v0.0.2 Rewrite - with web-proxy methods
23
- v0.0.1 Initial idea
data/LICENSE DELETED
@@ -1,22 +0,0 @@
1
- Copyright (c) 2008 <Ari Lerner>
2
-
3
- Permission is hereby granted, free of charge, to any person
4
- obtaining a copy of this software and associated documentation
5
- files (the "Software"), to deal in the Software without
6
- restriction, including without limitation the rights to use,
7
- copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- copies of the Software, and to permit persons to whom the
9
- Software is furnished to do so, subject to the following
10
- conditions:
11
-
12
- The above copyright notice and this permission notice shall be
13
- included in all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
- OTHER DEALINGS IN THE SOFTWARE.
data/README DELETED
@@ -1,139 +0,0 @@
1
- = poolparty
2
-
3
- http://poolpartyrb.com
4
- Ari Lerner
5
- CitrusByte
6
- http://blog.citrusbyte.com
7
-
8
- == DESCRIPTION:
9
-
10
- poolparty (http://poolpartyrb.com), Ari Lerner (http://blog.xnot.org, http://blog.citrusbyte.com) - poolparty is a framework for maintaining and running auto-scalable applications on Amazon's EC2 cloud. Run entire applications using the EC2 cluster and the unlimited S3 disk. More details to be listed at http://poolpartyrb.com.
11
-
12
- == Basics
13
-
14
- poolparty is written with the intention of being as application-agnostic as possible. It installs only the basic required software to glue the cloud together on the instances as listed below.
15
-
16
- poolparty is easily configuration. In fact, it makes little assumptions about your development environment and allows several options on how to begin configuring the cloud.
17
-
18
- = Development setup
19
-
20
- === IN THE ENVIRONMENT
21
-
22
- There are 5 values that poolparty reads from the environment, you can set these basic environment variables and leave the rest to the poolparty defaults. Those values are:
23
-
24
- ENV["ACCESS_KEY"] => AWS access key
25
- ENV["SECRET_ACCESS_KEY"] => AWS secret access key
26
- ENV["CONFIG_FILE"] => Location of your config yaml file (optional)
27
- ENV["EC2_HOME"] => EC2 home directory (defaults to ~/.ec2)
28
- ENV["KEYPAIR_NAME"] => The keypair used to launch instances
29
-
30
- The structure assumed for the keypair is EC2_HOME/id_rsa-<keypairname>
31
-
32
- === IN A CONFIG FILE
33
-
34
- poolparty assumes your config directory is set in config/config.yml. However, you can set this in your environment variables and it will read the config file from the environment variable
35
-
36
- === WITH A RAKE TASK
37
-
38
- poolparty comes with a rake task that can setup your environment for you. Set the environment variables above and run
39
-
40
- rake dev:setup
41
-
42
- This will write a .<KEYPAIR_NAME>_pool_keys into your home directory. Then you can just run
43
-
44
- source ~/.<KEYPAIR_NAME>_pool_keys
45
-
46
- and your environment will be all setup for you everytime you want to work on the cloud
47
-
48
- = Basics
49
-
50
- poolparty can work in two ways to load balance it's traffic. It can either do server-side or client-side load-balancing. Since every instance load balances itself, you can either set the client to grab an instance and send it to that using client-side load balancing (with a js library). Alternatively, you can set the master in dns and reference it when referring to the application.
51
-
52
- Since poolparty makes no assumptions as to what you will be hosting on the application, the world is your oyster when running a cloud. You can set each instance to register with a dynDNS service so that your application has multiple points of entry and can run load-balanced on the fly.
53
-
54
- Every instance will auto-mount the s3 bucket set in the config file (if it is set up) into the /data folder of the instance. This gives each instance access to the same data regardless of the instance. It uses s3fuse and caching through s3fuse in the /tmp directory to work as fast as possible on the local instances.
55
-
56
- The instances all are loaded with the following software:
57
-
58
- * Haproxy - The basic load balancing software
59
- * Heartbeat - The failover software
60
- * S3Fuse - The mounting software for the s3 bucket
61
- * Monit - The maintainer of the services to maintain services
62
-
63
- When an instance is started or brought down, the master is responsible for reloading every instance with the new data on each instance. If the master goes down, the next in succession will take over as the master (using heartbeat) and it will reconfigure the cloud, setting itself as the master and take over the maintenance of the cloud.
64
-
65
- Your cloud is never guaranteed to be maintained, but with more than 1 instance unless you have more than 1 instance up
66
-
67
- Each instance has a /etc/hosts file that has each node listed as the node name listed in the cloud:list (rake task).
68
-
69
- = CloudSpeak - Communicating to your cloud(s)
70
- Binaries!
71
- Included in poolparty are two binaries to communicate back with your clouds. Those are:
72
-
73
- * pool - operate on your pool. This includes list, start, stop maintain, restart. Check the help with pool -h
74
- * instance - operate on a specific instance. This allos you to ssh, scp, reload, install as well. Check the help with: instance -h
75
-
76
- The cloud can be maintained entirely through rake tasks, although there are a few front-ends being developed (one in cocoa).
77
-
78
- It is simple to include these tasks in your Rakefile. Just add the following lines:
79
-
80
- require "poolparty"
81
- PoolParty.include_cloud_tasks # or PoolParty.tasks or PoolParty.include_tasks
82
-
83
- All the cloud rake tasks are in the cloud namespace and can be viewed with:
84
-
85
- rake -T cloud
86
-
87
- The instance rake tasks are in the instance namespace and can be listed with:
88
-
89
- rake -T instance
90
-
91
- For more help, check http://poolpartyrb.com
92
-
93
- == REQUIREMENTS:
94
-
95
- * aws/s3
96
- * aska
97
- * EC2
98
-
99
- == INSTALL:
100
-
101
- gem install auser-poolparty
102
-
103
- == ROADMAP
104
-
105
- v0.1.4 - Add documentation
106
- v0.1.5 - Add AMI bundling tasks
107
-
108
- == THANKS
109
-
110
- Ron Evans, http://deadprogrammersociety.blogspot.com/ for his enthusiasm
111
- Tim Goh, http://citrusbyte.com for sanity checks and thoughts
112
- PJ Cabrera, http://pjtrix.com for excitement, thoughts and contribution
113
- Blake Mizerany, http://sinatrarb.com/, for his support and ideas
114
- Nicolás 'Foca' Sanguinetti, http://nicolassanguinetti.info/
115
-
116
- == LICENSE:
117
-
118
- (The MIT License)
119
-
120
- Copyright (c) 2008 Ari Lerner. CitrusByte
121
-
122
- Permission is hereby granted, free of charge, to any person obtaining
123
- a copy of this software and associated documentation files (the
124
- 'Software'), to deal in the Software without restriction, including
125
- without limitation the rights to use, copy, modify, merge, publish,
126
- distribute, sublicense, and/or sell copies of the Software, and to
127
- permit persons to whom the Software is furnished to do so, subject to
128
- the following conditions:
129
-
130
- The above copyright notice and this permission notice shall be
131
- included in all copies or substantial portions of the Software.
132
-
133
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
134
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
135
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
136
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
137
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
138
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
139
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/assets/clouds.png DELETED
Binary file
data/bin/instance DELETED
@@ -1,68 +0,0 @@
1
- #!/usr/bin/ruby
2
- require 'rubygems'
3
- require 'optparse'
4
- require 'poolparty'
5
- require "fileutils"
6
-
7
- # Set defaults
8
- commandables = %w(ssh cmd scp restart start stop install start_maintain stop_maintain)
9
- options = PoolParty.options(:optsparse =>
10
- { :banner => <<-EOU
11
- Usage: instance [OPTIONS] { #{commandables.join(" | ")} }
12
- -----------------------------------------------------------------
13
- EOU
14
- })
15
-
16
- PoolParty.load_app
17
-
18
- master = PoolParty::Master.new
19
- list = PoolParty::Optioner.parse(ARGV.dup, %w(-v --verbose))
20
- num = list.reject {|a| commandables.include?(a) }.pop
21
-
22
- instance = master.get_node( num || 0 )
23
-
24
- unless instance
25
- puts "Cloud is not running"
26
- exit
27
- end
28
-
29
- list.each do |cmd|
30
- case cmd
31
- when "ssh"
32
- PoolParty.message "Ssh'ing into #{instance.ip}"
33
- instance.ssh
34
- when "cmd"
35
- PoolParty.message "Executing #{instance_options[:cmd]} on #{instance.ip}"
36
- instance.ssh list.shift
37
- when "scp"
38
- list.shift
39
- src, dest = list.shift, (list.shift || "~")
40
- PoolParty.message "Scp'ing #{src} to #{dest}"
41
- instance.scp src, (dest || "~")
42
- when "restart"
43
- PoolParty.message "Restarting services"
44
- instance.restart_with_monit
45
- when "start"
46
- PoolParty.message "Starting services"
47
- instance.start_with_monit
48
- when "stop"
49
- PoolParty.message "Stopping services"
50
- instance.stop_with_monit
51
- when "install"
52
- PoolParty.message "Installing services"
53
- instance.install
54
- when "start_maintain"
55
- PoolParty.message "Running heartbeat failover service"
56
- pid = Master.run_thread_loop(:daemonize => true) do
57
- instance.become_master if instance.is_not_master_and_master_is_not_running?
58
- end
59
- File.open(Application.maintain_pid_path) {|f| f.write(pid)}
60
- when "stop_maintain"
61
- PoolParty.message "Stopping heartbeat failover service"
62
- pid = open(Application.maintain_pid_path).read
63
- `kill -9 #{pid}`
64
- FileUtils.rm Application.maintain_pid_path # Check this
65
- else
66
- puts master.list
67
- end
68
- end
data/bin/poolnotify DELETED
@@ -1,34 +0,0 @@
1
- #!/usr/bin/ruby
2
- require 'rubygems'
3
- $:.unshift(File.join(File.dirname(__FILE__), "lib"))
4
- require 'poolparty'
5
-
6
- def notify(mess)
7
- `/usr/local/bin/growlnotify --image #{File.expand_path(File.dirname(__FILE__))}/../assets/clouds.png -m "Your #{PoolParty.options.keypair} cloud #{mess}"`
8
- end
9
-
10
- @master = PoolParty::Master.new
11
-
12
- @@size = @master.nodes.size
13
-
14
- notify("has #{@@size} nodes")
15
-
16
- blk = lambda {
17
- loop do
18
- sz = @master.nodes.size
19
- PoolParty.message "Your cloud has #{sz} nodes from #{@@size} nodes"
20
- unless @@size == sz
21
- if @@size > sz
22
- notify("shrank to #{sz} nodes")
23
- else
24
- notify("grew to #{sz} nodes")
25
- end
26
- @@size = sz
27
- end
28
-
29
- @master.reset!
30
- wait 20.seconds
31
- end
32
- }
33
-
34
- PoolParty::Application.production? ? daemonize(&blk) : blk.call
@@ -1,17 +0,0 @@
1
- #!/bin/bash
2
- # This is responsible for checking to make sure that the master instance is up and running
3
- # and if it is not, take over the master role and reconfigure the cloud
4
- case $1 in
5
- start)
6
- instance start_maintain
7
- ;;
8
- stop)
9
- instance stop_maintain
10
- ;;
11
- status)
12
- ps aux | awk '{print $2}' | grep `cat /var/run/pool_maintain.pid`
13
- ;;
14
- *)
15
- echo "Syntax incorrect. You need one of {start|stop|status}"
16
- ;;
17
- esac
@@ -1,582 +0,0 @@
1
- #!/bin/bash
2
- #
3
- # ec2ubuntu-build-ami
4
- #
5
- # This script builds, bundles, and uploads an Ubuntu base install AMI
6
- # for Amazon EC2. This can be run on any of the following Fedora Core
7
- # AMIs, depending on what type of new Ubuntu AMI you wish to create:
8
- #
9
- # 32-bit, 2.6.21 kernel: ami-f51aff9c
10
- # 32-bit, 2.6.16 kernel: ami-20b65349
11
- # 64-bit, 2.6.16 kernel: ami-36ff1a5f
12
- # 64-bit, 2.6.21 kernel: ami-f21aff9b
13
- #
14
- # Command line options:
15
- #
16
- # --bucket NAME - REQUIRED
17
- # --prefix PREFIX - Defaults to a reasonable manifest name.
18
- # --user ID - Defaults to $AWS_USER_ID
19
- # --access-key ID - Defaults to $AWS_access_key
20
- # --secret-key ID - Defaults to $AWS_SECRET_access_key
21
- # --private-key PATH - Defaults to $EC2_PRIVATE_KEY
22
- # --cert PATH - Defaults to $EC2_CERT
23
- # --release VERSION - One of: 6.06 6.10 7.04 7.10 8.04
24
- # --codename NAME - Only needed if release not recognized.
25
- # --timezone ZONE - Defaults to US/Pacific
26
- # --lang LANG - Defaults to en_US.UTF-8
27
- # --size MB - Root partition size in megabytes
28
- # --package NAME - Additional Ubuntu package to install
29
- # --script FILE - External script to run before bundle
30
- # --desktop nx - Takes longer and makes AMI much bigger
31
- #
32
- # It is ok to specify multiple --package and --script options.
33
- # You can also use "--desktop yes" to install the desktop packages
34
- # without the NX software.
35
- #
36
- # For Amazon EC2 AMIs built using this script:
37
- #
38
- # http://alestic.com
39
- #
40
- # For updated versions of this script:
41
- #
42
- # http://code.google.com/p/ec2ubuntu/
43
- #
44
- # For general Ubuntu on EC2 support:
45
- #
46
- # http://groups.google.com/group/ec2ubuntu
47
- #
48
- # History:
49
- #
50
- # 2008-05-16 Eric Hammond <ehammond@thinksome.com>
51
- # - Run the instance user-data if it looks like a script (starts with #!)
52
- # - Wait for the network (DHCP) to come up before grabbing instance data.
53
- #
54
- # 2008-05-14 Eric Hammond <ehammond@thinksome.com>
55
- # - Create new ssh host keys on first boot.
56
- # - Disable apparmor as we don't have the kernel module installed yet.
57
- # - Don't claim every AMI was built by Eric Hammond in /etc/motd
58
- # - Create /tmp earlier in the boot process to avoid warnings.
59
- # - Implemented following suggestions from Hans Omli:
60
- # - Disable useless CMOS hwclock at boot to avoid error and save seconds.
61
- # - Avoid grep warning about missing authorized_keys file on first boot.
62
- #
63
- # 2008-05-13 Thomas Shealy <thomas.shealy@gmail.com>
64
- # - Add --retry to ec2-upload-bundle.
65
- #
66
- # 2008-05-12 Thomas Shealy <thomas.shealy@gmail.com>
67
- # - Support 64-bit desktop AMIs.
68
- # - Upgrade to NX 3.2.
69
- #
70
- # 2008-04-29 Eric Hammond <ehammond@thinksome.com>
71
- # - Support command line options with reasonable defaults.
72
- # - Support building Ubuntu 8.04 Hardy Heron.
73
- #
74
- # 2008-04-22 Vincent Desjardins
75
- # - Add a variable to override the default size of the image created
76
- # - Add a optional call to an external script before bundling the AMI
77
- #
78
- # 2008-04-19 Eric Hammond <ehammond@thinksome.com>
79
- # - Support 2.6.21 kernel with 64-bit builds.
80
- #
81
- # 2008-04-18 Eric Hammond <ehammond@thinksome.com>
82
- # - Fix performance problem with 2.6.21 initrd (with killall nash-hotplug).
83
- #
84
- # 2008-04-11 Eric Hammond <ehammond@thinksome.com>
85
- # - Install kernel modules for both 2.6.16-xenU and 2.6.21.7-2.fc8xen
86
- #
87
- # 2008-04-05 Eric Hammond <ehammond@thinksome.com>
88
- # - Add support for desktop build with NoMachine NX Free.
89
- #
90
- # 2008-04-03 Eric Hammond <ehammond@thinksome.com>
91
- # - Upgrade to latest AMI tools 1.3-20041 20071010 (obviates several patches)
92
- # - Add new Ubuntu patches for new version of AMI tools
93
- # - Switch from "uname -i" to "uname -m" to enable building on Ubuntu 64-bit
94
- # - Merge Dapper, Edgy, Feisty, Gutsy, Hardy scripts (Hardy doesn't work yet)
95
- #
96
- # 2008-03-13 Eric Hammond <ehammond@thinksome.com>
97
- # - Prevent apt-get from running newly installed daemons
98
- #
99
- # 2008-03-09 Eric Hammond <ehammond@thinksome.com>
100
- # - Upgrade to kernel modules 2.6.16.60
101
- # - Upgrade fuse kernel module to 2.7.3
102
- # - Upgrade to latest AMI tools 1.3-19365 (obviates one patch)
103
- #
104
- # 2008-02-05 Eric Hammond <ehammond@thinksome.com>
105
- # - Patch AMI tools to work with new Ruby 1.8.6
106
- #
107
- # 2008-02-03 Eric Hammond <ehammond@thinksome.com>
108
- # - Install rsync without lutimes support (as it's not in the EC2 kernel)
109
- #
110
- # 2008-01-17 Eric Hammond <ehammond@thinksome.com>
111
- # - Upgrade to debootstrap 1.0.8
112
- #
113
- # 2007-12-25 Eric Hammond <ehammond@thinksome.com>
114
- # - Install fuse kernel module (32-bit)
115
- # - Upgrade to debootstrap 1.0.7
116
- #
117
- # 2007-12-02 Eric Hammond <ehammond@thinksome.com>
118
- # - Use architecture "amd64" instead of "i386" for debootstrap on 64-bit
119
- # - Add ia32-libs compatability package for 64-bit
120
- #
121
- # 2007-12-01 Eric Hammond <ehammond@thinksome.com>
122
- # - Add support for building on 64-bit kernel (large, extra large instances)
123
- #
124
- # 2007-11-23 Eric Hammond <ehammond@thinksome.com>
125
- # - ssh credentials retrieved from instance parameters or ephemeral storage.
126
- # - Patch ec2-unbundle to work on Ubuntu
127
- # - Also add locale to /etc/default/locale
128
- #
129
- # 2007-11-22 Eric Hammond <ehammond@thinksome.com>
130
- # - Upgrade Ubuntu AMI tools patch to match new AMI tools source.
131
- # - Install ca-certificates to better support ec2-upload-bundle per:
132
- # http://developer.amazonwebservices.com/connect/thread.jspa?threadID=16543&tstart=0
133
- # - ec2-bundle-vol excludes /etc/udev/rules.d/70-persistent-net.rules
134
- # so that the network works on a rebundled instance, per:
135
- # http://developer.amazonwebservices.com/connect/message.jspa?messageID=70873
136
- #
137
- # 2007-11-18 Eric Hammond <ehammond@thinksome.com>
138
- # - Original put together based on code, tricks, and fixes from many
139
- # others.
140
- #
141
-
142
- export AWS_USER_ID=161964561164
143
- export AWS_access_key=1XCTNEK1CC5BQPA3EE02
144
- export ACCESS_KEY=$AWS_access_key
145
- export AWS_SECRET_ACCESS_KEY=Q2qJHP0S2iOKikn9glB+KZcF/aYf4huS/GdHvqEZ
146
- export SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY
147
- export bucket=a-instances
148
- export prefix=ubuntu-proxy-base-$(date +%Y%m%d)
149
-
150
- packages="ubuntu-standard openssh-server rsync ruby openssl curl ca-certificates libopenssl-ruby1.8 patch alien"
151
-
152
- while [ $# -gt 0 ]; do
153
- case $1 in
154
- --release) release=$2; shift 2 ;;
155
- --codename) codename=$2; shift 2 ;;
156
- --tag) tag=$2; shift 2 ;;
157
- --bucket) bucket=$2; shift 2 ;;
158
- --prefix) prefix=$2; shift 2 ;;
159
- --user) AWS_USER_ID=$2; shift 2 ;;
160
- --access-key) AWS_access_key=$2; shift 2 ;;
161
- --secret-key) AWS_SECRET_ACCESS_KEY=$2; shift 2 ;;
162
- --private-key) EC2_PRIVATE_KEY=$2; shift 2 ;;
163
- --cert) EC2_CERT=$2; shift 2 ;;
164
- --timezone) timezone=$2; shift 2 ;;
165
- --lang) LANG=$2; shift 2 ;;
166
- --size) size=$2; shift 2 ;;
167
- --script) scripts="$scripts $2"; shift 2 ;;
168
- --package) packages="$packages $2"; shift 2 ;;
169
- --desktop) desktop=$2
170
- packages="$packages ubuntu-desktop user-setup"
171
- shift 2 ;;
172
- *) echo "$0: Unrecognized option: $1" >&2; exit 1;
173
- esac
174
- done
175
-
176
- true ${release:=8.04}
177
- if [ "$codename" = "" ]; then
178
- case $release in
179
- 6.06) codename=dapper ;;
180
- 6.10) codename=edgy ;;
181
- 7.04) codename=feisty ;;
182
- 7.10) codename=gutsy ;;
183
- 8.04) codename=hardy ;;
184
- *) echo "$0: Unrecognized release: $release" >&2; exit 1;
185
- esac
186
- fi
187
-
188
- # Required and default parameters
189
- true ${AWS_USER_ID:?} ${AWS_access_key:?} ${AWS_SECRET_ACCESS_KEY:?} \
190
- ${bucket:?} \
191
- ${EC2_CERT:=$(echo /mnt/cert-*.pem)} \
192
- ${EC2_PRIVATE_KEY:=$(echo /mnt/pk-*.pem)} \
193
- ${timezone:=US/Pacific} ${LANG:=en_US.UTF-8} \
194
- ${tag:=custom} ${prefix:=ubuntu-$release-$codename-$tag-$(date +%Y%m%d)}
195
-
196
- if [ "$codename" == "dapper" ]; then
197
- true ${size:=3072}
198
- else
199
- true ${size:=4096}
200
- fi
201
-
202
- echo Building AMI for Ubuntu $release $codename
203
- echo timezone: $timezone
204
- echo LANG: $LANG
205
- echo Image size: ${size} MB
206
- echo Uploading to: $bucket/$prefix
207
-
208
- set -e
209
- set -x
210
-
211
- # The good stuff starts here.
212
-
213
- mkdir -p /mnt/build
214
- cd /mnt/build
215
- mkdir -p ubuntu
216
-
217
- if which apt-get >/dev/null 2>/dev/null; then
218
- # Ubuntu / Debian
219
- apt-get install -y binutils
220
- else
221
- # Fedora Core / Red Hat / CentOS
222
- yum install -y binutils
223
- fi
224
-
225
- if [ $(uname -m) = 'x86_64' ]; then
226
- modules="http://s3.amazonaws.com/ec2-downloads/ec2-modules-2.6.16.33-xenU-x86_64.tgz http://alestic-downloads.s3.amazonaws.com/ec2-kernel-modules-2.6.21.x86_64.tar.gz"
227
- bundlearch="x86_64"
228
- bsarch="amd64"
229
- export notlongext="64"
230
- else
231
- # http://groups.google.com/group/ec2ubuntu/web/compiling-kernel-modules-from-source-for-amazon-ec2
232
- modules="http://alestic-downloads.s3.amazonaws.com/ec2-kernel-modules-2.6.16-xenU.tgz http://alestic-downloads.s3.amazonaws.com/ec2-kernel-modules-2.6.21.7-2.fc8xen.tar.gz"
233
- bundlearch="i386"
234
- bsarch="i386"
235
- export notlongext=""
236
- fi
237
-
238
- if [ "$desktop" = "nx" ]; then
239
- notlongext="$notlongext-desktop"
240
- fi
241
-
242
- # Don't launch daemons on apt-get install
243
- mkdir -p ubuntu/usr/sbin/
244
- cat << EOF > ubuntu/usr/sbin/policy-rc.d
245
- #!/bin/sh
246
- exit 101
247
- EOF
248
- chmod 755 ubuntu/usr/sbin/policy-rc.d
249
-
250
- # Bootstrap Ubuntu
251
- BSURL=http://archive.ubuntu.com/ubuntu/pool/main/d/debootstrap
252
- BSVER=debootstrap_1.0.8
253
- BSDIR=debootstrap
254
- curl -s $BSURL/$BSVER.tar.gz |
255
- tar xz
256
- curl -s $BSURL/${BSVER}_all.deb > /tmp/${BSVER}_all.deb
257
- ar p /tmp/${BSVER}_all.deb data.tar.gz |
258
- tar xvzOf - ./usr/share/debootstrap/devices.tar.gz > $BSDIR/devices.tar.gz
259
- if [ "$codename" = "hardy" ]; then
260
- ln -s gutsy $BSDIR/scripts/ubuntu/$codename
261
- fi
262
- ln -s ubuntu/$codename $BSDIR/scripts/$codename
263
- export DEBOOTSTRAP_DIR=$BSDIR
264
- perl -pi.bak -e 'print "set -x\n" if $.==2' $BSDIR/debootstrap
265
- $BSDIR/debootstrap --arch $bsarch $codename ubuntu http://us.archive.ubuntu.com/ubuntu
266
-
267
- chroot ubuntu mount -t proc none /proc
268
- chroot ubuntu mkdir -p /dev/pts
269
- chroot ubuntu mount -t devpts none /dev/pts
270
- chroot ubuntu mknod --mode 666 /dev/ptmx c 5 2
271
-
272
- chroot ubuntu apt-get -f install -y
273
-
274
- # Change these to your locale and timezone
275
- chroot ubuntu localedef -i en_US -c -f UTF-8 en_US.UTF-8
276
- echo $timezone >ubuntu/etc/timezone
277
- echo "LANG=\"$LANG\"" >ubuntu/etc/default/locale
278
- /bin/cp -f ubuntu/usr/share/zoneinfo/$timezone ubuntu/etc/localtime
279
-
280
- # Basic sources.list
281
- mv ubuntu/etc/apt/sources.list ubuntu/etc/apt/sources.list.orig || true
282
- cat <<EOF >ubuntu/etc/apt/sources.list
283
- deb http://us.archive.ubuntu.com/ubuntu $codename main restricted universe multiverse
284
- deb-src http://us.archive.ubuntu.com/ubuntu $codename main restricted universe multiverse
285
-
286
- deb http://us.archive.ubuntu.com/ubuntu $codename-updates main restricted universe multiverse
287
- deb-src http://us.archive.ubuntu.com/ubuntu $codename-updates main restricted universe multiverse
288
-
289
- deb http://security.ubuntu.com/ubuntu $codename-security main restricted universe multiverse
290
- deb-src http://security.ubuntu.com/ubuntu $codename-security main restricted universe multiverse
291
- EOF
292
-
293
- # Update package list
294
- chroot ubuntu apt-get update
295
-
296
- # Architecture/release specific instructions
297
- if [ "$bundlearch" = "i386" ]; then
298
- if [ "$codename" = "edgy" -o \
299
- "$codename" = "feisty" -o \
300
- "$codename" = "gutsy" ]; then
301
- chroot ubuntu apt-get install -y libc6-xen
302
- fi
303
- if [ "$codename" = "hardy" ]; then
304
- # tls seems to have a bug on hardy: perl -e 'glob("xxx*")'
305
- mv ubuntu/lib/tls ubuntu/lib/tls.disabled
306
- fi
307
- else
308
- chroot ubuntu apt-get install -y ia32-libs
309
- fi
310
-
311
- # MAKEDEV is expected in /dev by some packages.
312
- ln -s /sbin/MAKEDEV ubuntu/dev/MAKEDEV
313
-
314
- # Upgrade/install packages
315
- chroot ubuntu apt-get -y upgrade
316
- chroot ubuntu apt-get install -y $packages
317
-
318
- # EC2 kernel modules
319
- for module in $modules; do
320
- curl -s $module | tar xzC ubuntu
321
- done
322
- chroot ubuntu depmod -a
323
-
324
- # Xen expects a single tty1
325
- /bin/rm -f ubuntu/etc/event.d/tty[2-6]
326
-
327
- # Security
328
- chroot ubuntu shadowconfig on
329
- chroot ubuntu passwd -d root
330
-
331
- # Basic networking
332
- cat <<'EOF' >ubuntu/etc/network/interfaces
333
- auto lo
334
- iface lo inet loopback
335
-
336
- auto eth0
337
- iface eth0 inet dhcp
338
- EOF
339
-
340
- cat <<'EOF' >ubuntu/etc/hosts
341
- 127.0.0.1 localhost.localdomain localhost
342
-
343
- # The following lines are desirable for IPv6 capable hosts
344
- ::1 ip6-localhost ip6-loopback
345
- fe00::0 ip6-localnet
346
- ff00::0 ip6-mcastprefix
347
- ff02::1 ip6-allnodes
348
- ff02::2 ip6-allrouters
349
- ff02::3 ip6-allhosts
350
- EOF
351
-
352
- cat <<'EOF' >>ubuntu/etc/ssh/sshd_config
353
- UseDNS no
354
- EOF
355
-
356
- # Fedora 6/8 initrd starts nash-hotplug which uses 100% CPU and prevents
357
- # udev from starting, not to mention slowing down everything else.
358
- cat <<EOF >ubuntu/etc/init.d/ec2-killall-nash-hotplug
359
- #!/bin/sh
360
- /usr/bin/killall nash-hotplug
361
- EOF
362
- chmod 755 ubuntu/etc/init.d/ec2-killall-nash-hotplug
363
- ln -s ../init.d/ec2-killall-nash-hotplug ubuntu/etc/rcS.d/S00ec2-killall-nash-hotplug
364
-
365
- # motd
366
- cat <<EOF >ubuntu/etc/rc.local
367
- #!/bin/sh -e
368
-
369
- # Get ssh credentials from instance parameters or ephemeral storage.
370
- /usr/local/sbin/ec2-get-credentials
371
-
372
- # If instance user-data starts with "#!" then run it on first boot.
373
- /usr/local/sbin/ec2-run-user-data
374
- EOF
375
-
376
- # Script to run user-data if it looks like a script
377
- curl -s -o ubuntu/usr/local/sbin/ec2-run-user-data \
378
- http://ec2ubuntu.googlecode.com/svn/trunk/bin/ec2-run-user-data
379
- chmod 755 ubuntu/usr/local/sbin/ec2-run-user-data
380
-
381
- # ec2-get-credentials
382
- cat <<'EOF' >ubuntu/usr/local/sbin/ec2-get-credentials
383
- #!/bin/bash
384
- # Retrieve the ssh credentials and add to authorized_keys file.
385
- # Based on /usr/local/sbin/ec2-get-credentials from ami-20b65349
386
- public_key_url=http://169.254.169.254/1.0/meta-data/public-keys/0/openssh-key
387
- public_key_file=/tmp/openssh_id.pub
388
- public_key_ephemeral=/mnt/openssh_id.pub
389
- authorized_keys=/root/.ssh/authorized_keys
390
- test -d /root/.ssh || mkdir -p -m 700 /root/.ssh
391
- perl -MIO::Socket::INET -e '
392
- until(new IO::Socket::INET("169.254.169.254:80")){print"Waiting for network...\n";sleep 1}
393
- ' | logger -t "ec2"
394
- curl --retry 3 --silent --fail -o $public_key_file $public_key_url
395
- if [ $? -eq 0 -a -e $public_key_file ] ; then
396
- if ! grep -s -q -f $public_key_file $authorized_keys
397
- then
398
- cat $public_key_file >> $authorized_keys
399
- echo "New ssh key added to $authorized_keys from $public_key_url" |
400
- logger -t "ec2"
401
- fi
402
- chmod 600 $authorized_keys
403
- rm -f $public_key_file
404
- elif [ -e $public_key_ephemeral ] ; then
405
- if ! grep -s -q -f $public_key_ephemeral $authorized_keys
406
- then
407
- cat $public_key_ephemeral >> $authorized_keys
408
- echo "New ssh key added to $authorized_keys from $public_key_ephemeral" |
409
- logger -t "ec2"
410
- fi
411
- chmod 600 $authorized_keys
412
- chmod 600 $public_key_ephemeral
413
- fi
414
- EOF
415
- chmod 755 ubuntu/usr/local/sbin/ec2-get-credentials
416
-
417
- # Install and patch Amazon AMI tools
418
- curl -s http://s3.amazonaws.com/ec2-downloads/ec2-ami-tools.noarch.rpm \
419
- > ubuntu/tmp/ec2-ami-tools.noarch.rpm
420
- chroot ubuntu alien -i --scripts /tmp/ec2-ami-tools.noarch.rpm
421
-
422
- ln -s /usr/lib/site_ruby/aes ubuntu/usr/local/lib/site_ruby/1.8/aes
423
- ln -s /usr/lib/site_ruby/ec2 ubuntu/usr/local/lib/site_ruby/1.8/ec2
424
-
425
- chroot ubuntu patch -d /usr/lib/site_ruby/aes/amiutil <<'EOF'
426
- --- /usr/lib/site_ruby/aes/amiutil/http.rb.orig 2008-04-02 22:27:01.000000000 -0400
427
- +++ /usr/lib/site_ruby/aes/amiutil/http.rb 2008-04-02 22:28:05.000000000 -0400
428
- @@ -58,7 +58,7 @@
429
- tf.close(false)
430
-
431
- begin
432
- - cmd_line = "curl -f #{curl_arguments} #{url} 2> #{tf.path} | tee #{path} | openssl sha1; exit ${PIPESTATUS[0]}"
433
- + cmd_line = "/bin/bash -c 'curl -f #{curl_arguments} #{url} 2> #{tf.path} | tee #{path} | openssl sha1; exit ${PIPESTATUS[0]}'"
434
- calculated_digest = IO.popen( cmd_line ) { |io| io.readline.chomp }
435
-
436
- unless $?.exitstatus == 0
437
- --- /usr/lib/site_ruby/aes/amiutil/bundlevol.rb.orig 2008-04-03 00:57:26.000000000 -0400
438
- +++ /usr/lib/site_ruby/aes/amiutil/bundlevol.rb 2008-04-03 00:58:42.000000000 -0400
439
- @@ -148,6 +148,10 @@
440
- if image_file.index( volume ) == 0
441
- exclude << image_file
442
- end
443
- +
444
- + # UGLY HACK for Ubuntu: Don't save the MAC address as that prevents
445
- + # networking from working on rebundled AMIs
446
- + exclude << "/etc/udev/rules.d/70-persistent-net.rules"
447
-
448
- # If we are inheriting instance data but can't access it we want to fail early
449
- if p.inherit && !AES::AmiUtils::InstanceData.new.instance_data_accessible
450
- EOF
451
-
452
- chroot ubuntu patch -d /usr/lib/site_ruby/ec2/platform/base <<'EOF'
453
- --- /usr/lib/site_ruby/ec2/platform/base/pipeline.rb.orig 2008-04-02 19:41:54.000000000 -0700
454
- +++ /usr/lib/site_ruby/ec2/platform/base/pipeline.rb 2008-04-02 19:47:17.000000000 -0700
455
- @@ -105,7 +105,8 @@
456
- @results = []
457
- create_tempfiles
458
-
459
- - invocation = command
460
- + # UGLY HACK for Ubuntu: Assumes no single quotes (') in command.
461
- + invocation = "/bin/bash -c '" + command + "'"
462
-
463
- # Execute the pipeline invocation
464
- STDERR.puts("Pipeline.execute: command = [#{invocation}]") if verbose
465
- EOF
466
-
467
- cat <<EOF >ubuntu/etc/init.d/ec2-mkdir-tmp
468
- #!/bin/sh
469
- # Create /tmp if missing (as it's nice to bundle without it).
470
- test -d /tmp || mkdir /tmp
471
- chmod 01777 /tmp
472
- EOF
473
- chmod +x ubuntu/etc/init.d/ec2-mkdir-tmp
474
- ln -s ../init.d/ec2-mkdir-tmp ubuntu/etc/rcS.d/S36ec2-mkdir-tmp
475
-
476
-
477
- # Generate new ssh host keys on first boot
478
- # Otherwise everybody knows our secret host key which makes it non-secret
479
- cat <<EOF >ubuntu/etc/init.d/ec2-ssh-host-key-gen
480
- #!/bin/sh
481
- rm -f /etc/ssh/ssh_host_*_key*
482
- ssh-keygen -f /etc/ssh/ssh_host_rsa_key -t rsa -C 'host' -N '' | logger -t \$0
483
- ssh-keygen -f /etc/ssh/ssh_host_dsa_key -t dsa -C 'host' -N '' | logger -t \$0
484
- rm -f /etc/rcS.d/S50ec2-ssh-host-key-gen
485
- EOF
486
- chmod +x ubuntu/etc/init.d/ec2-ssh-host-key-gen
487
- ln -s ../init.d/ec2-ssh-host-key-gen ubuntu/etc/rcS.d/S50ec2-ssh-host-key-gen
488
-
489
- # Inside Xen, CMOS clock is irrelevant, so save seconds at boot
490
- /bin/rm -f ubuntu/etc/rc?.d/*hwclock*
491
-
492
- # We're missing the apparmor kernel module for now so avoid boot warnings
493
- /bin/rm -f ubuntu/etc/rc?.d/*apparmor
494
-
495
- # Release-specific
496
- if [ "$codename" = "gutsy" ]; then
497
- # Install a copy of rsync with no lutimes support, as the Amazon EC2
498
- # kernel does not support this newer feature to change symlink timestamps.
499
- curl -s -o ubuntu/tmp/rsync_2.6.9-5ubuntu1_$bsarch.deb \
500
- https://level22.s3.amazonaws.com/20080203-rsync-no-lutimes/rsync_2.6.9-5ubuntu1_$bsarch.deb
501
- chroot ubuntu dpkg --install /tmp/rsync_2.6.9-5ubuntu1_$bsarch.deb
502
- fi
503
-
504
- # Are we installing the desktop with NoMachine NX?
505
- if [ "$desktop" = "nx" ]; then
506
- if [ "$bundlearch" = "i386" ]; then
507
- nxclient_pkg="nxclient_3.2.0-9_i386.deb"
508
- nxnode_pkg="nxnode_3.2.0-5_i386.deb"
509
- nxserver_pkg="nxserver_3.2.0-7_i386.deb"
510
- else
511
- nxclient_pkg="nxclient_3.2.0-9_x86_64.deb"
512
- nxnode_pkg="nxnode_3.2.0-5_x86_64.deb"
513
- nxserver_pkg="nxserver_3.2.0-7_x86_64.deb"
514
- fi
515
-
516
- curl -o ubuntu/tmp/$nxclient_pkg \
517
- http://64.34.161.181/download/3.2.0/Linux/$nxclient_pkg
518
- curl -o ubuntu/tmp/$nxnode_pkg \
519
- http://64.34.161.181/download/3.2.0/Linux/$nxnode_pkg
520
- curl -o ubuntu/tmp/$nxserver_pkg \
521
- http://64.34.161.181/download/3.2.0/Linux/FE/$nxserver_pkg
522
-
523
- chroot ubuntu dpkg -i /tmp/$nxclient_pkg
524
- chroot ubuntu dpkg -i /tmp/$nxnode_pkg
525
- chroot ubuntu dpkg -i /tmp/$nxserver_pkg
526
- fi
527
-
528
- # Call external script if requested
529
- for script in $scripts; do
530
- if [ -f "$script" ]; then
531
- if [ -e "$script" ]; then
532
- "$script"
533
- else
534
- /bin/bash "$script"
535
- fi
536
- fi
537
- done
538
-
539
- ############################## CUSTOM INSTALLS ####################################
540
- # BUILD AMI HERE
541
- ###################################################################################
542
-
543
- # cleanup
544
- if [ "$codename" != "dapper" ]; then
545
- chroot ubuntu apt-get -y autoremove --purge patch alien
546
- fi
547
- chroot ubuntu apt-get clean
548
- rm -f ubuntu/usr/sbin/policy-rc.d
549
- rm -rf ubuntu/tmp/* ubuntu/root/.bash_history
550
-
551
- # Bundle & upload to S3
552
- cp $EC2_PRIVATE_KEY ubuntu/tmp/pk.pem
553
- cp $EC2_CERT ubuntu/tmp/cert.pem
554
-
555
- chroot ubuntu ec2-bundle-vol \
556
- -r $bundlearch \
557
- -d /tmp \
558
- -p $prefix \
559
- -u $AWS_USER_ID \
560
- -k /tmp/pk.pem \
561
- -c /tmp/cert.pem \
562
- -s $size \
563
- -e /tmp
564
-
565
- ec2-upload-bundle \
566
- --retry \
567
- -b $bucket \
568
- -m ubuntu/tmp/$prefix.manifest.xml \
569
- -a $AWS_access_key \
570
- -s $AWS_SECRET_ACCESS_KEY
571
-
572
- umount ubuntu/dev/pts
573
- umount ubuntu/proc
574
-
575
- set +x
576
-
577
- cat <<EOF
578
-
579
- Now you might want to run this command:
580
- ec2-register $bucket/$prefix.manifest.xml
581
-
582
- EOF