auser-poolparty 0.2.85 → 0.2.88

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest.txt CHANGED
@@ -6,6 +6,7 @@ PostInstall.txt
6
6
  README.txt
7
7
  Rakefile
8
8
  bin/cloud
9
+ bin/cloud-add-access
9
10
  bin/cloud-add-keypair
10
11
  bin/cloud-configure
11
12
  bin/cloud-contract
data/PostInstall.txt CHANGED
@@ -1,4 +1,4 @@
1
- Get ready to jump in the pool, you just installed PoolParty! (Updated at 01:19 12/15/08)
1
+ Get ready to jump in the pool, you just installed PoolParty! (Updated at 02:30 12/16/08)
2
2
 
3
3
  To get started, run the generator:
4
4
 
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
3
+ require "poolparty"
4
+ require "poolpartycl"
5
+
6
+ o = PoolParty::Optioner.new(ARGV, {:extra_help => "\nUsage: cloud [options] add-access file\n\n"}) do |opts, optioner|
7
+ opts.on('-n name', '--name name', 'Listing for cloud name') { |c| optioner.cloudname c }
8
+ opts.on('-i num', '--id num', 'Instance num to ssh (default: 0)') { |i| optioner.num i }
9
+ end
10
+
11
+ @instance_number = (o.num || 0 ).to_i
12
+
13
+ if o.unflagged_args.length == 1
14
+ @file = o.unflagged_args.pop
15
+ else
16
+ puts header("Error")
17
+ puts "usage: \nUsage: cloud [options] add-access file\n\n"
18
+ end
19
+
20
+ o.loaded_clouds.each do |cloud|
21
+
22
+ with_cloud(cloud, {:rsa_file=>@file }) do
23
+ # Add access here
24
+ cmd = "cat #{rsa_file} | #{ssh_command(master)} 'cat >> ~/.ssh/authorized_keys'"
25
+ vputs "Running #{cmd}"
26
+ Kernel.system cmd
27
+ end
28
+
29
+ end
@@ -18,7 +18,7 @@ o.loaded_clouds.each do |cloud|
18
18
  boot_file = "#{Messenger.append_dir}/pm_client_rel-0.1"
19
19
 
20
20
  Kernel.system "cd #{Messenger.append_dir} && rake build_boot_scripts" unless ::File.file?("#{boot_file}.boot") || testing
21
- command = Messenger.erl_command("client", "-setcookie #{generate_unique_cookie_string} -boot #{boot_file} #{noshell ? "" : "-detached -heart -noshell"}", 7049, 7050)
21
+ command = Messenger.erl_command("client", "-boot #{boot_file} #{noshell ? "" : "-detached -heart -noshell"}", 7049, 7050)
22
22
  vputs "Running #{command}"
23
23
 
24
24
  Kernel.system "export HOME=/root && #{command}" unless testing
@@ -16,7 +16,7 @@ o.loaded_clouds.each do |cloud|
16
16
 
17
17
  boot_file = "#{Messenger.append_dir}/pm_master_rel-0.1"
18
18
  Kernel.system ". /etc/profile && server-build-messenger" unless ::File.file?("#{boot_file}.boot") || testing
19
- command = Messenger.erl_command("master", "-setcookie #{generate_unique_cookie_string} -boot #{boot_file} #{noshell ? "" : "-noshell -detached -heart"}")
19
+ command = Messenger.erl_command("master", "-boot #{boot_file} #{noshell ? "" : "-noshell -detached -heart"}")
20
20
  vputs "Running #{command}"
21
21
 
22
22
  Kernel.system "export HOME=/root && #{command}" unless testing
@@ -22,7 +22,7 @@ o.loaded_clouds.each do |cloud|
22
22
  boot_file = "#{Messenger.append_dir}/pm_node_rel-0.1"
23
23
 
24
24
  Kernel.system ". /etc/profile && server-build-messenger" unless ::File.file?("#{boot_file}.boot") || testing
25
- command = Messenger.erl_command(hostname, "-setcookie #{generate_unique_cookie_string} -boot #{boot_file} #{noshell ? "" : "-noshell -detached -heart"} -- #{available_monitors.join(" ")}")
25
+ command = Messenger.erl_command(hostname, "-boot #{boot_file} #{noshell ? "" : "-noshell -detached -heart"} -- #{available_monitors.join(" ")}")
26
26
  vputs "Running #{command}"
27
27
 
28
28
  Kernel.system "export HOME=/root && #{command}" unless testing
@@ -5,9 +5,11 @@ module PoolParty
5
5
  def enable
6
6
  execute_on_master do
7
7
  has_package({:name => "haproxy"})
8
-
8
+
9
+ # Service is required
10
+ has_service(:name => "haproxy", :ensures => "running")
9
11
  # Restart sysklogd after we update the haproxy.log
10
- has_service(:name => "sysklogd")
12
+ has_service(:name => "sysklogd", :notify => get_service("haproxy"))
11
13
 
12
14
  # Template variables
13
15
  has_variable(:name => "name_haproxy", :value => "#{cloud.name}")
@@ -22,9 +24,6 @@ module PoolParty
22
24
  has_line_in_file("ENABLED=1", "/etc/default/haproxy")
23
25
  has_line_in_file("SYSLOGD=\"-r\"", "/etc/default/syslogd")
24
26
  has_line_in_file("local0.* /var/log/haproxy.log", "/etc/syslog.conf", {:notify => get_service("sysklogd")})
25
-
26
- # Service is required
27
- has_service(:name => "haproxy", :ensures => "running")
28
27
 
29
28
  # has_exec(:name => "reloadhaproxy", :command => "/etc/init.d/haproxy reload", :requires => get_package("haproxy"))
30
29
 
@@ -27,7 +27,13 @@ module PoolParty
27
27
 
28
28
  has_gempackage(:name => "sexp_processor", :download_url => "http://rubyforge.org/frs/download.php/45589/sexp_processor-3.0.0.gem")
29
29
 
30
- has_gempackage(:name => "capistrano", :requires => get_gempackage("net-ssh"))
30
+ # Capistrano
31
+ has_gempackage(:name => "net-ssh", :download_url => "http://rubyforge.org/frs/download.php/48041/net-ssh-2.0.6.gem")
32
+ has_gempackage(:name => "net-sftp", :download_url => "http://rubyforge.org/frs/download.php/37669/net-sftp-2.0.1.gem")
33
+ has_gempackage(:name => "net-scp", :download_url => "http://rubyforge.org/frs/download.php/37664/net-scp-1.0.1.gem")
34
+ has_gempackage(:name => "net-ssh-gateway", :download_url => "http://rubyforge.org/frs/download.php/36389/net-ssh-gateway-1.0.0.gem")
35
+ has_gempackage(:name => "highline", :download_url => "http://rubyforge.org/frs/download.php/46328/highline-1.5.0.gem")
36
+ has_gempackage(:name => "capistrano", :requires => get_gempackage("highline"))
31
37
 
32
38
  has_gempackage(:name => "ParseTree", :download_url => "http://rubyforge.org/frs/download.php/45600/ParseTree-3.0.1.gem", :requires => [get_gempackage("sexp_processor"), get_gempackage("ZenTest")])
33
39
 
@@ -5,14 +5,6 @@ module PoolParty
5
5
  raise unless cld
6
6
  @cloud = cld
7
7
  end
8
-
9
- def set_poolparty_roles
10
- returning Array.new do |arr|
11
- arr << "role 'master.#{@cloud.name}'.to_sym, '#{@cloud.master.ip}'"
12
- arr << "role :master, '#{@cloud.master.ip}'"
13
- arr << "role :slaves, '#{@cloud.nonmaster_nonterminated_instances.map{|a| a.ip}.join('", "')}'" if @cloud.nonmaster_nonterminated_instances.size > 0
14
- end.join("\n")
15
- end
16
-
8
+
17
9
  end
18
10
  end
@@ -40,4 +40,7 @@ class Hash
40
40
  each {|k,v| m[k] = v.to_os }
41
41
  MyOpenStruct.new(m)
42
42
  end
43
+ def method_missing(sym, *args, &block)
44
+ key?(sym) ? fetch(sym) : super
45
+ end
43
46
  end
@@ -19,7 +19,7 @@ module PoolParty
19
19
  end
20
20
 
21
21
  def available_bases
22
- puts Remote.available_bases
22
+ remote_bases
23
23
  end
24
24
 
25
25
  def header(str="")
@@ -39,7 +39,7 @@ module PoolParty
39
39
 
40
40
  def setup_dev
41
41
  unless ::File.exists?("#{full_keypair_basename_path}.pub")
42
- cmd = "scp #{ssh_array.join(" ")} #{Base.user}@#{master.ip}:.ssh/authorized_keys #{full_keypair_basename_path}.pub"
42
+ cmd = "scp #{scp_array.join(" ")} #{Base.user}@#{master.ip}:.ssh/authorized_keys #{full_keypair_basename_path}.pub"
43
43
  vputs "Running #{cmd}"
44
44
  Kernel.system(cmd)
45
45
  end
@@ -4,7 +4,7 @@ module PoolParty
4
4
  class CpuMonitor < BaseMonitor
5
5
 
6
6
  def run
7
- stdin, stdout, stderr = Open3.popen3('uptime')
7
+ stdout = %x[uptime]
8
8
  stdout.split(/\s+/)[-1].to_f rescue 0.0
9
9
  end
10
10
 
@@ -16,7 +16,7 @@ module PoolParty
16
16
  end
17
17
  # TODO: Fix cookie setting
18
18
  def self.erl_command(hostname, extra="", min_ports=7000, max_ports=7050)
19
- command_line_opts = "-pa #{append_dir}/ebin -kernel inet_dist_listen_min #{min_ports} inet_dist_listen_max #{max_ports} -sname #{hostname}"
19
+ command_line_opts = "-cookie -pa #{append_dir}/ebin -kernel inet_dist_listen_min #{min_ports} inet_dist_listen_max #{max_ports} -sname #{hostname}"
20
20
 
21
21
  "erl #{command_line_opts} #{extra}"
22
22
  end
@@ -9,6 +9,20 @@ require "#{::File.dirname(__FILE__)}/ec2/ec2_response_object"
9
9
 
10
10
  begin
11
11
  require 'EC2'
12
+ rescue LoadError
13
+ puts <<-EOM
14
+ Error: In order to use ec2, you need to install the amazon-ec2 gem
15
+
16
+ Ec2 is the default remoter base for PoolParty. If you intend on using
17
+ a different remoter base, specify it with:
18
+
19
+ using :remoter_name
20
+
21
+ in your config file, otherwise, to continue install amazon-ec2 with
22
+
23
+ gem install amazon-ec2
24
+ EOM
25
+ end
12
26
 
13
27
  class String
14
28
  def convert_from_ec2_to_ip
@@ -141,26 +155,20 @@ begin
141
155
 
142
156
  # Hook
143
157
  #TODO#: Change this so they match with the cap tasks
144
- def custom_install_tasks_for(o)
145
- arr = if has_cert_and_key?
146
- [
147
- # "mv #{::File.basename(pub_key)} #{Base.base_config_directory}/ssl/public_keys/#{o.name}.pem",
148
- # "mv #{::File.basename(private_key)} #{Base.base_config_directory}/ssl/private_keys/#{o.name}.pem"
149
- ]
150
- else
151
- []
152
- end
153
- arr << [
154
- "# ec2 installation tasks",
155
- "# Set hostname",
158
+ def custom_install_tasks_for(o)
159
+ [
156
160
  # "if [ -z $(grep -v '#' /etc/hosts | grep '#{o.name}') ]; then echo \"$(curl http://169.254.169.254/latest/meta-data/public-ipv4) #{o.name}\" >> /etc/hosts; fi",
157
161
  "if [ -z \"$(grep -v '#' /etc/hosts | grep '#{o.name}')\" ]; then echo '127.0.0.1 #{o.name}' >> /etc/hosts; fi",
158
162
  "hostname #{o.name}",
159
- "echo #{o.name} > /etc/hostname",
163
+ "echo #{o.name} > /etc/hostname"
164
+ ]
165
+ end
166
+
167
+ def after_install_tasks_for(o)
168
+ [
160
169
  "cd /var/poolparty && wget http://rubyforge.org/frs/download.php/43666/amazon-ec2-0.3.1.gem -O amazon-ec2.gem 2>&1",
161
- "/usr/bin/gem install -y --no-ri --no-rdoc amazon-ec2.gem 2>&1",
170
+ "/usr/bin/gem install --no-ri --no-rdoc amazon-ec2.gem 2>&1"
162
171
  ]
163
- []
164
172
  end
165
173
 
166
174
  def custom_configure_tasks_for(o)
@@ -173,18 +181,4 @@ begin
173
181
  end
174
182
  end
175
183
  register_remote_base :Ec2
176
- end
177
- rescue LoadError
178
- puts <<-EOM
179
- Error: In order to use ec2, you need to install the amazon-ec2 gem
180
-
181
- Ec2 is the default remoter base for PoolParty. If you intend on using
182
- a different remoter base, specify it with:
183
-
184
- using :remoter_name
185
-
186
- in your config file, otherwise, to continue install amazon-ec2 with
187
-
188
- gem install amazon-ec2
189
- EOM
190
- end
184
+ end
@@ -15,7 +15,7 @@ module PoolParty
15
15
  end
16
16
  def run_command_on_command(cmd="ls -l", remote_instance=nil)
17
17
  vputs "Running #{cmd} on #{remote_instance.name == %x[hostname].chomp ? "self (master)" : "#{remote_instance.name}"}"
18
- remote_instance.name == %x[hostname].chomp ? %x[#{cmd}] : "#{ssh_command(remote_instance)} '#{cmd}'"
18
+ (remote_instance.nil? || remote_instance.name == %x[hostname].chomp) ? %x[#{cmd}] : "#{ssh_command(remote_instance)} '#{cmd}'"
19
19
  end
20
20
  def ssh_command(remote_instance)
21
21
  "#{ssh_string} #{remote_instance.ip}"
@@ -32,6 +32,9 @@ module PoolParty
32
32
  def ssh_array
33
33
  ["-o StrictHostKeyChecking=no", "-l #{Base.user}", '-i "'+full_keypair_path+'"']
34
34
  end
35
+ def scp_array
36
+ ["-o StrictHostKeyChecking=no", '-i "'+full_keypair_path+'"']
37
+ end
35
38
  def rsync_command
36
39
  "rsync -azP --exclude cache -e '#{ssh_string} -l #{Base.user}'"
37
40
  end
@@ -144,6 +147,7 @@ module PoolParty
144
147
  def when_no_pending_instances(&block)
145
148
  reset!
146
149
  if list_of_pending_instances.size == 0
150
+ vputs ""
147
151
  block.call if block
148
152
  else
149
153
  vprint "."
@@ -303,7 +307,7 @@ module PoolParty
303
307
  # Take the rsync command and execute it on the system
304
308
  # if there is an instance given
305
309
  def run_command_on(cmd, instance=nil)
306
- Kernel.system "#{run_command_on_command(cmd, instance)}" if instance
310
+ Kernel.system "#{run_command_on_command(cmd, instance)}"
307
311
  end
308
312
 
309
313
  # Ssh into the instance given
@@ -20,7 +20,8 @@ module PoolParty
20
20
 
21
21
  def register_remote_base(*args)
22
22
  args.each do |arg|
23
- (remote_bases << "#{arg}".downcase.to_sym)
23
+ base_name = "#{arg}".downcase.to_sym
24
+ (remote_bases << base_name) unless remote_bases.include?(base_name)
24
25
  end
25
26
  end
26
27
 
@@ -85,7 +86,7 @@ module PoolParty
85
86
  end
86
87
  # Get instance by number
87
88
  def get_instance_by_number(i=0, list = remote_instances_list)
88
- name = (i.zero? ? "master" : "node#{i}")
89
+ name = ((i.nil? || i.zero?) ? "master" : "node#{i}")
89
90
  list.select {|i| i.name == name }.first
90
91
  end
91
92
  # A callback before the configuration task takes place
@@ -99,9 +100,10 @@ module PoolParty
99
100
  # List the instances for the current key pair, regardless of their states
100
101
  # If no keypair is passed, select them all
101
102
  def list_of_instances(keyp=nil)
102
- tmp_key = (keyp ? keyp : keypair).to_s
103
+ tmp_key = (keyp ? keyp : nil)
104
+
103
105
  unless @describe_instances
104
- tmpInstanceList = describe_instances.select {|a| a if tmp_key ? a[:keypair] == tmp_key : true }
106
+ tmpInstanceList = describe_instances.select {|a| a if (tmp_key.nil? || tmp_key.empty? ? true : a[:keypair] == tmp_key) }
105
107
  has_master = !tmpInstanceList.select {|a| a[:name] == "master" }.empty?
106
108
  if has_master
107
109
  @describe_instances = tmpInstanceList
@@ -134,7 +136,7 @@ module PoolParty
134
136
  @describe_instances = nil
135
137
  end
136
138
  def self.included(other)
137
- PoolParty.register_remote_base(self.class.to_s.downcase.to_sym)
139
+ # PoolParty.register_remote_base(self.class.to_s.downcase.to_sym)
138
140
  end
139
141
 
140
142
  # Callback after loaded
@@ -127,7 +127,7 @@ module PoolParty
127
127
  # talk to each other safely. This is based off the keypair
128
128
  # and the name of the cloud
129
129
  def generate_unique_cookie_string
130
- Digest::SHA256.hexdigest("#{full_keypair_name}#{name}")
130
+ Digest::SHA256.hexdigest("#{full_keypair_name}#{name}")[0..12]
131
131
  end
132
132
 
133
133
  # Build the new poolparty manifest
@@ -22,14 +22,14 @@ module PoolParty
22
22
  })
23
23
 
24
24
  has_exec(opts.merge({:name => "#{name}", :cwd =>"#{Base.remote_storage_path}"})) do
25
- command "gem install -y --no-ri --no-rdoc #{Base.remote_storage_path}/#{name}.gem"
25
+ command "gem install --no-ri --no-rdoc #{Base.remote_storage_path}/#{name}.gem"
26
26
  ifnot "gem list --local #{name} | grep #{name} #{"| grep #{version}" if version}"
27
27
  requires get_file("#{Base.remote_storage_path}/#{name}.gem")
28
28
  end
29
29
 
30
30
  else
31
31
  has_exec(opts.merge({:name => "#{name}", :cwd => "/tmp", :path => "/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/var/lib/gems/1.8/bin"})) do
32
- command "gem install -y --no-ri --no-rdoc #{"--version #{version}" if version} #{"--source #{source}" if source} #{name} <<heredoc
32
+ command "gem install --no-ri --no-rdoc #{"--version #{version}" if version} #{"--source #{source}" if source} #{name} <<heredoc
33
33
  1
34
34
  heredoc"
35
35
  ifnot "gem list --local #{name} | grep #{name} #{"| grep #{version}" if version}"
@@ -4,7 +4,6 @@ module PoolParty
4
4
  module Provisioner
5
5
  class Capistrano < ProvisionerBase
6
6
 
7
- include PoolParty::Capistrano
8
7
  include ::Capistrano::Configuration::Actions::Invocation
9
8
 
10
9
  def process_install!(testing=false)
@@ -31,33 +30,48 @@ module PoolParty
31
30
 
32
31
  def master_install_tasks
33
32
  [
34
- "master:provision_master"
35
- ].push([custom_install_tasks, master_configure_tasks]).flatten#.map {|a| a.to_sym }
33
+ "custom_install_tasks",
34
+ "master_provision_master_task",
35
+ "after_install_tasks",
36
+ "custom_configure_tasks",
37
+ "run_provisioner_twice",
38
+ "master_configure_master_task"
39
+ ]#.map {|a| a.to_sym }
36
40
  end
37
41
  def master_configure_tasks
38
42
  [
39
- "master:create_local_node_entry_for_puppet", "master:move_template_files", "master:setup_poolparty_base_structure",
40
- "master:move_provisioner_manifest", "run_provisioner"
41
- ].push(custom_configure_tasks).flatten#.map {|a| a.to_sym }
43
+ "master_configure_master_task"
44
+ ]#.map {|a| a.to_sym }
42
45
  end
43
46
 
44
47
  def slave_install_tasks
45
48
  [
46
- "slave:add_master_to_hosts_file", "slave:add_provisioner_configs", "setup_provisioner_config",
47
- "create_puppetrunner_command", "create_puppetrerun_command", "install_rubygems",
48
- "install_provisioner", "slave:stop_provisioner_daemon"
49
- ].push([custom_install_tasks, slave_configure_tasks]).flatten#.map {|a| a.to_sym }
49
+ "custom_install_tasks",
50
+ "slave_provision_slave_task",
51
+ "after_install_tasks",
52
+ "custom_configure_tasks",
53
+ "slave_configure_slave_task"
54
+ ]
50
55
  end
51
56
  def slave_configure_tasks
52
57
  [
53
- "run_provisioner"
54
- ].push(custom_configure_tasks).flatten#.map {|a| a.to_sym }
58
+ "custom_configure_tasks",
59
+ "slave_configure_slave_task"
60
+ ]#.flatten.map {|a| a.to_sym }
55
61
  end
56
62
  # Run tasks after the initialized
57
63
  def loaded
58
64
  create_config
59
65
  end
60
66
 
67
+ def set_poolparty_roles
68
+ returning Array.new do |arr|
69
+ arr << "role 'master.#{@cloud.name}'.to_sym, '#{@cloud.master.ip}'"
70
+ arr << "role :master, '#{@cloud.master.ip}'"
71
+ arr << "role :slaves, '#{@cloud.nonmaster_nonterminated_instances.map{|a| a.ip}.join('", "')}'" if @cloud.nonmaster_nonterminated_instances.size > 0
72
+ end.join("\n")
73
+ end
74
+
61
75
  # Create the config for capistrano
62
76
  # This is a dynamic capistrano configuration file
63
77
  def create_config
@@ -86,18 +100,31 @@ module PoolParty
86
100
  # Prerun
87
101
  def prerun_setup
88
102
  end
89
-
103
+
104
+ # In run_capistrano, we are going to run the entire capistrano process
105
+ # First,
90
106
  def run_capistrano(roles=[:master], meth=:install)
91
107
  prerun_setup
92
108
 
93
109
  commands = meth == :install ? install_tasks : configure_tasks
94
- name = "provisioner_#{meth}"
95
-
110
+ name = "#{roles.first}_provisioner_#{meth}"
111
+
96
112
  __define_task(name, roles) do
97
- commands.map {|command|
98
- task = find_task(command)
99
- task.options.merge!(:roles => roles)
100
- execute_task task
113
+ commands.map {|command|
114
+ task = find_task(command.to_sym)
115
+
116
+ if task
117
+ task.options.merge!(:roles => roles)
118
+ execute_task task
119
+ else
120
+ if provisioner.respond_to?(command.to_sym)
121
+ cmd = provisioner.send(command.to_sym)
122
+ cmd = cmd.join(" && ") if cmd.is_a?(Array)
123
+ run(cmd)
124
+ else
125
+ self.send(command.to_sym)
126
+ end
127
+ end
101
128
  }
102
129
  end
103
130
 
@@ -106,7 +133,7 @@ module PoolParty
106
133
  return true
107
134
  rescue ::Capistrano::CommandError => e
108
135
  return false unless verbose
109
- raise ProvisionerException.new("Error: #{e}")
136
+ puts "Error: #{e} " and raise ProvisionerException.new("Error: #{e}")
110
137
  end
111
138
  end
112
139
 
@@ -4,68 +4,74 @@
4
4
  Capistrano::Configuration.instance(:must_exist).load do
5
5
  # namespace(:base) do
6
6
  desc "Install rubygems"
7
- task :install_rubygems do
7
+ def install_rubygems
8
8
  run "#{installer_for} ruby rubygems"
9
9
  end
10
10
  desc "Setup for poolparty"
11
- task :setup_for_poolparty do
11
+ def setup_for_poolparty
12
12
  run "mkdir -p /etc/poolparty"
13
13
  end
14
14
  desc "Install provisioner"
15
- task :install_provisioner do
15
+ def install_provisioner
16
16
  run "#{installer_for} #{puppet_packages}"
17
17
  end
18
18
  desc "Create poolparty commands"
19
- task :create_poolparty_commands do
19
+ def create_poolparty_commands
20
20
  end
21
21
  desc "Create poolparty runner command"
22
- task :create_puppetrunner_command do
22
+ def create_puppetrunner_command
23
23
  run <<-EOR
24
24
  cp #{remote_storage_path}/templates/puppetrunner /usr/bin/puppetrunner &&
25
25
  chmod +x /usr/bin/puppetrunner
26
26
  EOR
27
27
  end
28
28
  desc "Create poolparty rerun command"
29
- task :create_puppetrerun_command do
29
+ def create_puppetrerun_command
30
30
  run <<-EOR
31
31
  cp #{remote_storage_path}/templates/puppetrerun /usr/bin/puppetrerun &&
32
32
  chmod +x /usr/bin/puppetrerun
33
33
  EOR
34
34
  end
35
35
  desc "Add the proper configs for provisioner"
36
- task :add_provisioner_configs do
36
+ def add_provisioner_configs
37
37
  run "cp #{remote_storage_path}/namespaceauth.conf /etc/puppet/namespaceauth.conf"
38
38
  end
39
39
  desc "Setup config file for provisioner"
40
- task :setup_provisioner_config do
40
+ def setup_provisioner_config
41
41
  run "mv #{remote_storage_path}/puppet.conf /etc/puppet/puppet.conf"
42
42
  end
43
+ desc "Run the provisioner twice (usually on install)"
44
+ def run_provisioner_twice
45
+ run "/usr/sbin/puppetd --test --server master 2>1 > /dev/null && /usr/sbin/puppetd --onetime --daemonize --logdest syslog --server master"
46
+ end
43
47
  desc "Run the provisioner"
44
- task :run_provisioner do
48
+ def run_provisioner
45
49
  run "/usr/sbin/puppetd --onetime --daemonize --logdest syslog --server master"
46
50
  end
47
51
  desc "Rerun the provisioner"
48
- task :rerun_provisioner do
52
+ def rerun_provisioner
49
53
  run "/usr/bin/puppetrerun"
50
54
  end
51
55
  desc "Remove the certs"
52
- task :remove_certs do
56
+ def remove_certs
53
57
  run "rm -rf /etc/puppet/ssl"
54
58
  end
55
59
  desc "Update rubygems"
56
- task :update_rubygems do
60
+ def update_rubygems
57
61
  run "/usr/bin/gem update --system 2>1 > /dev/null && /usr/bin/gem update --system"
58
62
  end
59
63
  desc "Fix rubygems"
60
- task :fix_rubygems do
64
+ def fix_rubygems
61
65
  # echo '#{open(::File.join(template_directory, "gem")).read}' > /usr/bin/gem &&
66
+ # cp #{remote_storage_path}/gem /usr/bin/gem
62
67
  run <<-EOR
68
+ if gem -v; then echo "gem is working"; else cp #{remote_storage_path}/gem /usr/bin/gem; fi &&
63
69
  /usr/bin/gem update --system 2>&1 > /dev/null;/usr/bin/gem update --system &&
64
- cp -f #{remote_storage_path}/gem /usr/bin/gem
70
+ if gem -v; then echo "gem is working"; else cp #{remote_storage_path}/gem /usr/bin/gem; fi
65
71
  EOR
66
72
  end
67
73
  desc "Upgrade system"
68
- task :upgrade_system do
74
+ def upgrade_system
69
75
  str = case os
70
76
  when :ubuntu
71
77
  "
@@ -78,15 +84,15 @@ aptitude update -y
78
84
  run str
79
85
  end
80
86
  desc "Upgrade rubygems"
81
- task :upgrade_rubygems do
87
+ def upgrade_rubygems
82
88
 
83
89
  end
84
90
  desc "Make log directory"
85
- task :make_log_directory do
91
+ def make_log_directory
86
92
  run "mkdir -p /var/log/poolparty"
87
93
  end
88
94
  desc "Create ssl storage directories for poolparty"
89
- task :create_poolparty_ssl_store do
95
+ def create_poolparty_ssl_store
90
96
  run <<-EOR
91
97
  mkdir -p #{poolparty_config_directory}/ssl/private_keys &&
92
98
  mkdir -p #{poolparty_config_directory}/ssl/certs &&
@@ -94,11 +100,44 @@ aptitude update -y
94
100
  EOR
95
101
  end
96
102
  desc "Add erlang cookie"
97
- task :write_erlang_cookie do
103
+ def write_erlang_cookie
98
104
  run <<-EOR
99
105
  mv #{remote_storage_path}/cookie ~/.erlang.cookie &&
100
106
  chmod 400 ~/.erlang.cookie
101
107
  EOR
102
108
  end
109
+ desc "Setup basic poolparty structure"
110
+ def setup_basic_poolparty_structure
111
+ run <<-EOR
112
+ echo "Creating basic structure for poolparty" &&
113
+ mkdir -p /etc/puppet/manifests/nodes &&
114
+ mkdir -p /etc/puppet/manifests/classes &&
115
+ echo "import 'nodes/*.pp'" > /etc/puppet/manifests/site.pp &&
116
+ echo "import 'classes/*.pp'" >> /etc/puppet/manifests/site.pp
117
+ EOR
118
+ end
119
+ desc "Setup shareable file system for provisioner"
120
+ def setup_provisioner_filestore
121
+ run <<-EOR
122
+ echo '[files]' > /etc/puppet/fileserver.conf &&
123
+ echo ' path #{remote_storage_path}' >> /etc/puppet/fileserver.conf &&
124
+ echo ' allow *' >> /etc/puppet/fileserver.conf &&
125
+ mkdir -p /var/poolparty/facts &&
126
+ mkdir -p /var/poolparty/files &&
127
+ mkdir -p #{base_config_directory}
128
+ EOR
129
+ end
130
+ desc "Setup autosigning for provisioner"
131
+ def setup_provisioner_autosigning
132
+ run "echo \"*\" > /etc/puppet/autosign.conf"
133
+ end
134
+ desc "Setup poolparty structure"
135
+ def setup_poolparty_base_structure
136
+ run <<-EOR
137
+ cp #{remote_storage_path}/#{key_file_locations.first} "#{base_config_directory}/.ppkeys" &&
138
+ mv #{remote_storage_path}/#{default_specfile_name} #{base_config_directory}/
139
+ EOR
140
+ end
141
+
103
142
  # end
104
143
  end
@@ -1,8 +1,8 @@
1
1
  # Cloud tasks
2
2
  Capistrano::Configuration.instance(:must_exist).load do
3
- namespace(:master) do
3
+ # namespace(:master) do
4
4
  desc "Provision master"
5
- task :provision_master do
5
+ def master_provision_master_task
6
6
  upgrade_system
7
7
  set_hostname_to_master
8
8
  create_local_hosts_entry
@@ -23,54 +23,24 @@ Capistrano::Configuration.instance(:must_exist).load do
23
23
  write_erlang_cookie
24
24
  end
25
25
  desc "Configure master"
26
- task :configure_master do
27
- master:move_provisioner_manifest
28
- master:move_template_files
29
- master:setup_poolparty_base_structure
26
+ def master_configure_master_task
27
+ create_local_node_entry_for_puppet
28
+ move_provisioner_manifest
29
+ move_template_files
30
+ setup_poolparty_base_structure
31
+ ensure_provisioner_is_running
30
32
  run_provisioner
31
33
  end
32
34
  desc "Set hostname to master"
33
- task :set_hostname_to_master do
35
+ def set_hostname_to_master
34
36
  run "hostname master"
35
37
  end
36
38
  desc "Add host entry into the master instance"
37
- task :create_local_hosts_entry do
39
+ def create_local_hosts_entry
38
40
  run "if [ -z \"$(grep -v '#' /etc/hosts | grep 'puppet')\" ]; then echo '#{cloud.master.ip} master puppet localhost' >> /etc/hosts; fi"
39
41
  end
40
- desc "Setup basic poolparty structure"
41
- task :setup_basic_poolparty_structure do
42
- run <<-EOR
43
- echo "Creating basic structure for poolparty" &&
44
- mkdir -p /etc/puppet/manifests/nodes &&
45
- mkdir -p /etc/puppet/manifests/classes &&
46
- echo "import 'nodes/*.pp'" > /etc/puppet/manifests/site.pp &&
47
- echo "import 'classes/*.pp'" >> /etc/puppet/manifests/site.pp
48
- EOR
49
- end
50
- desc "Setup shareable file system for provisioner"
51
- task :setup_provisioner_filestore do
52
- run <<-EOR
53
- echo '[files]' > /etc/puppet/fileserver.conf &&
54
- echo ' path #{remote_storage_path}' >> /etc/puppet/fileserver.conf &&
55
- echo ' allow *' >> /etc/puppet/fileserver.conf &&
56
- mkdir -p /var/poolparty/facts &&
57
- mkdir -p /var/poolparty/files &&
58
- mkdir -p #{base_config_directory}
59
- EOR
60
- end
61
- desc "Setup autosigning for provisioner"
62
- task :setup_provisioner_autosigning do
63
- run "echo \"*\" > /etc/puppet/autosign.conf"
64
- end
65
- desc "Setup poolparty structure"
66
- task :setup_poolparty_base_structure do
67
- run <<-EOR
68
- cp #{remote_storage_path}/#{key_file_locations.first} "#{base_config_directory}/.ppkeys" &&
69
- mv #{remote_storage_path}/#{default_specfile_name} #{base_config_directory}/
70
- EOR
71
- end
72
42
  desc "Download base gems"
73
- task :download_base_gems do
43
+ def download_base_gems
74
44
  run(returning(Array.new) do |arr|
75
45
  base_gems.each do |name, url|
76
46
  arr << "wget #{url} -O #{Base.remote_storage_path}/#{name}.gem 2>&1"
@@ -78,7 +48,7 @@ Capistrano::Configuration.instance(:must_exist).load do
78
48
  end.join(" && "))
79
49
  end
80
50
  desc "Install base gems"
81
- task :install_base_gems do
51
+ def install_base_gems
82
52
  run(returning(Array.new) do |arr|
83
53
  base_gems.each do |name, url|
84
54
  if url.empty?
@@ -90,15 +60,19 @@ Capistrano::Configuration.instance(:must_exist).load do
90
60
  end.join(" && "))
91
61
  end
92
62
  desc "Start provisioner base"
93
- task :start_provisioner_base do
63
+ def start_provisioner_base
94
64
  run "/etc/init.d/puppetmaster start"
95
65
  end
96
66
  desc "Restart provisioner base"
97
- task :restart_provisioner_base do
67
+ def restart_provisioner_base
98
68
  run "/etc/init.d/puppetmaster stop;rm -rf /etc/poolparty/ssl;puppetmasterd --verbose;/etc/init.d/puppetmaster start"
99
69
  end
70
+ desc "Ensure provisioner is running"
71
+ def ensure_provisioner_is_running
72
+ run "/usr/sbin/puppetmasterd --verbose 2>1 > /dev/null;echo ''"
73
+ end
100
74
  desc "Create local node for puppet manifest"
101
- task :create_local_node_entry_for_puppet do
75
+ def create_local_node_entry_for_puppet
102
76
  # run ". /etc/profile && server-write-new-nodes"
103
77
  str = returning Array.new do |arr|
104
78
  arr << "node default { include poolparty }"
@@ -109,21 +83,21 @@ Capistrano::Configuration.instance(:must_exist).load do
109
83
  run "echo #{str} > #{manifest_path}/nodes/nodes.pp"
110
84
  end
111
85
  desc "Move template files into place"
112
- task :move_template_files do
86
+ def move_template_files
113
87
  run <<-EOR
114
88
  mkdir -p #{template_path} &&
115
89
  cp -R #{remote_storage_path}/templates/* #{template_path}
116
90
  EOR
117
91
  end
118
92
  desc "Move manifest into place"
119
- task :move_provisioner_manifest do
93
+ def move_provisioner_manifest
120
94
  run <<-EOR
121
95
  cp #{remote_storage_path}/poolparty.pp /etc/puppet/manifests/classes/poolparty.pp
122
96
  EOR
123
97
  end
124
98
  desc "Move poolparty keys"
125
- task :move_poolparty_keys do
99
+ def move_poolparty_keys
126
100
  run "cp #{remote_storage_path}/#{@full_keypair_name} #{@remote_keypair_path}"
127
101
  end
128
- end
102
+ # end
129
103
  end
@@ -1,12 +1,40 @@
1
1
  Capistrano::Configuration.instance(:must_exist).load do
2
- namespace(:slave) do
2
+ # namespace(:slave) do
3
+ desc "Provision a slave"
4
+ def slave_provision_slave_task
5
+ upgrade_system
6
+ add_master_to_hosts_file
7
+ setup_for_poolparty
8
+ install_provisioner
9
+ stop_provisioner_daemon
10
+ setup_basic_poolparty_structure
11
+ setup_provisioner_filestore
12
+ setup_provisioner_autosigning
13
+ install_rubygems
14
+ fix_rubygems
15
+ add_provisioner_configs
16
+ setup_provisioner_config
17
+ create_puppetrunner_command
18
+ create_puppetrerun_command
19
+ download_base_gems
20
+ install_base_gems
21
+ write_erlang_cookie
22
+ end
23
+ desc "Configure a slave"
24
+ def slave_configure_slave_task
25
+ create_local_node_entry_for_puppet
26
+ move_provisioner_manifest
27
+ move_template_files
28
+ setup_poolparty_base_structure
29
+ run_provisioner
30
+ end
3
31
  desc "Add master ip to hosts file"
4
- task :add_master_to_hosts_file do
5
- run "if [ -z \"$(grep -v '#' /etc/hosts | grep 'master')\" ]; then echo '#{master_ip} puppet master' >> /etc/hosts; else echo 'host already set'; fi"
32
+ def add_master_to_hosts_file
33
+ run "if [ -z \"$(grep -v '#' /etc/hosts | grep 'master')\" ]; then echo '#{cloud.master.ip} puppet master' >> /etc/hosts; else echo 'host already set'; fi"
6
34
  end
7
35
  desc "Stop provisioner daemon"
8
- task :stop_provisioner_daemon do
36
+ def stop_provisioner_daemon
9
37
  run "/etc/init.d/puppetmaster stop"
10
38
  end
11
- end
39
+ # end
12
40
  end
@@ -115,6 +115,11 @@ module PoolParty
115
115
  @cloud.custom_configure_tasks_for(@instance) || []
116
116
  end
117
117
 
118
+ # Last install tasks, if need to install after everything else
119
+ def after_install_tasks
120
+ @cloud.after_install_tasks_for(@instance)
121
+ end
122
+
118
123
  # Get the packages associated with each os
119
124
  def puppet_packages
120
125
  case @os
@@ -159,6 +164,10 @@ module PoolParty
159
164
  :rake => "http://rubyforge.org/frs/download.php/43954/rake-0.8.3.gem",
160
165
  :sexp_processor => "http://rubyforge.org/frs/download.php/45589/sexp_processor-3.0.0.gem",
161
166
  "net-ssh" => "http://rubyforge.org/frs/download.php/48041/net-ssh-2.0.6.gem",
167
+ "net-sftp" => "http://rubyforge.org/frs/download.php/37669/net-sftp-2.0.1.gem",
168
+ "net-scp" => "http://rubyforge.org/frs/download.php/37664/net-scp-1.0.1.gem",
169
+ "net-ssh-gateway" => "http://rubyforge.org/frs/download.php/36389/net-ssh-gateway-1.0.0.gem",
170
+ :highline => "http://rubyforge.org/frs/download.php/46328/highline-1.5.0.gem",
162
171
  :capistrano => "http://rubyforge.org/frs/download.php/48031/capistrano-2.5.3.gem",
163
172
  :poolparty => "http://github.com/auser/poolparty/tree/master%2Fpkg%2Fpoolparty.gem?raw=true",
164
173
  "ec2" => "http://rubyforge.org/frs/download.php/43666/amazon-ec2-0.3.1.gem"
@@ -2,7 +2,7 @@ module PoolParty
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
- TINY = 85
5
+ TINY = 89
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/lib/poolparty.rb CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
 
3
3
  # Load required gems
4
4
  @required_software = Array.new
5
- %w(activesupport ftools logging resolv ruby2ruby digest/sha2 open3 capistrano).each do |lib|
5
+ %w(activesupport ftools logging resolv ruby2ruby digest/sha2 open3).each do |lib|
6
6
  begin
7
7
  require lib
8
8
  rescue Exception => e
data/lib/poolpartycl.rb CHANGED
@@ -3,5 +3,5 @@ Dir["#{File.dirname(__FILE__)}/poolparty/helpers/**.rb"].each do |lib|
3
3
  end
4
4
 
5
5
  def help_array
6
- ["-h", "--help", "-V", "--version"]
6
+ ["-h", "--help", "-V", "--version", "--debug", "-d"]
7
7
  end
data/poolparty.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: poolparty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.85
4
+ version: 0.2.88
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ari Lerner
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-15 00:00:00 -08:00
12
+ date: 2008-12-16 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -57,6 +57,7 @@ email:
57
57
  - ari.lerner@citrusbyte.com
58
58
  executables:
59
59
  - cloud
60
+ - cloud-add-access
60
61
  - cloud-add-keypair
61
62
  - cloud-configure
62
63
  - cloud-contract
@@ -121,6 +122,7 @@ files:
121
122
  - README.txt
122
123
  - Rakefile
123
124
  - bin/cloud
125
+ - bin/cloud-add-access
124
126
  - bin/cloud-add-keypair
125
127
  - bin/cloud-configure
126
128
  - bin/cloud-contract
@@ -530,7 +532,7 @@ files:
530
532
  has_rdoc: true
531
533
  homepage: http://poolparty.rubyforge.org
532
534
  post_install_message: |-
533
- Get ready to jump in the pool, you just installed PoolParty! (Updated at 01:19 12/15/08)
535
+ Get ready to jump in the pool, you just installed PoolParty! (Updated at 02:30 12/16/08)
534
536
 
535
537
  To get started, run the generator:
536
538
 
@@ -33,6 +33,14 @@ describe "Hash" do
33
33
  it "should be able to flush out with pre and posts" do
34
34
  @a.flush_out("hi", "ho").sort.should == ["hia => '10'ho","hib => '20'ho","hic => '30'ho"]
35
35
  end
36
+ describe "method_missing" do
37
+ it "should be able to call a key on the hash as a method" do
38
+ {:first_name => "bob", :last_name => "frank"}.first_name.should == "bob"
39
+ end
40
+ it "should return nil if there is no key set in the hash" do
41
+ {:first_name => "bob", :last_name => "frank"}.neighbor.should == nil
42
+ end
43
+ end
36
44
  describe "select" do
37
45
  before(:each) do
38
46
  @selected_hash = @a.select {|k,v| k if k == :a}
@@ -389,7 +389,7 @@ describe "Cloud" do
389
389
  @cloud.respond_to?(:generate_unique_cookie_string).should == true
390
390
  end
391
391
  it "should call hexdigest to digest/sha" do
392
- Digest::SHA256.should_receive(:hexdigest).with("#{@cloud.full_keypair_name}#{@cloud.name}")
392
+ Digest::SHA256.should_receive(:hexdigest).with("#{@cloud.full_keypair_name}#{@cloud.name}").and_return "blaaaaah"
393
393
  @cloud.generate_unique_cookie_string
394
394
  end
395
395
  it "should generate the same cookie string every time" do
@@ -21,7 +21,12 @@ describe "Capistrano provisioner" do
21
21
  it "should create the config at ::Capistrano::Logger::IMPORTANT if the cloud is not verbose" do
22
22
  @cloud.stub!(:verbose).and_return false
23
23
  PoolParty::Provisioner::Capistrano.new(nil, @cloud).config.logger.level.should == ::Capistrano::Logger::IMPORTANT
24
- end
24
+ end
25
+ end
26
+ describe "install tasks" do
27
+ it "should have the configure tasks included" do
28
+ @pb.master_install_tasks.include?("custom_configure_tasks").should == true
29
+ end
25
30
  end
26
31
  end
27
32
  end
data/website/index.html CHANGED
@@ -34,7 +34,7 @@
34
34
  <h1>PoolParty</h1>
35
35
  <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/poolparty"; return false'>
36
36
  <p>Get Version</p>
37
- <a href="http://rubyforge.org/projects/poolparty" class="numbers">0.2.85</a>
37
+ <a href="http://rubyforge.org/projects/poolparty" class="numbers">0.2.88</a>
38
38
  </div>
39
39
  <h1>&#8216;Easy cloud computing&#8217;</h1>
40
40
  <h2>What</h2>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auser-poolparty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.85
4
+ version: 0.2.88
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ari Lerner
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-15 00:00:00 -08:00
12
+ date: 2008-12-16 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -57,6 +57,7 @@ email:
57
57
  - ari.lerner@citrusbyte.com
58
58
  executables:
59
59
  - cloud
60
+ - cloud-add-access
60
61
  - cloud-add-keypair
61
62
  - cloud-configure
62
63
  - cloud-contract
@@ -121,6 +122,7 @@ files:
121
122
  - README.txt
122
123
  - Rakefile
123
124
  - bin/cloud
125
+ - bin/cloud-add-access
124
126
  - bin/cloud-add-keypair
125
127
  - bin/cloud-configure
126
128
  - bin/cloud-contract
@@ -530,7 +532,7 @@ files:
530
532
  has_rdoc: true
531
533
  homepage: http://poolparty.rubyforge.org
532
534
  post_install_message: |-
533
- Get ready to jump in the pool, you just installed PoolParty! (Updated at 01:19 12/15/08)
535
+ Get ready to jump in the pool, you just installed PoolParty! (Updated at 02:30 12/16/08)
534
536
 
535
537
  To get started, run the generator:
536
538