auser-poolparty 0.2.81 → 0.2.84

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. data/Capfile +1 -0
  2. data/Manifest.txt +13 -6
  3. data/PostInstall.txt +1 -1
  4. data/bin/cloud-configure +2 -1
  5. data/bin/cloud-handle-load +3 -3
  6. data/bin/cloud-maintain +2 -2
  7. data/bin/cloud-provision +4 -4
  8. data/bin/cloud-setup-dev +25 -0
  9. data/bin/cloud-start +1 -0
  10. data/bin/server-start-client +1 -1
  11. data/bin/server-start-master +1 -1
  12. data/bin/server-start-node +1 -1
  13. data/bin/server-write-new-nodes +26 -0
  14. data/lib/poolparty/capistrano.rb +18 -0
  15. data/lib/poolparty/exceptions/ProvisionerException.rb +5 -0
  16. data/lib/poolparty/helpers/optioner.rb +2 -1
  17. data/lib/poolparty/modules/cloud_resourcer.rb +17 -0
  18. data/lib/poolparty/modules/file_writer.rb +2 -2
  19. data/lib/poolparty/net/messenger.rb +1 -1
  20. data/lib/poolparty/net/remote_bases/ec2.rb +3 -2
  21. data/lib/poolparty/net/remoter.rb +12 -8
  22. data/lib/poolparty/plugins/git.rb +5 -1
  23. data/lib/poolparty/poolparty/cloud.rb +3 -1
  24. data/lib/poolparty/provisioners/capistrano/capistrano.rb +129 -0
  25. data/lib/poolparty/provisioners/capistrano/capistrano_configurer.rb +58 -0
  26. data/lib/poolparty/provisioners/capistrano/recipies/base.rb +100 -0
  27. data/lib/poolparty/provisioners/capistrano/recipies/master.rb +120 -0
  28. data/lib/poolparty/provisioners/capistrano/recipies/slave.rb +12 -0
  29. data/lib/poolparty/provisioners/provisioner_base.rb +98 -274
  30. data/lib/poolparty/templates/gem +12 -10
  31. data/lib/poolparty/version.rb +1 -1
  32. data/lib/poolparty.rb +5 -3
  33. data/poolparty.gemspec +18 -9
  34. data/spec/poolparty/helpers/optioner_spec.rb +1 -1
  35. data/spec/poolparty/net/remote_spec.rb +13 -14
  36. data/spec/poolparty/net/remoter_spec.rb +11 -11
  37. data/spec/poolparty/plugins/git_spec.rb +1 -1
  38. data/spec/poolparty/poolparty_spec.rb +1 -1
  39. data/spec/poolparty/provisioners/capistrano/capistrano_spec.rb +27 -0
  40. data/spec/poolparty/provisioners/provisioner_base_spec.rb +120 -0
  41. data/spec/poolparty/spec_helper.rb +15 -1
  42. data/website/index.html +1 -1
  43. metadata +18 -9
  44. data/lib/poolparty/provisioners/provisioners/become_master.rb +0 -166
  45. data/lib/poolparty/provisioners/provisioners/master.rb +0 -196
  46. data/lib/poolparty/provisioners/provisioners/slave.rb +0 -65
  47. data/spec/poolparty/helpers/provisioner_base_spec.rb +0 -137
  48. data/spec/poolparty/helpers/provisioners/master_spec.rb +0 -53
  49. data/spec/poolparty/helpers/provisioners/slave_spec.rb +0 -27
@@ -1,196 +0,0 @@
1
- module PoolParty
2
- module Provisioner
3
- class Master < ProvisionerBase
4
-
5
- def initialize(cl=self, os=:ubuntu)
6
- raise MasterException.new(:no_ip) unless cl.master && cl.master.ip
7
- super(cl.master, cl, os)
8
- @master_ip = cl.master.ip
9
- end
10
-
11
- def valid?
12
- !(@cloud.nil? || @cloud.master.nil?)
13
- end
14
-
15
- def error
16
- raise RemoteException.new(:could_not_install, "Your cloud does not have a master")
17
- end
18
-
19
- def first_install_tasks
20
- [
21
- create_local_hosts_entry
22
- ]
23
- end
24
-
25
- def install_tasks
26
- [
27
- setup_basic_structure,
28
- setup_configs,
29
- setup_fileserver,
30
- setup_autosigning,
31
- install_poolparty,
32
- restart_puppetmaster,
33
- run_first_time,
34
- create_local_node,
35
- ] << configure_tasks
36
- end
37
-
38
- def configure_tasks
39
- [
40
- create_local_node,
41
- move_templates,
42
- setup_poolparty,
43
- create_poolparty_manifest,
44
- restart_puppetd
45
- ]
46
- end
47
-
48
- # If the master is not in the hosts file, then add it to the hosts file
49
- def create_local_hosts_entry
50
- <<-EOS
51
- echo "Creating local host entry"
52
- if [ -z \"$(grep -v '#' /etc/hosts | grep 'puppet')" ]; then echo '#{@master_ip} master puppet localhost' >> /etc/hosts; fi
53
- hostname master
54
- EOS
55
- end
56
-
57
- def setup_basic_structure
58
- <<-EOS
59
- echo "Creating basic structure for poolparty"
60
- mkdir -p /etc/puppet/manifests/nodes
61
- mkdir -p /etc/puppet/manifests/classes
62
- echo "import 'nodes/*.pp'" > /etc/puppet/manifests/site.pp
63
- echo "import 'classes/*.pp'" >> /etc/puppet/manifests/site.pp
64
- cp #{Base.remote_storage_path}/namespaceauth.conf /etc/puppet/namespaceauth.conf
65
- EOS
66
- end
67
-
68
- def setup_configs
69
- <<-EOS
70
- echo "Setting up configuration"
71
- echo "#{open(File.join(template_directory, "puppet.conf")).read}" > /etc/puppet/puppet.conf
72
- EOS
73
- end
74
-
75
- def setup_fileserver
76
- <<-EOS
77
- echo "Setting up the master fileserver"
78
- echo "
79
- [files]
80
- path #{Base.remote_storage_path}
81
- allow *" > /etc/puppet/fileserver.conf
82
- mkdir -p /var/poolparty/facts
83
- mkdir -p /var/poolparty/files
84
- mkdir -p /etc/poolparty
85
- EOS
86
- end
87
- # Change this eventually for better security supportsetup_fileserver
88
- def setup_autosigning
89
- <<-EOS
90
- echo "Creating accessibility for the nodes"
91
- echo "*" > /etc/puppet/autosign.conf
92
- EOS
93
- end
94
-
95
- def setup_poolparty
96
- <<-EOS
97
- echo "Setting the poolparty configuration"
98
- cp #{Base.remote_storage_path}/#{Base.key_file_locations.first} "#{Base.base_config_directory}/.ppkeys"
99
- mv #{Base.remote_storage_path}/#{Base.default_specfile_name} #{Base.base_config_directory}/
100
- EOS
101
- end
102
-
103
- def copy_ssh_app
104
- "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}"
105
- end
106
-
107
- def install_poolparty
108
- <<-EOE
109
- echo "Installing poolparty"
110
- cd /var/poolparty
111
- wget http://rubyforge.org/frs/download.php/44731/logging-0.9.4.gem -O logging.gem 2>&1
112
- wget http://rubyforge.org/frs/download.php/45581/ZenTest-3.11.0.gem -O ZenTest.gem 2>&1
113
- wget http://rubyforge.org/frs/download.php/45600/ParseTree-3.0.1.gem -O ParseTree.gem 2>&1
114
- wget http://rubyforge.org/frs/download.php/45587/ruby2ruby-1.2.0.gem -O ruby2ruby.gem 2>&1
115
- wget http://rubyforge.org/frs/download.php/45627/activesupport-2.1.2.gem -O activesupport.gem 2>&1
116
- wget http://rubyforge.org/frs/download.php/18366/xml-simple-1.0.11.gem -O xml-simple.gem 2>&1
117
- wget http://rubyforge.org/frs/download.php/45683/RubyInline-3.8.1.gem -O RubyInline.gem 2>&1
118
- wget http://rubyforge.org/frs/download.php/42580/flexmock-0.8.3.gem -O flexmock.gem 2>&1
119
- wget http://rubyforge.org/frs/download.php/45685/hoe-1.8.2.gem -O hoe.gem 2>&1
120
- wget http://rubyforge.org/frs/download.php/18698/lockfile-1.4.3.gem -O lockfile.gem 2>&1
121
- wget http://rubyforge.org/frs/download.php/45546/rubyforge-1.0.1.gem -O rubyforge.gem 2>&1
122
- wget http://rubyforge.org/frs/download.php/43954/rake-0.8.3.gem -O rake.gem 2>&1
123
- wget http://rubyforge.org/frs/download.php/45589/sexp_processor-3.0.0.gem -O sexp_processor.gem 2>&1
124
- wget http://github.com/auser/poolparty/tree/master%2Fpkg%2Fpoolparty.gem?raw=true -O poolparty.gem 2>&1
125
- # wget http://rubyforge.org/frs/download.php/43666/amazon-ec2-0.3.1.gem -O amazon-ec2.gem 2>&1
126
-
127
- #{
128
- %w(rake lockfile rubyforge hoe ZenTest sexp_processor flexmock logging activesupport
129
- RubyInline ParseTree ruby2ruby xml-simple poolparty).map do |dep|
130
- "/usr/bin/gem install --ignore-dependencies -y --no-ri --no-rdoc #{dep}.gem #{unix_hide_string}"
131
- end.join("\n")
132
- }
133
- EOE
134
- end
135
-
136
- # /etc/init.d/puppetmaster stop; rm -rf /etc/puppet/ssl; /etc/init.d/puppetmaster start
137
- # ps aux | grep puppetmaster | grep -v grep | awk '{print $2}' | xargs kill;
138
- def restart_puppetmaster
139
- <<-EOS
140
- echo "(Re)starting poolparty"
141
- . /etc/profile
142
- /etc/init.d/puppetmaster stop;rm -rf /etc/poolparty/ssl;puppetmasterd --verbose;/etc/init.d/puppetmaster start
143
- EOS
144
- end
145
-
146
- def run_first_time
147
- <<-EOE
148
- echo "Running first time run"
149
- cp #{Base.remote_storage_path}/#{Base.template_directory}/puppetrunner /usr/bin/puppetrunner
150
- chmod +x /usr/bin/puppetrunner
151
- EOE
152
- end
153
-
154
- # TODO:
155
- # Consider this method in the manifest
156
- def create_local_node
157
- str = <<-EOS
158
- node default {
159
- include poolparty
160
- }
161
- EOS
162
- @cloud.list_of_running_instances.each do |ri|
163
- str << <<-EOS
164
- node "#{ri.name}" inherits default {}
165
- EOS
166
- end
167
- "echo '#{str}' > #{Base.manifest_path}/nodes/nodes.pp"
168
- end
169
-
170
- def move_templates
171
- <<-EOS
172
- echo "Moving templates into place"
173
- mkdir -p #{Base.template_path}
174
- cp -R #{Base.remote_storage_path}/#{Base.template_directory}/* #{Base.template_path}
175
- EOS
176
- end
177
-
178
- def create_poolparty_manifest
179
- <<-EOS
180
- echo "Creating the manifest"
181
- cp #{Base.remote_storage_path}/poolparty.pp /etc/puppet/manifests/classes/poolparty.pp
182
- #{copy_ssh_app}
183
- EOS
184
- end
185
-
186
- def restart_puppetd
187
- # /usr/bin/puppetrerun
188
- # /usr/bin/puppetcleaner master
189
- <<-EOS
190
- echo "Running puppet manifest"
191
- /usr/bin/puppetrerun
192
- EOS
193
- end
194
- end
195
- end
196
- end
@@ -1,65 +0,0 @@
1
- module PoolParty
2
- module Provisioner
3
- class Slave < ProvisionerBase
4
-
5
- def install_tasks
6
- [
7
- setup_poolparty,
8
- setup_puppet,
9
- setup_configs,
10
- ] << configure_tasks
11
- end
12
-
13
- def configure_tasks
14
- [
15
- start_puppet
16
- ]
17
- end
18
-
19
- def setup_poolparty
20
- <<-EOE
21
- echo "Running first time run"
22
- cp #{Base.remote_storage_path}/#{Base.template_directory}/puppetrunner /usr/bin/puppetrunner
23
- chmod +x /usr/bin/puppetrunner
24
- EOE
25
- end
26
-
27
- def setup_puppet
28
- <<-EOE
29
- if [ -z "$(grep -v '#' /etc/hosts | grep 'master')" ]; then echo "#{master_ip} puppet master" >> /etc/hosts; else echo "host already set"; fi
30
- cp #{Base.remote_storage_path}/namespaceauth.conf /etc/puppet/namespaceauth.conf
31
- EOE
32
- end
33
-
34
- def setup_configs
35
- <<-EOS
36
- echo "#{open(File.join(template_directory, "puppet.conf")).read}" > /etc/puppet/puppet.conf
37
- /etc/init.d/puppetmaster stop #{unix_hide_string}
38
- mkdir -p #{Base.base_config_directory}
39
- # rm -rf /etc/puppet/ssl
40
- # /usr/bin/puppetrerun
41
- EOS
42
- end
43
-
44
- # /etc/init.d/puppetmasterd stop
45
- # puppetd --listen --fqdn #{@instance.name}
46
- def start_puppet
47
- <<-EOS
48
- /bin/sh /usr/bin/puppetrunner
49
- EOS
50
- end
51
-
52
- def last_install_tasks
53
- [
54
- "rm -rf /etc/puppet/ssl",
55
- "/usr/bin/puppetrerun"
56
- ]
57
- end
58
-
59
- def master_ip
60
- @cloud.master.ip
61
- end
62
-
63
- end
64
- end
65
- end
@@ -1,137 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
2
-
3
- include Provisioner
4
-
5
- describe "ProvisionerBase" do
6
- before(:each) do
7
- @cloud = cloud :app do;end
8
- @remote_instance = PoolParty::Remote::RemoteInstance.new({:ip => "192.168.0.1", :status => "running", :name => "master"}, @cloud)
9
- @cloud.stub!(:custom_install_tasks_for).with(@remote_instance).and_return []
10
- stub_list_from_remote_for(@remote_instance)
11
- stub_list_from_remote_for(@cloud)
12
- end
13
- describe "class methods" do
14
- it "should have install" do
15
- ProvisionerBase.respond_to?(:install).should == true
16
- end
17
- it "should have configure" do
18
- ProvisionerBase.respond_to?(:configure).should == true
19
- end
20
- end
21
- describe "tasks" do
22
- before(:each) do
23
- class Provisioner::TestProvisioner < Provisioner::ProvisionerBase
24
- def tasks
25
- [
26
- "hello",
27
- " ",
28
- "world"
29
- ]
30
- end
31
- end
32
- @tp = TestProvisioner.new(@remote_instance,@cloud)
33
- end
34
- it "should have tasks on the provisioner" do
35
- ProvisionerBase.new(@remote_instance,@cloud).install_tasks.class.should == Array
36
- end
37
- it "should have empty tasks on the provisioner" do
38
- ProvisionerBase.new(@remote_instance,@cloud).install_tasks.should be_empty
39
- end
40
- it "should allow a new class to write tasks that aren't empty upon instantiation" do
41
- @tp.tasks.should_not be_empty
42
- end
43
- it "should have described 3 tasks in the task_list" do
44
- @tp.tasks.size.should == 3
45
- end
46
- end
47
- it "should return a hash when asking for the installers" do
48
- ProvisionerBase.installers.class.should == Hash
49
- end
50
- it "should not return an empty string when asking for the Ubuntu installer" do
51
- ProvisionerBase.installers[:ubuntu].should_not be_nil
52
- end
53
- it "should be able to fetch the ubuntu installer with the helper method installer" do
54
- ProvisionerBase.new(@remote_instance,@cloud, "ubuntu").installer_for.should == "aptitude install -y "
55
- end
56
- it "should be able to fetch the fedora installer with the helper method installer" do
57
- ProvisionerBase.new(@remote_instance,@cloud, "fedora").installer_for.should == "yum install "
58
- end
59
- describe "install_string" do
60
- before(:each) do
61
- class Provisioner::BTestProvisioner < Provisioner::ProvisionerBase
62
- def install_tasks
63
- [
64
- "hello",
65
- insert_space,
66
- add_world
67
- ]
68
- end
69
- def insert_space
70
- " "
71
- end
72
- def add_world
73
- "cruel world"
74
- end
75
- def default_install_tasks
76
- [] << install_tasks << custom_install_tasks
77
- end
78
- end
79
- @provisioner = BTestProvisioner.new(@remote_instance, @cloud)
80
- end
81
- it "should not run \"hello\"" do
82
- @provisioner.should_not_receive(:hello)
83
- end
84
- it "should run insert_space" do
85
- @provisioner.should_receive(:insert_space).once.and_return " "
86
- end
87
- it "should run add_world" do
88
- @provisioner.should_receive(:insert_space).once.and_return "world"
89
- end
90
- it "should compound the string to be hello \n \n cruel world" do
91
- @provisioner.install_string.should == "hello \n \n cruel world"
92
- end
93
- it "should call the last_install_tasks last" do
94
- @provisioner.should_receive(:last_install_tasks).at_least(1).and_return ["pops"]
95
- end
96
- it "should append the last_install_tasks to the end" do
97
- @provisioner.stub!(:last_install_tasks).and_return ["pops"]
98
- @provisioner.install_string.should == "hello \n \n cruel world \n pops"
99
- end
100
- it "should append the custom_install_tasks_for from the cloud" do
101
- @cloud.stub!(:custom_install_tasks_for).and_return ["echo 'hi from custom'"]
102
- @provisioner.install_string.should =~ /echo 'hi from custom'/
103
- end
104
- after do
105
- @provisioner.install_string
106
- end
107
- describe "processing" do
108
- before(:each) do
109
- @provisioner = ProvisionerBase.new(@remote_instance, @cloud)
110
- stub_list_from_remote_for(@cloud)
111
- @cloud.stub!(:keypair).and_return "fake_keypair"
112
- @cloud.stub!(:keypair_path).and_return "~/.ec2/fake_keypair"
113
- @cloud.stub!(:other_clouds).and_return []
114
- @cloud.stub!(:expand_when).and_return "cpu > 10"
115
- @cloud.stub!(:copy_file_to_storage_directory).and_return true
116
- @cloud.stub!(:rsync_storage_files_to).and_return true
117
- @cloud.stub!(:minimum_runnable_options).and_return []
118
- Provisioner::Master.stub!(:new).and_return @provisioner
119
- @provisioner.stub!(:build_and_store_new_config_file).and_return true
120
- @provisioner.stub!(:process_clean_reconfigure_for!).and_return true
121
- end
122
- describe "provision_master" do
123
- it "should call write_install_file" do
124
- @provisioner.should_receive(:write_install_file).and_return(true)
125
- end
126
- it "should call process_install!" do
127
- @provisioner.should_receive(:process_install!).and_return(true)
128
- end
129
- after(:each) do
130
- hide_output {
131
- Provisioner.provision_master(@cloud, true)
132
- }
133
- end
134
- end
135
- end
136
- end
137
- end
@@ -1,53 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper'
2
-
3
- include Provisioner
4
-
5
- describe "Master provisioner" do
6
- before(:each) do
7
- @cloud = cloud :app do; end
8
- stub_list_from_remote_for(@cloud)
9
- @remote_instance = PoolParty::Remote::RemoteInstance.new({:ip => "192.168.0.1", :status => "running", :name => "master"}, @cloud)
10
-
11
- @cloud.stub!(:master).and_return sample_instances.first
12
- @master = Master.new(@cloud, :ubuntu)
13
- end
14
- describe "install_tasks" do
15
- before(:each) do
16
- @cloud.stub!(:master).and_return sample_instances.first
17
- @master.stub!(:cloud).and_return @cloud
18
- end
19
- it "should call install_puppet_master" do
20
- @master.should_receive(:install_puppet)
21
- end
22
- it "should call create_local_hosts_entry" do
23
- @master.should_receive(:create_local_hosts_entry)
24
- end
25
- it "should call setup_fileserver" do
26
- @master.should_receive(:setup_fileserver)
27
- end
28
- it "should call create_local_node" do
29
- @master.should_receive(:create_local_node).twice
30
- end
31
- it "should call the custom_install_tasks" do
32
- @master.should_receive(:custom_install_tasks)
33
- end
34
- after do
35
- @master.install
36
- end
37
- end
38
- it "should return install_puppet_master as apt-get install puppet factor" do
39
- @master.install_puppet.should =~ /install -y puppet puppetmaster/
40
- end
41
- it "should return setup basic structure and set classes into the manifest" do
42
- @master.setup_basic_structure.should =~ /echo "import 'classes\/\*\.pp'" >> \/etc\/puppet\/manifests\/site\.pp/
43
- end
44
- it "should return setup_fileserver with the setup" do
45
- @master.setup_fileserver.should =~ /\[files\]/
46
- end
47
- it "should be able to create_local_node" do
48
- @master.create_local_node.should =~ /ode \"master\"/
49
- end
50
- it "should create a node1 node as well" do
51
- @master.create_local_node.should =~ /ode \"node1\"/
52
- end
53
- end
@@ -1,27 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper'
2
-
3
- include Provisioner
4
-
5
- describe "Slave provisioner" do
6
- before(:each) do
7
-
8
- @cloud = cloud :app do; end
9
- @remote_instance = PoolParty::Remote::RemoteInstance.new({:ip => "192.168.0.1", :status => "running", :name => "master"}, @cloud)
10
- stub_list_from_remote_for(@cloud)
11
-
12
- @cloud.stub!(:master).and_return sample_instances.first
13
-
14
- @slave = Slave.new(@remote_instance, @cloud, :ubuntu)
15
- end
16
- describe "install_tasks" do
17
- it "should call install_puppet_slave" do
18
- @slave.should_receive(:install_puppet)
19
- end
20
- after do
21
- @slave.install
22
- end
23
- end
24
- it "should return setup_puppet with the master" do
25
- @slave.setup_puppet.should =~ /master/
26
- end
27
- end