auser-poolparty 0.2.37 → 0.2.38

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. data/Manifest.txt +1 -0
  2. data/bin/cloud-add-keypair +2 -2
  3. data/bin/cloud-maintain +10 -11
  4. data/bin/cloud-provision +5 -4
  5. data/bin/messenger-get-load +3 -2
  6. data/bin/server-show-stats +22 -0
  7. data/lib/erlang/messenger/ebin/master_app.beam +0 -0
  8. data/lib/erlang/messenger/ebin/node_app.beam +0 -0
  9. data/lib/erlang/messenger/ebin/pm_client.beam +0 -0
  10. data/lib/erlang/messenger/ebin/pm_cluster.beam +0 -0
  11. data/lib/erlang/messenger/ebin/pm_event_manager.beam +0 -0
  12. data/lib/erlang/messenger/ebin/pm_master_event_handler.beam +0 -0
  13. data/lib/erlang/messenger/ebin/pm_master_supervisor.beam +0 -0
  14. data/lib/erlang/messenger/ebin/pm_node_supervisor.beam +0 -0
  15. data/lib/erlang/messenger/ebin/pm_packager.beam +0 -0
  16. data/lib/erlang/messenger/src/utils.erl +1 -1
  17. data/lib/erlang/messenger/useful_snippets +8 -0
  18. data/lib/poolparty/aska/aska.rb +13 -0
  19. data/lib/poolparty/base_packages/haproxy.rb +17 -24
  20. data/lib/poolparty/base_packages/poolparty.rb +26 -18
  21. data/lib/poolparty/core/object.rb +1 -1
  22. data/lib/poolparty/helpers/provisioner_base.rb +15 -12
  23. data/lib/poolparty/helpers/provisioners/master.rb +39 -35
  24. data/lib/poolparty/helpers/provisioners/slave.rb +2 -3
  25. data/lib/poolparty/net/remote_instance.rb +6 -0
  26. data/lib/poolparty/plugins/git.rb +2 -2
  27. data/lib/poolparty/pool/resource.rb +1 -1
  28. data/lib/poolparty/pool/resources/conditional.rb +15 -3
  29. data/lib/poolparty/pool/resources/gem_package.rb +12 -7
  30. data/lib/poolparty/templates/puppetcleaner +1 -1
  31. data/lib/poolparty/version.rb +1 -1
  32. data/poolparty.gemspec +4 -2
  33. data/spec/poolparty/pool/resources/conditional_spec.rb +2 -2
  34. data/website/index.html +1 -1
  35. metadata +4 -2
@@ -33,6 +33,7 @@ bin/server-get-load
33
33
  bin/server-list-active
34
34
  bin/server-list-responding
35
35
  bin/server-rerun
36
+ bin/server-show-stats
36
37
  bin/server-start-master
37
38
  bin/server-start-node
38
39
  config/hoe.rb
@@ -15,8 +15,8 @@ include Remote
15
15
 
16
16
  @clouds.each do |name, cloud|
17
17
 
18
- with_cloud(cloud, {:location => @location}) do
19
- logger.info header("Creating keypair for #{name}")
18
+ with_cloud(cloud, {:location => @location, :verbose => o.verbose}) do
19
+ vputs header("Creating keypair for #{name}")
20
20
  create_keypair unless testing
21
21
  end
22
22
 
@@ -18,19 +18,18 @@ include Remote
18
18
 
19
19
  @clouds.each do |name, cloud|
20
20
 
21
- with_cloud(cloud, {:location => @location, :testing => o.testing}) do
22
- logger.info header("Maintaining cloud #{name}")
21
+ with_cloud(cloud, {:location => @location, :testing => o.testing, :verbose => o.verbose}) do
22
+ vputs header("Maintaining cloud #{name}")
23
23
  if !minimum_number_of_instances_are_running?
24
- logger.warn "#{list_of_running_instances.size} running instances of between #{minimum_instances} and #{maximum_instances}"
25
- logger.warn "Launching new instance"
26
- expand_cloud_if_necessary( !testing )
24
+ vputs "#{list_of_running_instances.size} running instances of between #{minimum_instances} and #{maximum_instances}"
25
+ vputs "Launching new instance"
27
26
  elsif !maximum_number_of_instances_are_not_running?
28
- logger.warn "#{list_of_running_instances.size} running instances of between #{minimum_instances} and #{maximum_instances}"
29
- logger.warn "Shutting down non-master instance"
30
- contract_cloud_if_necessary( !testing )
31
- else
32
- logger.info "Cloud is maintained"
33
- end
27
+ vputs "#{list_of_running_instances.size} running instances of between #{minimum_instances} and #{maximum_instances}"
28
+ vputs "Shutting down non-master instance"
29
+ end
30
+ vputs "Cloud is maintained"
31
+ expand_cloud_if_necessary( !testing )
32
+ contract_cloud_if_necessary( !testing )
34
33
  end
35
34
 
36
35
  end
@@ -4,7 +4,7 @@ require "poolparty"
4
4
  require "poolpartycl"
5
5
  o = PoolParty::Optioner.new(ARGV) do |opts, optioner|
6
6
  opts.on('-s', '--slave', 'Provision slave (default: false)') { optioner.provision_slave true }
7
- opts.on('-i num', '--id num', 'Instance num to provision') { |i| optioner.num i }
7
+ opts.on('-i num', '--id num', 'Instance num to provision') { |i| optioner.instance_num i }
8
8
  end
9
9
 
10
10
  load_pool(o.spec || Binary.get_existing_spec_location)
@@ -12,13 +12,14 @@ load_pool(o.spec || Binary.get_existing_spec_location)
12
12
  include Remote
13
13
 
14
14
  @clouds = extract_cloud_from_options o
15
- @instance_num = o.num.to_i || nil
16
15
 
17
16
  @clouds.each do |cloud|
18
17
 
19
- with_cloud(cloud, {:verbose => o.verbose, :testing => o.testing, :provision_slave => (o.provision_slave || false), :instance_num => @instance_num}) do
18
+ with_cloud(cloud, {:verbose => o.verbose, :testing => o.testing, :provision_slave => (o.provision_slave || false), :instance_number => o.instance_num}) do
19
+
20
+ instance_num = instance_number.to_i if instance_number
20
21
 
21
- if instance_num
22
+ if instance_num
22
23
  @instance = get_instance_by_number( instance_num )
23
24
  vputs "Provisioning instance: #{@instance.name} (#{instance_num})"
24
25
  Provisioner.provision_slave(@instance, self, testing)
@@ -18,9 +18,10 @@ include Remote
18
18
 
19
19
  @clouds.each do |cl|
20
20
 
21
- with_cloud(cl, {:testing => o.testing, :monitorname => @monitor }) do
21
+ with_cloud(cl, {:testing => o.testing, :monitorname => @monitor, :verbose => o.verbose }) do
22
22
  vputs "Getting #{monitorname} load through the messenger"
23
- print PoolParty::Messenger.messenger_send!("get_load #{monitorname}", testing)
23
+ load = PoolParty::Messenger.messenger_send!("get_load #{monitorname}", testing)
24
+ load =~ /[0-9\.]+/ ? print load : vputs "-1"
24
25
  end
25
26
 
26
27
  end
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
3
+ require "poolparty"
4
+ require "poolpartycl"
5
+
6
+ available_monitors = PoolParty::Monitors.available_monitors
7
+ o = PoolParty::Optioner.new(ARGV) do |opts, optioner|
8
+ end
9
+
10
+ load_pool(o.spec || Binary.get_existing_spec_location)
11
+
12
+ include Remote
13
+
14
+ @clouds = extract_cloud_from_options o
15
+
16
+ @clouds.each do |cloud|
17
+
18
+ with_cloud(cloud, {:testing => o.testing }) do
19
+ puts rules_values
20
+ end
21
+
22
+ end
@@ -32,7 +32,7 @@ end.
32
32
  average_for_list(Num, L) ->
33
33
  case length(L) of
34
34
  0 ->
35
- 0;
35
+ -1;
36
36
  _ ->
37
37
  Num / length(L)
38
38
  end.
@@ -4,3 +4,11 @@
4
4
  % Start test nodes, defining testing
5
5
  % erl -pa ./ebin -kernel inet_dist_listen_min 7000 inet_dist_listen_max 7050 -setcookie poolparty -boot pm_node_rel-0.1 -sname node0
6
6
  % erl -pa ./ebin -kernel inet_dist_listen_min 7000 inet_dist_listen_max 7050 -setcookie poolparty -boot pm_node_rel-0.1 -sname node1
7
+
8
+ % Starting the client on the master
9
+ % erl -pa /var/lib/gems/1.8/gems/poolparty-0.2.37/lib/erlang/messenger/ebin -kernel inet_dist_listen_min 7000 inet_dist_listen_max 7050 -sname client -setcookie poolparty -run pm_client start
10
+
11
+ % Get the load
12
+ % erl -pa /var/lib/gems/1.8/gems/poolparty-0.2.38/lib/erlang/messenger/ebin -kernel inet_dist_listen_min 7000 inet_dist_listen_max 7050 -sname client -setcookie poolparty -run pm_client start -run pm_client get_load cpu -run erlang init stop
13
+
14
+ % cd /var/poolparty && gem uninstall poolparty && wget http://github.com/auser/poolparty/tree/master%2Fpkg%2Fpoolparty-latest.gem?raw=true -O poolparty-latest.gem 2>&1 && gem install --no-ri --no-rdoc poolparty-latest.gem
@@ -14,6 +14,7 @@ module Aska
14
14
 
15
15
  create_instance_variable(k)
16
16
  rs << {k => [m, v]}
17
+ rs << {k => [">", "0"]} unless rs.reject {|a| a.to_s == "#{k}>0" }
17
18
  end
18
19
  self.send(:define_method, name) do
19
20
  look_up_rules(name)
@@ -66,6 +67,18 @@ module Aska
66
67
  end
67
68
  end
68
69
  end
70
+ def rules_values
71
+ returning Array.new do |arr|
72
+ self.class.defined_rules.each do |name,rule_array|
73
+ arr << name
74
+ rule_array.each do |rule|
75
+ rule.map do |k,v|
76
+ arr << "#{k} -> #{__aska_aska_stuff(k)} (#{v[0]} #{v[1]})"
77
+ end
78
+ end
79
+ end
80
+ end.join("\n")
81
+ end
69
82
  # Get the variable from the class
70
83
  # If it's defined as an attr_accessor, we know it has been defined as a rule
71
84
  # Otherwise, if we are passing it as a
@@ -3,43 +3,36 @@ module PoolParty
3
3
  plugin :haproxy do
4
4
 
5
5
  def enable
6
- execute_if("$hostname", "master") do
6
+ execute_on_master do
7
7
  package({:name => "haproxy"})
8
8
 
9
- # Startup haproxy and enable it
10
- has_line_in_file("ENABLED=1", "/etc/default/haproxy")
11
- has_line_in_file("SYSLOGD=\"-r\"", "/etc/default/syslogd")
12
- has_line_in_file("local0.* /var/log/haproxy.log", "/etc/syslog.conf", {:notify => 'Service["sysklogd"]'})
13
-
14
9
  # Restart sysklogd after we update the haproxy.log
15
10
  has_service(:name => "sysklogd") do
16
11
  ensures "running"
17
12
  end
13
+
14
+ # Template variables
15
+ has_variable(:name => "name_haproxy", :value => "#{cloud.name}")
16
+ has_variable(:name => "nodenames_haproxy", :value => "generate('/usr/bin/env', '/var/lib/gems/1.8/bin/server-list-active', '-c', 'name')")
17
+ has_variable(:name => "node_ips_haproxy", :value => "generate('/usr/bin/env', '/var/lib/gems/1.8/bin/server-list-active', '-c', 'ip')")
18
+
19
+ has_variable(:name => "ports_haproxy", :value => ([(self.respond_to?(:port) ? port : Base.port)].flatten))
20
+ has_variable(:name => "forwarding_port", :value => (respond_to?(:forwarding_port) ? forwarding_port : Base.forwarding_port))
21
+ has_variable(:name => "proxy_mode", :value => (respond_to?(:proxy_mode) ? proxy_mode : Base.proxy_mode))
22
+
23
+ # Startup haproxy and enable it
24
+ has_line_in_file("ENABLED=1", "/etc/default/haproxy")
25
+ has_line_in_file("SYSLOGD=\"-r\"", "/etc/default/syslogd")
26
+ has_line_in_file("local0.* /var/log/haproxy.log", "/etc/syslog.conf", {:notify => get_service("sysklogd")})
18
27
 
19
28
  # Service is required
20
29
  has_service(:name => "haproxy", :ensures => "running")
21
30
 
22
- # Tempalte variables
23
- variable(:name => "name_haproxy", :value => "#{cloud.name}")
24
-
25
- # if cloud.provisioning?
26
- # variable(:name => "nodenames_haproxy", :value => "#{list_of_running_instances.map{|a| "#{a.send :name}" }.join("\t")}")
27
- # variable(:name => "node_ips_haproxy", :value => "#{list_of_running_instances.map{|a| "#{a.send :ip}" }.join("\t")}")
28
- # else
29
- variable(:name => "nodenames_haproxy", :value => "generate('/usr/bin/env', '/var/lib/gems/1.8/bin/server-list-active', '-c', 'name')")
30
- variable(:name => "node_ips_haproxy", :value => "generate('/usr/bin/env', '/var/lib/gems/1.8/bin/server-list-active', '-c', 'ip')")
31
- # end
32
-
33
- variable(:name => "ports_haproxy", :value => ([(self.respond_to?(:port) ? port : Base.port)].flatten))
34
- variable(:name => "forwarding_port", :value => (respond_to?(:forwarding_port) ? forwarding_port : Base.forwarding_port))
35
- variable(:name => "proxy_mode", :value => (respond_to?(:proxy_mode) ? proxy_mode : Base.proxy_mode))
36
-
37
31
  # These can also be passed in via hash
38
32
  has_remotefile(:name => "/etc/haproxy.cfg") do
39
33
  mode 644
40
- # onlyif '$hostname == "master"'
41
- requires 'Package["haproxy"]'
42
- notify 'Service["haproxy"]'
34
+ requires get_package("haproxy")
35
+ notify get_service("haproxy")
43
36
  template File.join(File.dirname(__FILE__), "..", "templates/haproxy.conf")
44
37
  end
45
38
  end
@@ -3,6 +3,12 @@ module PoolParty
3
3
  plugin :poolparty do
4
4
 
5
5
  def enable
6
+ # Build hostsfile
7
+ # TODO: COME BACK AND CLEAN THIS UP
8
+ (self.respond_to?(:list_of_running_instances) ? self : parent).list_of_running_instances.each do |ri|
9
+ has_host({:name => "#{ri.name}", :ip => ri.ip })
10
+ end
11
+
6
12
  has_package(:name => "erlang")
7
13
  has_package(:name => "erlang-dev")
8
14
  has_package(:name => "erlang-src")
@@ -32,39 +38,41 @@ module PoolParty
32
38
 
33
39
  has_gempackage(:name => "RubyInline", :download_url => "http://rubyforge.org/frs/download.php/45683/RubyInline-3.8.1.gem")
34
40
 
35
- has_gempackage(:name => "poolparty", :download_url => "http://github.com/auser/poolparty/tree/master%2Fpkg%2Fpoolparty-latest.gem?raw=true", :requires => [get_gempackage("ruby2ruby"), get_gempackage("RubyInline"), get_gempackage("ParseTree")])
41
+ has_gempackage(:name => "poolparty-latest", :download_url => "http://github.com/auser/poolparty/tree/master%2Fpkg%2Fpoolparty-latest.gem?raw=true", :requires => [get_gempackage("ruby2ruby"), get_gempackage("RubyInline"), get_gempackage("ParseTree")])
36
42
 
37
- has_exec(:name => "build_messenger", :command => ". /etc/profile && server-build-messenger", :requires => get_gempackage("poolparty"))
38
- has_exec(:name => "start_node", :command => ". /etc/profile && server-start-node", :requires => get_exec("build_messenger"))
43
+ has_exec(:name => "build_messenger", :command => ". /etc/profile && server-build-messenger", :requires => get_gempackage("poolparty-latest"), :ifnot => "ps aux | grep beam | grep node")
44
+ has_exec(:name => "start_node", :command => ". /etc/profile && server-start-node", :requires => get_exec("build_messenger"), :ifnot => "ps aux | grep beam | grep node")
39
45
 
40
46
  end
41
-
42
- # Build hostsfile
43
- # TODO: COME BACK AND CLEAN THIS UP
44
- (self.respond_to?(:list_of_running_instances) ? self : parent).list_of_running_instances.each do |ri|
45
- has_host({:name => "#{ri.name}", :ip => ri.ip })
46
- end
47
47
 
48
48
  # Custom run puppet to minimize footprint
49
49
  # TODO: Update the offsetted times
50
- has_cron(:name => "puppetd runner", :user => Base.user, :minute => "*/8") do
51
- command((self.respond_to?(:master) ? self : parent).master.puppet_runner_command)
50
+ execute_on_master do
51
+ has_cron(:name => "puppetd runner", :user => Base.user, :minute => "*/5") do
52
+ command(PoolParty::Remote::RemoteInstance.puppet_master_rerun_command)
53
+ end
54
+ end
55
+ execute_on_node do
56
+ has_cron(:name => "puppetd runner", :user => Base.user, :minute => "*/5") do
57
+ command(PoolParty::Remote::RemoteInstance.puppet_rerun_commad)
58
+ end
52
59
  end
53
60
 
54
61
  # These are all requirements on the master
55
- execute_if("$hostname", "master") do
56
- has_cron({:name => "maintain script ", :command => ". /etc/profile && which cloud-maintain | /bin/sh", :minute => "*/3"})
62
+ execute_on_master do
63
+ has_cron({:name => "maintain script", :command => ". /etc/profile && which cloud-maintain | /bin/sh", :minute => "*/3"})
57
64
  # TODO: Update this so it only runs when needed
58
- has_exec(:name => "start master messenger", :command => ". /etc/profile && server-start-master", :requires => [get_gempackage("poolparty"), get_exec("build_messenger")])
65
+ has_exec(:name => "start master messenger", :command => ". /etc/profile && server-start-master", :requires => [get_gempackage("poolparty-latest"), get_exec("build_messenger")], :ifnot => "ps aux | grep beam | grep node")
59
66
 
60
67
  has_remotefile(:name => "/usr/bin/puppetcleaner") do
61
68
  mode 744
62
69
  template File.join(File.dirname(__FILE__), "..", "templates/puppetcleaner")
63
70
  end
64
- has_remotefile(:name => "/usr/bin/puppetrerun") do
65
- mode 744
66
- template File.join(File.dirname(__FILE__), "..", "templates/puppetrerun")
67
- end
71
+ end
72
+
73
+ has_remotefile(:name => "/usr/bin/puppetrerun") do
74
+ mode 744
75
+ template File.join(File.dirname(__FILE__), "..", "templates/puppetrerun")
68
76
  end
69
77
 
70
78
  # has_host(:name => "puppet", :ip => (self.respond_to?(:master) ? self : parent).master.ip)
@@ -31,7 +31,7 @@ class Object
31
31
  v
32
32
  else
33
33
  vs = v.to_s.to_sym
34
- respond_to?(vs) ? self.send(vs, *args) : v
34
+ respond_to?(vs) ? self.send(vs, *args) : v rescue v
35
35
  end
36
36
  end
37
37
  def to_option_string
@@ -10,7 +10,6 @@ module PoolParty
10
10
  # Convenience method to clean
11
11
  def self.provision_master(cloud, testing=false)
12
12
  Provisioner::Master.new(cloud).process_install!(testing)
13
- process_clean_reconfigure_for!(cloud.master, cloud, testing)
14
13
  end
15
14
 
16
15
  def self.configure_master(cloud, testing=false)
@@ -29,7 +28,6 @@ module PoolParty
29
28
 
30
29
  def self.configure_slaves(cloud, testing=false)
31
30
  cloud.nonmaster_nonterminated_instances.each do |sl|
32
- puts "Slave: #{sl.name} (#{sl.ip})"
33
31
  configure_slave(sl, cloud, testing)
34
32
  end
35
33
  end
@@ -65,10 +63,14 @@ module PoolParty
65
63
  # Callback after initialized
66
64
  def loaded(opts={}, parent=self)
67
65
  end
66
+
67
+ ### Installation tasks
68
+
68
69
  # This is the actual runner for the installation
69
70
  def install
70
71
  valid? ? install_string : error
71
72
  end
73
+ # Write the installation tasks to a file in the storage directory
72
74
  def write_install_file
73
75
  error unless valid?
74
76
  ::FileUtils.mkdir_p Base.storage_directory unless ::File.exists?(Base.storage_directory)
@@ -88,16 +90,16 @@ module PoolParty
88
90
  vputs "Logging on to #{@instance.ip} (#{@instance.name})"
89
91
  @cloud.rsync_storage_files_to(@instance)
90
92
  vputs "Preparing configuration on the master"
91
- process_clean_reconfigure_for!(@instance)
92
93
 
93
94
  before_install(@instance)
94
95
 
95
96
  vputs "Logging in and running provisioning on #{@instance.name}"
96
- cmd = "cd #{Base.remote_storage_path} && chmod +x install_#{name}.sh && /bin/sh install_#{name}.sh && rm install_#{name}.sh"
97
+ cmd = "cd #{Base.remote_storage_path} && chmod +x install_#{name}.sh && /bin/sh install_#{name}.sh; rm install_#{name}.sh"
97
98
  verbose ? @cloud.run_command_on(cmd, @instance) : hide_output {@cloud.run_command_on(cmd, @instance)}
98
99
 
99
- process_clean_reconfigure_for!(@instance)
100
- after_install(@instance)
100
+ process_clean_reconfigure_for!(@instance, testing)
101
+
102
+ after_install(@instance)
101
103
  end
102
104
  end
103
105
  # Install callbacks
@@ -106,6 +108,9 @@ module PoolParty
106
108
  end
107
109
  def after_install(instance)
108
110
  end
111
+
112
+ ### Configuraton tasks
113
+
109
114
  def configure
110
115
  valid? ? configure_string : error
111
116
  end
@@ -122,25 +127,23 @@ module PoolParty
122
127
  unless testing
123
128
  vputs "Logging on to #{@instance.ip}"
124
129
  @cloud.rsync_storage_files_to(@instance)
125
- process_clean_reconfigure_for!(@instance)
126
130
 
127
131
  cmd = "cd #{Base.remote_storage_path} && chmod +x configure_#{name}.sh && /bin/sh configure_#{name}.sh && rm configure_#{name}.sh"
128
132
  verbose ? @cloud.run_command_on(cmd, @instance) : hide_output {@cloud.run_command_on(cmd, @instance)}
129
- process_clean_reconfigure_for!(@instance)
130
133
  end
131
134
  end
132
135
  def process_clean_reconfigure_for!(instance, testing=false)
133
136
  vputs "Cleaning certs from master: #{instance.name}"
134
137
  # puppetca --clean #{instance.name}.compute-1.internal; puppetca --clean #{instance.name}.ec2.internal
135
138
  # find /etc/puppet/ssl -type f -exec rm {} \;
136
- command = <<-EOE
137
- if [ -f '/usr/bin/puppetcleaner' ]; then /usr/bin/env puppetcleaner; fi
138
- EOE
139
- @cloud.run_command_on(command, @cloud.master) unless testing
139
+ command = instance.master? ? "if [ -f '/usr/bin/puppetcleaner' ]; then /usr/bin/env puppetcleaner; fi" : "rm -rf /etc/puppet/ssl"
140
+ @cloud.run_command_on(command, instance) unless testing
140
141
  end
141
142
  def process_reconfigure!(testing=false)
142
143
  @cloud.run_command_on(RemoteInstance.puppet_runner_command, @instance) unless testing
143
144
  end
145
+ # Tasks that need to be performed everytime we do any
146
+ # remote ssh'ing into any instance
144
147
  def setup_runner(force=false)
145
148
  @cloud.prepare_to_configuration
146
149
  @cloud.build_and_store_new_config_file(force)
@@ -24,6 +24,7 @@ module PoolParty
24
24
  setup_fileserver,
25
25
  setup_autosigning,
26
26
  install_poolparty,
27
+ setup_poolparty,
27
28
  start_puppetmaster
28
29
  ] << configure_tasks
29
30
  end
@@ -77,48 +78,23 @@ mkdir -p /etc/poolparty
77
78
  echo "*" > /etc/puppet/autosign.conf
78
79
  EOS
79
80
  end
80
-
81
- def create_local_node
82
- str = <<-EOS
83
- node default {
84
- include poolparty
85
- }
86
- EOS
87
- @cloud.list_of_running_instances.each do |ri|
88
- str << <<-EOS
89
- node "#{ri.name}" inherits default {}
90
- EOS
91
- end
92
- "echo '#{str}' > /etc/puppet/manifests/nodes/nodes.pp"
93
- end
94
-
95
- def move_templates
96
- <<-EOS
97
- mkdir -p #{Base.template_path}
98
- cp #{Base.remote_storage_path}/#{Base.template_directory}/* #{Base.template_path}
99
- EOS
100
- end
101
81
 
102
- def create_poolparty_manifest
82
+ def setup_poolparty
103
83
  <<-EOS
104
- cp #{Base.remote_storage_path}/poolparty.pp /etc/puppet/manifests/classes/poolparty.pp
105
84
  cp #{Base.remote_storage_path}/#{Base.key_file_locations.first} "#{Base.base_config_directory}/.ppkeys"
106
85
  cp #{Base.remote_storage_path}/#{Base.default_specfile_name} #{Base.base_config_directory}/#{Base.default_specfile_name}
107
- #{copy_ssh_app}
108
86
  EOS
109
87
  end
110
-
88
+
111
89
  def copy_ssh_app
112
- if @cloud.remote_keypair_path != "#{Base.remote_storage_path}/#{@cloud.full_keypair_name}"
113
- "cp #{Base.remote_storage_path}/#{@cloud.full_keypair_name} #{@cloud.remote_keypair_path}"
114
- end
90
+ "cp #{Base.remote_storage_path}/#{@cloud.full_keypair_name} #{@cloud.remote_keypair_path}" if @cloud.remote_keypair_path != "#{Base.remote_storage_path}/#{@cloud.full_keypair_name}"
115
91
  end
116
92
 
117
93
  def install_poolparty
118
94
  <<-EOE
119
95
  cd /var/poolparty
120
96
  wget http://rubyforge.org/frs/download.php/44731/logging-0.9.4.gem -O logging.gem 2>&1
121
- wget http://rubyforge.org/frs/download.php/45581/ZenTest-3.11.0.gem -O zentest.gem 2>&1
97
+ wget http://rubyforge.org/frs/download.php/45581/ZenTest-3.11.0.gem -O ZenTest.gem 2>&1
122
98
  wget http://rubyforge.org/frs/download.php/45600/ParseTree-3.0.1.gem -O ParseTree.gem 2>&1
123
99
  wget http://rubyforge.org/frs/download.php/45587/ruby2ruby-1.2.0.gem -O ruby2ruby.gem 2>&1
124
100
  wget http://rubyforge.org/frs/download.php/45627/activesupport-2.1.2.gem -O activesupport.gem 2>&1
@@ -131,11 +107,11 @@ wget http://rubyforge.org/frs/download.php/45546/rubyforge-1.0.1.gem -O rubyforg
131
107
  wget http://rubyforge.org/frs/download.php/43954/rake-0.8.3.gem -O rake.gem 2>&1
132
108
  wget http://rubyforge.org/frs/download.php/45589/sexp_processor-3.0.0.gem -O sexp_processor.gem 2>&1
133
109
  wget http://github.com/auser/poolparty/tree/master%2Fpkg%2Fpoolparty-latest.gem?raw=true -O poolparty-latest.gem 2>&1
134
- wget http://rubyforge.org/frs/download.php/43666/amazon-ec2-0.3.1.gem -O amazon-ec2.gem 2>&1
110
+ wget http://rubyforge.org/frs/download.php/43666/amazon-ec2-0.3.1.gem -O grempe-amazon-ec2.gem 2>&1
135
111
 
136
112
  #{
137
- %w(rake lockfile rubyforge hoe zentest sexp_processor flexmock logging activesupport
138
- RubyInline ParseTree ruby2ruby xml-simple poolparty-latest amazon-ec2).map do |dep|
113
+ %w(rake lockfile rubyforge hoe ZenTest sexp_processor flexmock logging activesupport
114
+ RubyInline ParseTree ruby2ruby xml-simple poolparty-latest grempe-amazon-ec2).map do |dep|
139
115
  "gem install --ignore-dependencies -y --no-ri --no-rdoc #{dep}.gem"
140
116
  end.join("\n")
141
117
  }
@@ -144,17 +120,45 @@ wget http://rubyforge.org/frs/download.php/43666/amazon-ec2-0.3.1.gem -O amazon-
144
120
  # gem install -y --no-ri --no-rdoc --source http://gems.github.com auser-poolparty
145
121
  EOE
146
122
  end
147
-
123
+
148
124
  # ps aux | grep puppetmasterd | awk '{print $2}' | xargs kill
149
125
  # rm -rf /etc/puppet/ssl
150
126
  def start_puppetmaster
151
127
  <<-EOS
152
- /usr/bin/env puppetcleaner 2>&1 > /dev/null
153
128
  puppetmasterd --verbose 2>&1 > /dev/null
154
129
  EOS
155
130
  end
156
131
 
157
- # puppetd --listen --fqdn #{@instance.name}
132
+ # TODO:
133
+ # Consider this method in the manifest
134
+ def create_local_node
135
+ str = <<-EOS
136
+ node default {
137
+ include poolparty
138
+ }
139
+ EOS
140
+ @cloud.list_of_running_instances.each do |ri|
141
+ str << <<-EOS
142
+ node "#{ri.name}" inherits default {}
143
+ EOS
144
+ end
145
+ "echo '#{str}' > /etc/puppet/manifests/nodes/nodes.pp"
146
+ end
147
+
148
+ def move_templates
149
+ <<-EOS
150
+ mkdir -p #{Base.template_path}
151
+ cp #{Base.remote_storage_path}/#{Base.template_directory}/* #{Base.template_path}
152
+ EOS
153
+ end
154
+
155
+ def create_poolparty_manifest
156
+ <<-EOS
157
+ cp #{Base.remote_storage_path}/poolparty.pp /etc/puppet/manifests/classes/poolparty.pp
158
+ #{copy_ssh_app}
159
+ EOS
160
+ end
161
+
158
162
  def restart_puppetd
159
163
  <<-EOS
160
164
  . /etc/profile && /usr/sbin/puppetd --onetime --no-daemonize --logdest syslog --server master 2>&1 > /dev/null
@@ -26,7 +26,7 @@ module PoolParty
26
26
  def setup_configs
27
27
  <<-EOS
28
28
  echo "#{open(File.join(template_directory, "puppet.conf")).read}" > /etc/puppet/puppet.conf
29
- rm -rf /etc/puppet/ssl
29
+ /usr/bin/puppetrerun
30
30
  EOS
31
31
  end
32
32
 
@@ -34,8 +34,7 @@ module PoolParty
34
34
  # puppetd --listen --fqdn #{@instance.name}
35
35
  def start_puppet
36
36
  <<-EOS
37
- rm -rf /etc/puppet/ssl
38
- /usr/bin/puppetrerun
37
+ . /etc/profile && /usr/sbin/puppetd --onetime --no-daemonize --logdest syslog --server master 2>&1
39
38
  EOS
40
39
  end
41
40
 
@@ -69,6 +69,12 @@ module PoolParty
69
69
  end
70
70
  # Commands for the servers
71
71
  def self.puppet_runner_command
72
+ ". /etc/profile && /usr/sbin/puppetd --onetime --no-daemonize --logdest syslog --server master 2>&1"
73
+ end
74
+ def self.puppet_master_rerun_command
75
+ "/usr/bin/puppetcleaner; #{puppet_runner_command}"
76
+ end
77
+ def self.puppet_rerun_commad
72
78
  "/usr/bin/puppetrerun 2>&1 > /dev/null"
73
79
  end
74
80
  end
@@ -11,12 +11,12 @@ module PoolParty
11
11
  has_package(:name => "git-core")
12
12
  has_directory(:name => "#{cwd}")
13
13
 
14
- exec({:name => "git-#{name}", :requires => get_package(:name => "git-core"), :requires => get_directory("#{cwd}")}) do
14
+ has_exec({:name => "git-#{name}", :requires => get_package("git-core"), :requires => get_directory("#{cwd}")}) do
15
15
  command parent.user ? "git clone #{parent.user}@#{parent.source} #{parent.path}" : "git clone #{parent.source} #{parent.to ? parent.to : ""}"
16
16
  cwd "#{parent.cwd if parent.cwd}"
17
17
  creates "#{::File.join( (parent.cwd ? parent.cwd : cwd), ::File.basename(parent.source, ::File.extname(parent.source)) )}/.git"
18
18
  end
19
- exec(:name => "update-#{name}", :requires => get_exec("git-#{name}")) do
19
+ has_exec(:name => "update-#{name}", :requires => get_exec("git-#{name}")) do
20
20
  cwd get_exec("git-#{parent.name}").cwd
21
21
  command "git pull"
22
22
  end
@@ -105,7 +105,7 @@ module PoolParty
105
105
  # the options
106
106
  # Finally, it uses the parent's options as the lowest priority
107
107
  def initialize(opts={}, parent=self, &block)
108
- # Take the options of the parents
108
+ # Take the options of the parents
109
109
  set_vars_from_options(opts) unless opts.empty?
110
110
  set_resource_parent(parent)
111
111
  self.run_in_context &block if block
@@ -1,9 +1,17 @@
1
1
  module PoolParty
2
2
  module Resources
3
3
 
4
- def execute_if(attr_s="$hostname", str="", parent=self, &block)
4
+ def execute_on_master(parent=self, &block)
5
+ execute_if("$hostname", "==", "master", parent, &block)
6
+ end
7
+
8
+ def execute_on_node(parent=self, &block)
9
+ execute_if("$hostname", "!=", "master", parent, &block)
10
+ end
11
+
12
+ def execute_if(attr_s="$hostname", comparison="==", str="", parent=self, &block)
5
13
  # parent = parent.is_a?(PoolParty::Cloud::Cloud) ? parent : parent.parent
6
- opts = {:attribute => attr_s, :equal => str}
14
+ opts = {:attribute => attr_s, :equal => str, :comparison => comparison}
7
15
  options = parent.respond_to?(:options) ? parent.options.merge!(opts) : opts
8
16
  # @c = PoolParty::Resources::Conditional.new(options, parent, &block)
9
17
  parent.add_resource(:conditional, options, parent, &block)
@@ -13,7 +21,7 @@ module PoolParty
13
21
  class Conditional < Resource
14
22
 
15
23
  def initialize(opts={}, parent=self, &block)
16
- name "#{opts[:name] ? opts[:name] : opts[:attribute]} == #{opts[:equal]}"
24
+ name "#{opts[:name] ? opts[:name] : opts[:attribute]} #{opts[:comparison]} #{opts[:equal]}"
17
25
  attribute opts[:attribute]
18
26
  equal opts[:equal]
19
27
  super
@@ -25,6 +33,10 @@ module PoolParty
25
33
  true
26
34
  end
27
35
 
36
+ def disallowed_options
37
+ [:comparison]
38
+ end
39
+
28
40
  def printable?
29
41
  false
30
42
  end
@@ -10,18 +10,23 @@ module PoolParty
10
10
  # TODO: Add it so that it tries to pull the gem off the master fileserver first...
11
11
  def loaded(opts={}, parent=self)
12
12
  if download_url
13
+
14
+ execute_on_master do
15
+ has_exec(:name => "download-#{name}", :cwd => Base.remote_storage_path, :command => "wget #{download_url} -O #{name}.gem", :ifnot => "test -f #{Base.remote_storage_path}/#{name}.gem")
16
+ end
13
17
 
14
- has_file(:name => "#{Base.remote_storage_path}/#{name}.gem", :source => "#{Base.fileserver_base}/#{name}.gem")
15
-
16
- execute_if("$hostname", "master") do
17
- has_exec(:name => "download-#{name}", :cwd => Base.remote_storage_path, :command => "wget #{download_url} -O #{name}.gem", :ifnot => "test -f #{Base.remote_storage_path}/#{name}.gem", :notify => get_file("#{Base.remote_storage_path}/#{name}.gem"))
18
- end
19
-
20
- has_exec(opts.merge({:name => "#{name}", :cwd =>"#{Base.remote_storage_path}", :path => "/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/var/lib/gems/1.8/bin"})) do
18
+ has_file({
19
+ :name => "#{Base.remote_storage_path}/#{name}.gem",
20
+ :source => "#{Base.fileserver_base}/#{name}.gem",
21
+ :requires => get_host("master")
22
+ })
23
+
24
+ has_exec(opts.merge({:name => "#{name}", :cwd =>"#{Base.remote_storage_path}"})) do
21
25
  command "gem install -y --no-ri --no-rdoc #{Base.remote_storage_path}/#{name}.gem"
22
26
  ifnot "gem list --local #{name} | grep #{name} #{"| grep #{version}" if version}"
23
27
  requires get_file("#{Base.remote_storage_path}/#{name}.gem")
24
28
  end
29
+
25
30
  else
26
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
27
32
  command "gem install -y --no-ri --no-rdoc #{"--version #{version}" if version} #{"--source #{source}" if source} #{name} <<heredoc
@@ -5,4 +5,4 @@ ps aux | grep puppetmaster | awk '{print $2}' | xargs kill
5
5
  /etc/init.d/puppetmaster stop
6
6
  rm -rf /etc/puppet/ssl
7
7
  puppetmasterd --verbose
8
- /etc/init.d/puppetmaster start
8
+ /etc/init.d/puppetmaster start
@@ -2,7 +2,7 @@ module PoolParty
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
- TINY = 37
5
+ TINY = 38
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -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.37
4
+ version: 0.2.38
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-10-31 00:00:00 -07:00
12
+ date: 2008-11-01 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -85,6 +85,7 @@ executables:
85
85
  - server-list-active
86
86
  - server-list-responding
87
87
  - server-rerun
88
+ - server-show-stats
88
89
  - server-start-master
89
90
  - server-start-node
90
91
  extensions: []
@@ -133,6 +134,7 @@ files:
133
134
  - bin/server-list-active
134
135
  - bin/server-list-responding
135
136
  - bin/server-rerun
137
+ - bin/server-show-stats
136
138
  - bin/server-start-master
137
139
  - bin/server-start-node
138
140
  - config/hoe.rb
@@ -9,7 +9,7 @@ describe "Conditional" do
9
9
  describe "wrapped" do
10
10
  before(:each) do
11
11
  @cloud = cloud :conditional_cloud_spec do
12
- execute_if("$hostname", "'master'", self) do
12
+ execute_if("$hostname", "==", "'master'", self) do
13
13
  has_file({:name => "/etc/apache2/puppetmaster2.conf"})
14
14
  end
15
15
  end
@@ -25,7 +25,7 @@ describe "Conditional" do
25
25
  @cond.resources.size.should == 1
26
26
  end
27
27
  it "should have a file resource on the conditional" do
28
- @cond.get_resource(:file, "/etc/apache2/puppetmaster2.conf").name.should == "/etc/apache2/puppetmaster2.conf"
28
+ @cond.get_file("/etc/apache2/puppetmaster2.conf").name.should == "/etc/apache2/puppetmaster2.conf"
29
29
  end
30
30
  it "should have the parent as the cloud" do
31
31
  @cond.parent.should == @cloud
@@ -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.37</a>
37
+ <a href="http://rubyforge.org/projects/poolparty" class="numbers">0.2.38</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.37
4
+ version: 0.2.38
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-10-31 00:00:00 -07:00
12
+ date: 2008-11-01 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -85,6 +85,7 @@ executables:
85
85
  - server-list-active
86
86
  - server-list-responding
87
87
  - server-rerun
88
+ - server-show-stats
88
89
  - server-start-master
89
90
  - server-start-node
90
91
  extensions: []
@@ -133,6 +134,7 @@ files:
133
134
  - bin/server-list-active
134
135
  - bin/server-list-responding
135
136
  - bin/server-rerun
137
+ - bin/server-show-stats
136
138
  - bin/server-start-master
137
139
  - bin/server-start-node
138
140
  - config/hoe.rb