auser-poolparty 1.1.7 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. data/History.txt +3 -0
  2. data/README.txt +10 -7
  3. data/Rakefile +0 -1
  4. data/VERSION.yml +2 -2
  5. data/bin/cloud-osxcopy +1 -1
  6. data/bin/cloud-setup-dev +1 -1
  7. data/bin/cloud-spec +0 -1
  8. data/bin/cloud-terminate +7 -1
  9. data/bin/cloud-verify +30 -0
  10. data/examples/basic.rb +3 -6
  11. data/examples/fairchild.rb +17 -21
  12. data/examples/maize.rb +37 -0
  13. data/lib/poolparty/base_packages/haproxy.rb +6 -6
  14. data/lib/poolparty/base_packages/heartbeat.rb +1 -43
  15. data/lib/poolparty/base_packages/poolparty.rb +1 -3
  16. data/lib/poolparty/modules/cloud_dsl.rb +10 -2
  17. data/lib/poolparty/modules/cloud_resourcer.rb +0 -4
  18. data/lib/poolparty/net/init.rb +1 -1
  19. data/lib/poolparty/net/remote_instance.rb +0 -27
  20. data/lib/poolparty/net/remoter/cloud_control.rb +0 -177
  21. data/lib/poolparty/net/remoter/interactive.rb +5 -16
  22. data/lib/poolparty/net/remoter_bases/ec2/ec2.rb +1 -10
  23. data/lib/poolparty/plugins/apache2.rb +53 -0
  24. data/lib/poolparty/plugins/deploy_directory.rb +16 -14
  25. data/lib/poolparty/plugins/gem_package.rb +24 -0
  26. data/lib/poolparty/plugins/line_in_file.rb +16 -0
  27. data/lib/poolparty/poolparty/plugin.rb +8 -6
  28. data/lib/poolparty/provision/dr_configure.rb +1 -0
  29. data/lib/poolparty/resources.rb +42 -0
  30. data/lib/poolparty/resources/cron.rb +30 -1
  31. data/lib/poolparty/resources/directory.rb +23 -0
  32. data/lib/poolparty/resources/exec.rb +22 -0
  33. data/lib/poolparty/resources/file.rb +28 -0
  34. data/lib/poolparty/resources/host.rb +22 -1
  35. data/lib/poolparty/resources/mount.rb +24 -0
  36. data/lib/poolparty/resources/package.rb +29 -13
  37. data/lib/poolparty/resources/remote_file.rb +32 -0
  38. data/lib/poolparty/resources/service.rb +20 -0
  39. data/lib/poolparty/resources/sshkey.rb +22 -0
  40. data/lib/poolparty/resources/symlink.rb +30 -0
  41. data/lib/poolparty/resources/variable.rb +25 -0
  42. data/lib/poolparty/templates/php.ini.erb +1253 -0
  43. data/lib/poolparty/verification/verifiers/ping.rb +5 -0
  44. data/lib/poolparty/verification/verify.rb +2 -0
  45. data/spec/bin/fixtures/bin_cloud_for_test.rb +0 -6
  46. data/spec/poolparty/dependency_resolver/chef_resolver_spec.rb +0 -6
  47. data/spec/poolparty/net/remoter_bases/ec2_remote_instance_spec.rb +0 -10
  48. data/spec/poolparty/spec_helper.rb +0 -1
  49. data/tasks/spec.rake +2 -0
  50. data/test/poolparty/dependency_resolver/puppet_resolver_test.rb +0 -10
  51. data/test/poolparty/verification/verify_test.rb +3 -3
  52. data/vendor/chef/apache2/attributes/apache.rb +1 -1
  53. data/vendor/gems/parenting/Manifest.txt +2 -1
  54. data/vendor/gems/parenting/lib/parenting.rb +1 -1
  55. data/vendor/gems/parenting/parenting.gemspec +2 -2
  56. metadata +8 -70
  57. data/bin/messenger-get-current-nodes +0 -14
  58. data/bin/server-become-master +0 -24
  59. data/bin/server-build-messenger +0 -28
  60. data/bin/server-clean-cert-for +0 -15
  61. data/bin/server-provision +0 -32
  62. data/bin/server-start-agent +0 -15
  63. data/bin/server-start-client +0 -29
  64. data/bin/server-start-master +0 -26
  65. data/bin/server-start-node +0 -32
  66. data/bin/server-stop-client +0 -3
  67. data/bin/server-stop-master +0 -3
  68. data/bin/server-stop-node +0 -3
  69. data/bin/server-update-hosts +0 -49
  70. data/lib/poolparty/capistrano.rb +0 -54
  71. data/lib/poolparty/capistrano/cloud_tasks.rb +0 -10
  72. data/lib/poolparty/config/postlaunchmessage.txt +0 -5
  73. data/lib/poolparty/net/messenger.rb +0 -57
  74. data/lib/poolparty/plugins/rsyncmirror.rb +0 -28
  75. data/lib/poolparty/services/conditional.rb +0 -46
  76. data/lib/poolparty/spec.rb +0 -31
  77. data/lib/poolparty/spec/core/string.rb +0 -18
  78. data/lib/poolparty/spec/matchers/a_spec_extensions_base.rb +0 -26
  79. data/lib/poolparty/spec/matchers/have_cron.rb +0 -28
  80. data/lib/poolparty/spec/matchers/have_deploydirectory.rb +0 -15
  81. data/lib/poolparty/spec/matchers/have_directory.rb +0 -31
  82. data/lib/poolparty/spec/matchers/have_exec.rb +0 -28
  83. data/lib/poolparty/spec/matchers/have_file.rb +0 -28
  84. data/lib/poolparty/spec/matchers/have_gempackage.rb +0 -28
  85. data/lib/poolparty/spec/matchers/have_git.rb +0 -28
  86. data/lib/poolparty/spec/matchers/have_host.rb +0 -28
  87. data/lib/poolparty/spec/matchers/have_mount.rb +0 -28
  88. data/lib/poolparty/spec/matchers/have_package.rb +0 -28
  89. data/lib/poolparty/spec/matchers/have_remotefile.rb +0 -28
  90. data/lib/poolparty/spec/matchers/have_rsyncmirror.rb +0 -28
  91. data/lib/poolparty/spec/matchers/have_service.rb +0 -28
  92. data/lib/poolparty/spec/matchers/have_sshkey.rb +0 -28
  93. data/lib/poolparty/spec/matchers/have_symlink.rb +0 -28
  94. data/lib/poolparty/spec/matchers/have_variable.rb +0 -32
  95. data/lib/poolparty/spec/spec/dynamic_matchers.rb +0 -63
  96. data/lib/poolparty/spec/spec/ensure_matchers_exist.rb +0 -7
  97. data/lib/poolparty/spec/templates/have_base.rb +0 -28
  98. data/spec/poolparty/net/messenger_spec.rb +0 -16
  99. data/spec/poolparty/services/conditional_spec.rb +0 -52
  100. data/spec/poolparty/spec/core/string_spec.rb +0 -57
@@ -1,28 +1,12 @@
1
1
  module PoolParty
2
2
  module Remote
3
3
 
4
- # #DEPRECATE We'll stub the ip to be the master ip for ease and accessibility
5
- # def ip(i=nil)
6
- # puts "DEPRECATED: ip will only be callable against a RemoteInstance in the next release."
7
- # i ? options[:ip] = i : (master ? master.ip : options[:ip])
8
- # end
9
- # #DEPRECATE: get the master instance
10
- def master
11
- puts "DEPRECATED: 'master' is deprecated and will be removed in the next major release."
12
- get_instance_by_number(0)
13
- end
14
-
15
4
  # Select a list of instances based on their status
16
5
  def nodes(hsh={})
17
6
  # _nodes[hsh] ||=
18
7
  list_of_instances.select_with_hash(hsh)
19
8
  end
20
9
 
21
- # Cache the instances_by_status here
22
- def _nodes
23
- @_nodes ||= {}
24
- end
25
-
26
10
  # Select the list of instances, either based on the neighborhoods
27
11
  # loaded from /etc/poolparty/neighborhood.json
28
12
  # or by the remote_base on keypair
@@ -34,6 +18,11 @@ module PoolParty
34
18
  end
35
19
 
36
20
  private
21
+ # Cache the instances_by_status here
22
+ def _nodes
23
+ @_nodes ||= {}
24
+ end
25
+
37
26
  # List the instances for the current key pair, regardless of their states
38
27
  # If no keypair is passed, select them all
39
28
  def _list_of_instances(select={})
@@ -74,6 +74,7 @@ module PoolParty
74
74
  return describe_instances.first if o[:instance_id].nil?
75
75
  describe_instances.detect {|a| a[:name] == o[:instance_id] || a[:ip] == o[:instance_id] || a[:instance_id] == o[:instance_id] }
76
76
  end
77
+ # TODO: Clean up this method and remove hostnames
77
78
  def describe_instances(o={})
78
79
  id = 0
79
80
  get_instances_description(options.merge(o)).each_with_index do |h,i|
@@ -137,16 +138,6 @@ module PoolParty
137
138
  associate_address(inst)
138
139
  end
139
140
  end
140
-
141
- # Attach a volume to the instance
142
- # DEPRECATE this relies on master. master will be removed in next major release. This method will be in ec2_remote_instance instead, or require an instance id
143
- def attach_volume(instance=nil)
144
- if ebs_volume_id
145
- vputs "Attaching volume #{ebs_volume_id} to the master at #{ebs_volume_device}"
146
- instance = master
147
- ec2.attach_volume(:volume_id => ebs_volume_id, :instance_id => instance.instance_id, :device => ebs_volume_device) if ebs_volume_id && ebs_volume_mount_point
148
- end
149
- end
150
141
 
151
142
  # Associate an address with the instance using ec2
152
143
  # Get the next_unused_elastic_ip
@@ -0,0 +1,53 @@
1
+ module PoolParty
2
+ class Base
3
+ plugin :apache do
4
+
5
+ # Called after the plugin is loaded entirely, all the options are set, etc.
6
+ def loaded(o={}, &block)
7
+ include_chef_recipe chef_apache2_recipe_root # We want to include the chef apache2 recipe to use it
8
+ end
9
+
10
+ def present_apache_module(*names)
11
+ names.each do |name|
12
+ has_chef_recipe "apache2::mod_" + name
13
+ end
14
+ end
15
+
16
+ private
17
+ def chef_apache2_recipe_root
18
+ "#{::File.dirname(__FILE__)}/../../../vendor/chef/apache2"
19
+ end
20
+
21
+ end
22
+
23
+
24
+ # Usage:°
25
+
26
+ # enable_php5 do
27
+ # extras :cli, :pspell, :mysql
28
+ # end
29
+ virtual_resource(:enable_php5) do
30
+ def loaded(opts={}, parent=self)
31
+ has_package("php5")
32
+ has_package("libapache2-mod-php5")
33
+ present_apache_module("php5")
34
+ has_file({:name => "/etc/php5/apache2/php.ini",
35
+ :template => File.dirname(__FILE__) + "/../templates/php.ini.erb",
36
+ :mode => 755,
37
+ :requires => get_package("libapache2-mod-php5")})
38
+ # :notify => get_exec("reload-apache2")})
39
+ end
40
+
41
+ def extras(*names)
42
+ names.each do |name|
43
+ # has_package(:name => "php5-#{name}", :requires => get_package("php5"))
44
+ has_package(:name => "php5-#{name}")
45
+ end
46
+ end
47
+
48
+ end
49
+
50
+
51
+ end
52
+
53
+ end
@@ -1,18 +1,22 @@
1
- =begin rdoc
2
- DeployDirectory
1
+ module PoolParty
2
+
3
+ =begin rdoc
4
+ == Deploy Directory
5
+
6
+ The deploy directory will copy the source directory from the developer machine (i.e. your laptop) to /tmp/poolparty, and then rsync it to the specified target directory on the cloud nodes.
7
+
8
+ == Usage
9
+
10
+ has_deploy_directory(has_deploy_directory 'bob',
11
+ :from => "~/path/to/my/site",
12
+ :to => "/mnt",
13
+ :owner => 'www-data'
14
+
15
+ This will place the contents of ~/path/to/my/site from your machine to /mnt/bob on the cloud instances virtual_resource(:deploy_directory)
3
16
 
4
- Deploy directory will rsync a local directory to
5
- each instance of your cloud.
6
-
7
- example:
8
- has_directory 'name', :from => '/local/path', :to => '/path/on/server/'
9
-
10
- The above example will place the contents of '/local/path' at '/path/on/server/name'
11
17
  =end
12
- module PoolParty
18
+
13
19
  class Deploydirectory
14
-
15
- virtual_resource(:deploy_directory) do
16
20
 
17
21
  def loaded(opts={}, &block)
18
22
  add_unpack_directory
@@ -40,8 +44,6 @@ module PoolParty
40
44
  end
41
45
 
42
46
  end
43
-
44
- end
45
47
 
46
48
  end
47
49
  end
@@ -4,6 +4,30 @@ module PoolParty
4
4
  # You can optionally pass a :download_url if you want a specific gem or version installed
5
5
  # example:
6
6
  # has_gem_package :name => 'rubot', :download_url => 'http://rubyforge.org/frs/download.php/35089/rubot-base-0.0.1.gem'
7
+
8
+ =begin rdoc
9
+ == Gempackage
10
+
11
+ Gempackages describe distributed gems on the cloud. The gem is only downloaded once and then hosted on the master if a download url is given.
12
+
13
+ == Usage
14
+
15
+ has_gempackage(:name => '...') do
16
+ # More options.
17
+ # This block is optional
18
+ end
19
+
20
+ == Options
21
+
22
+ * <tt>name</tt> The gem name
23
+ * <tt>download_url</tt> The location of the gem to download and server across the instances
24
+ * <tt>version</tt> The gem version requirement (optional and useless if download_url is given)
25
+ * <tt>source</tt> The gem source (optional and useless matter if download_url is given)
26
+
27
+ == Examples
28
+ has_gempackage(:name => 'rake',
29
+ :download_url => 'http://rubyforge.org/frs/download.php/43954/rake-0.8.3.gem')
30
+ =end
7
31
 
8
32
  class GempackageResource
9
33
 
@@ -1,4 +1,20 @@
1
1
  module PoolParty
2
+ =begin rdoc
3
+
4
+
5
+ == Line in File
6
+
7
+ Ensures that the line given is in the file
8
+
9
+ == Usage
10
+
11
+ has_line_in_file('line', '/full/file/path.ext')
12
+
13
+ == Examples
14
+
15
+ has_line_in_file("ENABLED=1", "/etc/default/haproxy")
16
+ =end
17
+
2
18
  class LineInFile
3
19
 
4
20
  virtual_resource(:line_in_file) do
@@ -8,22 +8,20 @@ module PoolParty
8
8
  include CloudResourcer
9
9
  include PoolParty::DependencyResolverCloudExtensions
10
10
  include PoolParty::Callbacks
11
-
12
- default_options({})
13
11
 
14
12
  def initialize(opts={}, prnt=nil, &block)
13
+ setup_callbacks
15
14
  before_load(opts, &block)
16
15
 
17
16
  block = Proc.new {enable} unless block
18
-
19
- @opts = opts
17
+
18
+ @opts = (opts.is_a?(Hash) ? opts : {:name => opts})
20
19
  super(opts, &block)
21
20
 
22
21
  run_in_context do
23
22
  loaded @opts, &block
24
23
  end
25
-
26
- setup_callbacks
24
+
27
25
  after_create
28
26
  end
29
27
 
@@ -41,6 +39,10 @@ module PoolParty
41
39
  def is_plugin?
42
40
  true
43
41
  end
42
+ def cloud
43
+ @parent
44
+ end
45
+
44
46
  def bootstrap_gems *gems
45
47
  gems.each do |g|
46
48
  Provision::BootStrapper.gem_list << g unless Provision::BootStrapper.gem_list.include?(g)
@@ -44,6 +44,7 @@ module PoolParty
44
44
  @cloud.call_before_configure_callbacks if @cloud
45
45
  prescribe_configuration
46
46
  execute!
47
+ @cloud.call_after_configure_callbacks if @cloud
47
48
  end
48
49
 
49
50
  private
@@ -0,0 +1,42 @@
1
+ module PoolParty
2
+ =begin rdoc
3
+
4
+ Resources are items that poolparty can make available in your clouds.
5
+ Resources are used in the <tt>clouds.rb</tt>, and in Plugins.
6
+ Plugins are collections of resources.
7
+
8
+ All of these resources can be defined as <tt>has_resource</tt> and <tt>does_not_have_resource</tt>:
9
+
10
+ * <tt>has_</tt>
11
+ example <tt>has_file(...)</tt>
12
+ * <tt>does_not_have_</tt>
13
+ For example: <tt>does_not_have_file(...)</tt>
14
+
15
+ == Resources
16
+
17
+
18
+ see PoolParty::Resources::File
19
+
20
+ * +has_file+ PoolParty::Resources::File
21
+ * +has_package+ PoolParty::Resources::Package
22
+ * +has_gempackage+ PoolParty::Resources::GempackageResource
23
+ * +has_exec+ PoolParty::Resources::Exec
24
+ * +has_variable+ (for templates) PoolParty::Resources::Variable
25
+ * +has_line_in_file+ PoolParty::Resources::LineInFile
26
+ * +has_remotefile+ PoolParty::Resources::Remotefile
27
+ * +hash_cron+ PoolParty::Resources::Cron
28
+ * +has_host+ PoolParty::Resources::Host
29
+ * +has_service+ PoolParty::Resources::Service
30
+ * +has_symlink+ PoolParty::Resources::Symlink
31
+ * +has_directory+ PoolParty::Resources::Directory
32
+ * +has_deploy_directory+ PoolParty::Resources::Deploydirectory
33
+ * +has_mount+ PoolParty::Resources::Mount
34
+
35
+ == Helper methods
36
+ * execute_if
37
+
38
+ =end
39
+
40
+ module Resources
41
+ end
42
+ end
@@ -1,6 +1,35 @@
1
1
  module PoolParty
2
2
  module Resources
3
-
3
+ =begin rdoc
4
+ == Cron
5
+
6
+ The cron resource will set cron jobs at the intervals you set
7
+
8
+ == Usage
9
+
10
+ has_cron(:name => '...') do
11
+ # More options.
12
+ # This block is optional
13
+ end
14
+
15
+ == Options
16
+
17
+ * <tt>name</tt> The name of the cronjob
18
+ * <tt>user</tt> The users who owns the cronjob
19
+ * <tt>command</tt> The cronjob command to run
20
+ * <tt>minute</tt> Set the minute of the cronjob
21
+ * <tt>hour</tt> Set the hour of the cronjob
22
+ * <tt>month</tt> Set the month of the cronjob
23
+ * <tt>monthday</tt> Set the day of the month of the cronjob
24
+ * <tt>weekday</tt> Set the weekday of the cronjob, in 0-6 format, where 0 is Sunday
25
+
26
+ == Example
27
+
28
+ has_cron(:name => "report mailer", :minute => "5", :hour => "0", :weekday => 1) do
29
+ command "/bin/sh /home/user/email_reports.sh"
30
+ end
31
+
32
+ =end
4
33
  class Cron < Resource
5
34
 
6
35
  default_options({
@@ -1,6 +1,29 @@
1
1
  module PoolParty
2
2
  module Resources
3
3
 
4
+ =begin rdoc rdoc
5
+ == Directory
6
+
7
+ The directory resource is used to describe a directory that should be present
8
+ on all of the instances.
9
+
10
+ == Usage
11
+
12
+ has_directory 'name', :from => '/local/path', :to => '/path/on/server/'
13
+
14
+ The above example will place the contents of '/local/path' at '/path/on/server/name'
15
+
16
+ has_directory(:name => '/etc/apache2')
17
+
18
+ == Options
19
+
20
+ * <tt>name</tt> Describe the location of the file with the name
21
+ * <tt>mode</tt> Describe the mode of the file (default: 644)
22
+ * <tt>owner</tt> The owner of the file (default: poolparty user)
23
+
24
+ =end
25
+
26
+
4
27
  class Directory < Resource
5
28
 
6
29
  def present
@@ -1,5 +1,27 @@
1
1
  module PoolParty
2
2
  module Resources
3
+ =begin rdoc rdoc
4
+ == Exec
5
+
6
+ Ensure a command is run on the instances
7
+
8
+ == Usage
9
+
10
+ has_exec(:name => '...') do
11
+ # More options.
12
+ # This block is optional
13
+ end
14
+
15
+ == Options
16
+
17
+ * <tt>name</tt> The name of your exec. This is optional, but nice for debugging purposes
18
+ * <tt>cwd</tt> Current working directory to execute the command (optional)
19
+ * <tt>command</tt> This describes the command to run
20
+ * <tt>path</tt> The path to run the command with (optional)
21
+
22
+ == Examples
23
+ has_exec(:name => 'start messenger', :command => 'server-start-node', :requires => get_gempackage('poolparty-latest', :onlyif => 'ps aux | grep beam | grep master')
24
+ =end
3
25
 
4
26
  class Exec < Resource
5
27
 
@@ -1,6 +1,34 @@
1
1
  module PoolParty
2
2
  module Resources
3
3
 
4
+ =begin rdoc rdoc
5
+ == File
6
+
7
+ The file resource is used to describe a file that should be present on all of the instances.
8
+
9
+ == Usage
10
+
11
+ has_file(:name => '...') do
12
+ # More options.
13
+ # This block is optional
14
+ end
15
+
16
+ == Options
17
+
18
+ * <tt>name</tt> Describe the location of the file with the name
19
+ * <tt>mode</tt> Describe the mode of the file (default: 644)
20
+ * <tt>owner</tt> The owner of the file (default: poolparty user)
21
+ * <tt>content</tt> The contents of the file
22
+ * <tt>source</tt> Used to describe a file that is hosted on the master instance.
23
+ * <tt>template</tt> The file contents are described with the template. The location given must be readable
24
+
25
+ To write a file to the template directory, use:
26
+
27
+ copy_template_to_storage_directory(filepath)
28
+
29
+ == Example
30
+ has_file(:name => '/etc/motd', :content => 'Hey and welcome to your node today!')
31
+ =end
4
32
  class File < Resource
5
33
 
6
34
  def loaded(o={}, &block)
@@ -1,6 +1,27 @@
1
1
  module PoolParty
2
2
  module Resources
3
-
3
+ =begin rdoc
4
+
5
+ == Host
6
+
7
+ The host parameter sets hosts on the instances. Setting this, every node will have the host.
8
+
9
+ == Usage
10
+
11
+ has_host(:name => '...') do
12
+ # More options.
13
+ # This block is optional
14
+ end
15
+
16
+ == Options
17
+
18
+ * <tt>name</tt>The name of the instance
19
+ * <tt>ip</tt> IP address of the instance for the host entry
20
+
21
+ == Examples
22
+
23
+ has_host({:name => "other_machine", :ip => 192.168.0.101 })
24
+ =end
4
25
  class Host < Resource
5
26
 
6
27
  default_options({