auser-poolparty 0.2.60 → 0.2.61
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.
- data/Manifest.txt +2 -0
 - data/README.txt +2 -0
 - data/bin/cloud-ensure-provisioning +8 -2
 - data/bin/cloud-provision +1 -0
 - data/bin/pool-list +10 -2
 - data/bin/server-send-command +18 -0
 - data/bin/server-update-hosts +47 -0
 - data/lib/poolparty.rb +1 -1
 - data/lib/poolparty/aska/aska.rb +1 -1
 - data/lib/poolparty/base_packages/haproxy.rb +2 -2
 - data/lib/poolparty/base_packages/poolparty.rb +14 -19
 - data/lib/poolparty/core/object.rb +7 -4
 - data/lib/poolparty/helpers/console.rb +4 -0
 - data/lib/poolparty/helpers/optioner.rb +3 -0
 - data/lib/poolparty/helpers/provisioners/master.rb +18 -15
 - data/lib/poolparty/helpers/provisioners/slave.rb +2 -1
 - data/lib/poolparty/modules/cloud_resourcer.rb +27 -8
 - data/lib/poolparty/modules/method_missing_sugar.rb +1 -1
 - data/lib/poolparty/net/remote.rb +3 -0
 - data/lib/poolparty/net/remote_bases/ec2.rb +6 -3
 - data/lib/poolparty/net/remote_instance.rb +9 -3
 - data/lib/poolparty/net/remoter.rb +8 -39
 - data/lib/poolparty/net/remoter_base.rb +4 -9
 - data/lib/poolparty/pool/base.rb +4 -3
 - data/lib/poolparty/pool/cloud.rb +19 -23
 - data/lib/poolparty/pool/plugin.rb +3 -27
 - data/lib/poolparty/pool/plugin_model.rb +6 -8
 - data/lib/poolparty/pool/pool.rb +15 -4
 - data/lib/poolparty/pool/resource.rb +5 -10
 - data/lib/poolparty/pool/resources/class_package.rb +6 -4
 - data/lib/poolparty/pool/resources/conditional.rb +2 -3
 - data/lib/poolparty/templates/puppetrerun +1 -13
 - data/lib/poolparty/templates/puppetrunner +1 -12
 - data/lib/poolparty/version.rb +1 -1
 - data/poolparty.gemspec +6 -2
 - data/spec/poolparty/aska/aska_spec.rb +0 -8
 - data/spec/poolparty/helpers/provisioner_base_spec.rb +2 -0
 - data/spec/poolparty/modules/cloud_resourcer_spec.rb +2 -2
 - data/spec/poolparty/net/remoter_spec.rb +0 -106
 - data/spec/poolparty/pool/base_spec.rb +0 -3
 - data/spec/poolparty/pool/cloud_spec.rb +10 -19
 - data/spec/poolparty/pool/plugin_spec.rb +2 -2
 - data/spec/poolparty/pool/pool_spec.rb +16 -1
 - data/spec/poolparty/pool/resource_spec.rb +1 -1
 - metadata +6 -2
 
    
        data/Manifest.txt
    CHANGED
    
    | 
         @@ -35,6 +35,7 @@ bin/server-get-load 
     | 
|
| 
       35 
35 
     | 
    
         
             
            bin/server-list-active
         
     | 
| 
       36 
36 
     | 
    
         
             
            bin/server-list-responding
         
     | 
| 
       37 
37 
     | 
    
         
             
            bin/server-rerun
         
     | 
| 
      
 38 
     | 
    
         
            +
            bin/server-send-command
         
     | 
| 
       38 
39 
     | 
    
         
             
            bin/server-show-stats
         
     | 
| 
       39 
40 
     | 
    
         
             
            bin/server-start-client
         
     | 
| 
       40 
41 
     | 
    
         
             
            bin/server-start-master
         
     | 
| 
         @@ -42,6 +43,7 @@ bin/server-start-node 
     | 
|
| 
       42 
43 
     | 
    
         
             
            bin/server-stop-client
         
     | 
| 
       43 
44 
     | 
    
         
             
            bin/server-stop-master
         
     | 
| 
       44 
45 
     | 
    
         
             
            bin/server-stop-node
         
     | 
| 
      
 46 
     | 
    
         
            +
            bin/server-update-hosts
         
     | 
| 
       45 
47 
     | 
    
         
             
            config/hoe.rb
         
     | 
| 
       46 
48 
     | 
    
         
             
            config/requirements.rb
         
     | 
| 
       47 
49 
     | 
    
         
             
            examples/basic.rb
         
     | 
    
        data/README.txt
    CHANGED
    
    
| 
         @@ -23,9 +23,15 @@ o.loaded_clouds.each do |cloud| 
     | 
|
| 
       23 
23 
     | 
    
         
             
                    s << "/usr/sbin/puppetca --clean #{node}.compute-1.internal"
         
     | 
| 
       24 
24 
     | 
    
         
             
                    s << "/usr/sbin/puppetca --clean #{node}.ec2.internal"
         
     | 
| 
       25 
25 
     | 
    
         
             
                  end.join(";")
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
      
 26 
     | 
    
         
            +
              
         
     | 
| 
      
 27 
     | 
    
         
            +
                  node_id = node.gsub(/node/, '')
         
     | 
| 
      
 28 
     | 
    
         
            +
                  
         
     | 
| 
      
 29 
     | 
    
         
            +
                  cmd = ". /etc/profile && #{str};cloud-provision -i #{node_id};#{str}"
         
     | 
| 
      
 30 
     | 
    
         
            +
                  running_cmd = "ps aux | grep -v grep | grep \"cloud-provision -i #{node_id}\""
         
     | 
| 
      
 31 
     | 
    
         
            +
                  
         
     | 
| 
       27 
32 
     | 
    
         
             
                  vputs "Executing #{cmd}"
         
     | 
| 
       28 
     | 
    
         
            -
                   
     | 
| 
      
 33 
     | 
    
         
            +
                  running = %x[#{running_cmd}]
         
     | 
| 
      
 34 
     | 
    
         
            +
                  `#{cmd}` if running.chomp.empty?
         
     | 
| 
       29 
35 
     | 
    
         
             
                end
         
     | 
| 
       30 
36 
     | 
    
         
             
                # @tp.join
         
     | 
| 
       31 
37 
     | 
    
         
             
              end  
         
     | 
    
        data/bin/cloud-provision
    CHANGED
    
    | 
         @@ -4,6 +4,7 @@ require "poolparty" 
     | 
|
| 
       4 
4 
     | 
    
         
             
            require "poolpartycl"
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
            o = PoolParty::Optioner.new(ARGV) do |opts, optioner|
         
     | 
| 
      
 7 
     | 
    
         
            +
              opts.on('-n cloudname', '--name name', 'Start cloud by this name')    { |c| optioner.cloudname c }
         
     | 
| 
       7 
8 
     | 
    
         
             
              opts.on('-p', '--slave', 'Provision slave (default: false)')    { optioner.provision_slave true }
         
     | 
| 
       8 
9 
     | 
    
         
             
              opts.on('-i num', '--id num', 'Instance num to provision')    { |i| optioner.instance_number i }
         
     | 
| 
       9 
10 
     | 
    
         
             
            end
         
     | 
    
        data/bin/pool-list
    CHANGED
    
    | 
         @@ -15,8 +15,16 @@ o.loaded_pools.each do |pool| 
     | 
|
| 
       15 
15 
     | 
    
         
             
                puts header("Listing pool #{name}")
         
     | 
| 
       16 
16 
     | 
    
         
             
                clouds.each do |name, cloud|
         
     | 
| 
       17 
17 
     | 
    
         
             
                  puts subheader("Cloud: #{name}")
         
     | 
| 
       18 
     | 
    
         
            -
                   
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
      
 18 
     | 
    
         
            +
                  with_cloud(cloud) do
         
     | 
| 
      
 19 
     | 
    
         
            +
                    puts header("Listing cloud #{name}")
         
     | 
| 
      
 20 
     | 
    
         
            +
                    puts subheader("Active instances")
         
     | 
| 
      
 21 
     | 
    
         
            +
                    puts list_of_running_instances.map{|a| a.to_s}.join("\n")
         
     | 
| 
      
 22 
     | 
    
         
            +
                    puts ""
         
     | 
| 
      
 23 
     | 
    
         
            +
                    if list_of_pending_instances.size > 0
         
     | 
| 
      
 24 
     | 
    
         
            +
                      puts subheader("Pending instances")
         
     | 
| 
      
 25 
     | 
    
         
            +
                      puts list_of_pending_instances.map{|a| a.to_s}.join("\n")
         
     | 
| 
      
 26 
     | 
    
         
            +
                    end
         
     | 
| 
      
 27 
     | 
    
         
            +
                  end
         
     | 
| 
       20 
28 
     | 
    
         
             
                end
         
     | 
| 
       21 
29 
     | 
    
         
             
              end
         
     | 
| 
       22 
30 
     | 
    
         
             
            end
         
     | 
| 
         @@ -0,0 +1,18 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #!/usr/bin/env ruby
         
     | 
| 
      
 2 
     | 
    
         
            +
            $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
         
     | 
| 
      
 3 
     | 
    
         
            +
            require "poolparty"
         
     | 
| 
      
 4 
     | 
    
         
            +
            require "poolpartycl"
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            @command = ARGV[-1] || ""
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            o = PoolParty::Optioner.new(ARGV) do |opts, optioner|
         
     | 
| 
      
 9 
     | 
    
         
            +
              opts.on('-c command', '--command command', 'Command to run')    { |c| optioner.command c }
         
     | 
| 
      
 10 
     | 
    
         
            +
            end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            @command,@args = Arr.split(" ")[0], Arr.split(" ")[1..-1]
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            o.loaded_clouds do |cloud|
         
     | 
| 
      
 15 
     | 
    
         
            +
              with_cloud(cloud, {:command => @command, :command_args => @args}) do
         
     | 
| 
      
 16 
     | 
    
         
            +
                cloud.send command.to_sym, command_args
         
     | 
| 
      
 17 
     | 
    
         
            +
              end  
         
     | 
| 
      
 18 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,47 @@ 
     | 
|
| 
      
 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) do |opts, optioner|
         
     | 
| 
      
 7 
     | 
    
         
            +
              opts.on('-n name', '--name name', 'Update hosts for local pool named [name]')    { |p| optioner.poolname p }
         
     | 
| 
      
 8 
     | 
    
         
            +
            end
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            o.loaded_pools.each do |pool|
         
     | 
| 
      
 11 
     | 
    
         
            +
              with_pool(pool) do
         
     | 
| 
      
 12 
     | 
    
         
            +
                pool_clouds.each do |cl|
         
     | 
| 
      
 13 
     | 
    
         
            +
                  
         
     | 
| 
      
 14 
     | 
    
         
            +
                  new_hosts_listing = returning Array.new do |arr|
         
     | 
| 
      
 15 
     | 
    
         
            +
                    cl.list_of_running_instances.each do |ri|
         
     | 
| 
      
 16 
     | 
    
         
            +
                      vputs ri.hosts_file_listing_for(cl)
         
     | 
| 
      
 17 
     | 
    
         
            +
                      arr << ri.hosts_file_listing_for(cl)
         
     | 
| 
      
 18 
     | 
    
         
            +
                    end
         
     | 
| 
      
 19 
     | 
    
         
            +
                    cl.other_clouds.each do |other|
         
     | 
| 
      
 20 
     | 
    
         
            +
                      other.list_of_running_instances.each do |ri|
         
     | 
| 
      
 21 
     | 
    
         
            +
                        vputs ri.hosts_file_listing_for(cl)
         
     | 
| 
      
 22 
     | 
    
         
            +
                        arr << ri.hosts_file_listing_for(cl)
         
     | 
| 
      
 23 
     | 
    
         
            +
                      end
         
     | 
| 
      
 24 
     | 
    
         
            +
                    end
         
     | 
| 
      
 25 
     | 
    
         
            +
                  end.join("\n")
         
     | 
| 
      
 26 
     | 
    
         
            +
                  
         
     | 
| 
      
 27 
     | 
    
         
            +
                  if testing
         
     | 
| 
      
 28 
     | 
    
         
            +
                    puts new_hosts_listing
         
     | 
| 
      
 29 
     | 
    
         
            +
                  else
         
     | 
| 
      
 30 
     | 
    
         
            +
                    new_hosts_file = "#{Base.manifest_path}/classes/hosts.pp"
         
     | 
| 
      
 31 
     | 
    
         
            +
                    
         
     | 
| 
      
 32 
     | 
    
         
            +
                    arr = returning Array.new do |arr|
         
     | 
| 
      
 33 
     | 
    
         
            +
                      new_hosts_listing.split(/\n/).each do |line|
         
     | 
| 
      
 34 
     | 
    
         
            +
                        parts = line.split(/\t/).map {|a| a.chomp }
         
     | 
| 
      
 35 
     | 
    
         
            +
                        ip,hostname,aliases = parts[0], parts[1], parts[2..-1]
         
     | 
| 
      
 36 
     | 
    
         
            +
                        
         
     | 
| 
      
 37 
     | 
    
         
            +
                        arr << PoolParty::Resources::Host.new(:ip => ip, :name => Resolv::DNS.new.getaddress(hostname), :alias => aliases).to_string
         
     | 
| 
      
 38 
     | 
    
         
            +
                      end
         
     | 
| 
      
 39 
     | 
    
         
            +
                    end
         
     | 
| 
      
 40 
     | 
    
         
            +
                    
         
     | 
| 
      
 41 
     | 
    
         
            +
                    ::File.open(new_hosts_file, "w+") {|f| f << arr.join("\n") }
         
     | 
| 
      
 42 
     | 
    
         
            +
                  end
         
     | 
| 
      
 43 
     | 
    
         
            +
                  
         
     | 
| 
      
 44 
     | 
    
         
            +
                end
         
     | 
| 
      
 45 
     | 
    
         
            +
                
         
     | 
| 
      
 46 
     | 
    
         
            +
              end
         
     | 
| 
      
 47 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/poolparty.rb
    CHANGED
    
    
    
        data/lib/poolparty/aska/aska.rb
    CHANGED
    
    
| 
         @@ -2,14 +2,14 @@ module PoolParty 
     | 
|
| 
       2 
2 
     | 
    
         
             
              class Base
         
     | 
| 
       3 
3 
     | 
    
         
             
                plugin :haproxy do
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
     | 
    
         
            -
                  def enable
         
     | 
| 
      
 5 
     | 
    
         
            +
                  def enable        
         
     | 
| 
       6 
6 
     | 
    
         
             
                    execute_on_master do
         
     | 
| 
       7 
7 
     | 
    
         
             
                      has_package({:name => "haproxy"})
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
9 
     | 
    
         
             
                      # Restart sysklogd after we update the haproxy.log
         
     | 
| 
       10 
10 
     | 
    
         
             
                      has_service(:name => "sysklogd")
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
                      # Template variables
         
     | 
| 
      
 12 
     | 
    
         
            +
                      # Template variables          
         
     | 
| 
       13 
13 
     | 
    
         
             
                      has_variable(:name => "name_haproxy", :value => "#{cloud.name}")
         
     | 
| 
       14 
14 
     | 
    
         
             
                      has_variable(:name => "nodenames_haproxy", :value => "generate('/usr/bin/env', '/usr/bin/server-list-active', '-c', 'name')")
         
     | 
| 
       15 
15 
     | 
    
         
             
                      has_variable(:name => "node_ips_haproxy",  :value => "generate('/usr/bin/env', '/usr/bin/server-list-active', '-c', 'ip')")
         
     | 
| 
         @@ -1,15 +1,9 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module PoolParty
         
     | 
| 
       2 
2 
     | 
    
         
             
              class Base
         
     | 
| 
       3 
     | 
    
         
            -
                plugin : 
     | 
| 
      
 3 
     | 
    
         
            +
                plugin :poolparty_base_packages do
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
                  def enable                
         
     | 
| 
       6 
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 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
                    # has_host({:name => "$hostname", :ip => "127.0.0.1", :alias => "localhost"})
         
     | 
| 
       13 
7 
     | 
    
         | 
| 
       14 
8 
     | 
    
         
             
                    has_package(:name => "erlang")
         
     | 
| 
       15 
9 
     | 
    
         
             
                    has_package(:name => "erlang-dev")
         
     | 
| 
         @@ -43,16 +37,22 @@ module PoolParty 
     | 
|
| 
       43 
37 
     | 
    
         
             
                      has_gempackage(:name => "poolparty", :download_url => "http://github.com/auser/poolparty/tree/master%2Fpkg%2Fpoolparty.gem?raw=true", :requires => [get_gempackage("ruby2ruby"), get_gempackage("RubyInline"), get_gempackage("ParseTree")])
         
     | 
| 
       44 
38 
     | 
    
         | 
| 
       45 
39 
     | 
    
         
             
                      # , :ifnot => "/bin/ps aux | /bin/grep -q pm_node"
         
     | 
| 
       46 
     | 
    
         
            -
                      has_exec(:name => "build_messenger", :command => ". /etc/profile && server-build-messenger 
     | 
| 
      
 40 
     | 
    
         
            +
                      has_exec(:name => "build_messenger", :command => ". /etc/profile && server-build-messenger")
         
     | 
| 
       47 
41 
     | 
    
         
             
                      has_exec(:name => "start_node", :command => ". /etc/profile && server-start-node")
         
     | 
| 
      
 42 
     | 
    
         
            +
                      has_exec(:name => "update_hosts", :command => ". /etc/profile && server-update-hosts")
         
     | 
| 
       48 
43 
     | 
    
         
             
                      # has_runit_service("pm_node", "pm_node", File.join(File.dirname(__FILE__), "..", "templates/messenger/node/"))
         
     | 
| 
       49 
44 
     | 
    
         
             
                    end
         
     | 
| 
       50 
45 
     | 
    
         | 
| 
       51 
46 
     | 
    
         
             
                    # execute_on_node do
         
     | 
| 
       52 
47 
     | 
    
         
             
                    has_cron(:name => "puppetd runner", :user => Base.user, :minute => "*/5") do
         
     | 
| 
       53 
48 
     | 
    
         
             
                      requires get_gempackage("poolparty")
         
     | 
| 
       54 
     | 
    
         
            -
                      command "/usr/bin/ 
     | 
| 
      
 49 
     | 
    
         
            +
                      command "/usr/bin/puppetrunner"
         
     | 
| 
      
 50 
     | 
    
         
            +
                    end
         
     | 
| 
      
 51 
     | 
    
         
            +
                    has_remotefile(:name => "/usr/bin/puppetrunner") do
         
     | 
| 
      
 52 
     | 
    
         
            +
                      mode 744
         
     | 
| 
      
 53 
     | 
    
         
            +
                      template File.join(File.dirname(__FILE__), "..", "templates/puppetrunner")
         
     | 
| 
       55 
54 
     | 
    
         
             
                    end
         
     | 
| 
      
 55 
     | 
    
         
            +
                    
         
     | 
| 
       56 
56 
     | 
    
         
             
                    # end
         
     | 
| 
       57 
57 
     | 
    
         | 
| 
       58 
58 
     | 
    
         
             
                    # Cloud panel setup
         
     | 
| 
         @@ -92,17 +92,12 @@ module PoolParty 
     | 
|
| 
       92 
92 
     | 
    
         
             
                        mode 744
         
     | 
| 
       93 
93 
     | 
    
         
             
                        template File.join(File.dirname(__FILE__), "..", "templates/puppetcleaner")
         
     | 
| 
       94 
94 
     | 
    
         
             
                      end
         
     | 
| 
      
 95 
     | 
    
         
            +
                      
         
     | 
| 
      
 96 
     | 
    
         
            +
                      has_remotefile(:name => "/usr/bin/puppetrerun") do
         
     | 
| 
      
 97 
     | 
    
         
            +
                        mode 744
         
     | 
| 
      
 98 
     | 
    
         
            +
                        template File.join(File.dirname(__FILE__), "..", "templates/puppetrerun")
         
     | 
| 
      
 99 
     | 
    
         
            +
                      end
         
     | 
| 
       95 
100 
     | 
    
         
             
                    end        
         
     | 
| 
       96 
     | 
    
         
            -
                    
         
     | 
| 
       97 
     | 
    
         
            -
                    has_remotefile(:name => "/usr/bin/puppetrerun") do
         
     | 
| 
       98 
     | 
    
         
            -
                      mode 744
         
     | 
| 
       99 
     | 
    
         
            -
                      template File.join(File.dirname(__FILE__), "..", "templates/puppetrerun")
         
     | 
| 
       100 
     | 
    
         
            -
                    end
         
     | 
| 
       101 
     | 
    
         
            -
                    has_remotefile(:name => "/usr/bin/puppetrunner") do
         
     | 
| 
       102 
     | 
    
         
            -
                      mode 744
         
     | 
| 
       103 
     | 
    
         
            -
                      template File.join(File.dirname(__FILE__), "..", "templates/puppetrunner")
         
     | 
| 
       104 
     | 
    
         
            -
                    end
         
     | 
| 
       105 
     | 
    
         
            -
                    
         
     | 
| 
       106 
101 
     | 
    
         
             
                    # has_host(:name => "puppet", :ip => (self.respond_to?(:master) ? self : parent).master.ip)
         
     | 
| 
       107 
102 
     | 
    
         
             
                  end
         
     | 
| 
       108 
103 
     | 
    
         | 
| 
         @@ -55,7 +55,7 @@ class Object 
     | 
|
| 
       55 
55 
     | 
    
         
             
                end
         
     | 
| 
       56 
56 
     | 
    
         
             
              end
         
     | 
| 
       57 
57 
     | 
    
         
             
              def block_instance_eval(*args, &block)
         
     | 
| 
       58 
     | 
    
         
            -
                return instance_eval(*args,&block) unless  
     | 
| 
      
 58 
     | 
    
         
            +
                return instance_eval(*args,&block) unless block && !block.arity.zero?
         
     | 
| 
       59 
59 
     | 
    
         
             
                old_method = (self.class.instance_method(:__) rescue nil)
         
     | 
| 
       60 
60 
     | 
    
         
             
                self.class.send(:define_method, :__, &block)
         
     | 
| 
       61 
61 
     | 
    
         
             
                block_method = self.class.instance_method(:__)
         
     | 
| 
         @@ -72,16 +72,19 @@ class Object 
     | 
|
| 
       72 
72 
     | 
    
         
             
              def meta_undef name
         
     | 
| 
       73 
73 
     | 
    
         
             
                meta_eval { remove_method name }
         
     | 
| 
       74 
74 
     | 
    
         
             
              end
         
     | 
| 
       75 
     | 
    
         
            -
              def run_in_context(&block)
         
     | 
| 
      
 75 
     | 
    
         
            +
              def run_in_context(context=self, &block)
         
     | 
| 
       76 
76 
     | 
    
         
             
                name="temp_#{self.class}_#{respond_to?(:parent) ? parent.to_s : Time.now.to_i}".to_sym
         
     | 
| 
       77 
77 
     | 
    
         
             
                meta_def name, &block
         
     | 
| 
       78 
     | 
    
         
            -
                self.send name,  
     | 
| 
      
 78 
     | 
    
         
            +
                self.send name, context
         
     | 
| 
       79 
79 
     | 
    
         
             
                # self.instance_eval &block if block
         
     | 
| 
       80 
     | 
    
         
            -
                meta_undef name
         
     | 
| 
      
 80 
     | 
    
         
            +
                meta_undef name rescue ""
         
     | 
| 
       81 
81 
     | 
    
         
             
              end
         
     | 
| 
       82 
82 
     | 
    
         
             
              def vputs(m="", o=self)
         
     | 
| 
       83 
83 
     | 
    
         
             
                puts m if o.verbose
         
     | 
| 
       84 
84 
     | 
    
         
             
              end
         
     | 
| 
      
 85 
     | 
    
         
            +
              def dputs(m="", o=self)
         
     | 
| 
      
 86 
     | 
    
         
            +
                vputs(">#{::File.basename(__FILE__)} (#{__LINE__}) #{m}", o)
         
     | 
| 
      
 87 
     | 
    
         
            +
              end
         
     | 
| 
       85 
88 
     | 
    
         
             
              def vprint(m="", o=self)
         
     | 
| 
       86 
89 
     | 
    
         
             
                print m if o.verbose
         
     | 
| 
       87 
90 
     | 
    
         
             
              end
         
     | 
| 
         @@ -20,6 +20,10 @@ module PoolParty 
     | 
|
| 
       20 
20 
     | 
    
         
             
                  o.cloudname ? [cloud(o.cloudname.downcase.to_sym)] : [clouds[clouds.keys.first]]
         
     | 
| 
       21 
21 
     | 
    
         
             
                end
         
     | 
| 
       22 
22 
     | 
    
         | 
| 
      
 23 
     | 
    
         
            +
                def extract_pool_from_options(o)
         
     | 
| 
      
 24 
     | 
    
         
            +
                  o.poolname ? [pool(o.poolname.downcase.to_sym)] : [pools[pools.keys.first]]
         
     | 
| 
      
 25 
     | 
    
         
            +
                end
         
     | 
| 
      
 26 
     | 
    
         
            +
                
         
     | 
| 
       23 
27 
     | 
    
         
             
                # Clear all the pools and reload the console
         
     | 
| 
       24 
28 
     | 
    
         
             
                # Call within console to reset and reload the entire poolparty base
         
     | 
| 
       25 
29 
     | 
    
         
             
                # as well
         
     | 
| 
         @@ -71,6 +71,9 @@ module PoolParty 
     | 
|
| 
       71 
71 
     | 
    
         | 
| 
       72 
72 
     | 
    
         
             
                    reject_junk_options!
         
     | 
| 
       73 
73 
     | 
    
         
             
                    raise CloudNotFoundException.new("Please specify your cloud with -s, move it to ./pool.spec or in your POOL_SPEC environment variable") unless loaded_clouds && !loaded_clouds.empty?
         
     | 
| 
      
 74 
     | 
    
         
            +
                    loaded_pools.each do |pl|
         
     | 
| 
      
 75 
     | 
    
         
            +
                      pl.configure(self.options)
         
     | 
| 
      
 76 
     | 
    
         
            +
                    end
         
     | 
| 
       74 
77 
     | 
    
         
             
                    loaded_clouds.each do |cl|
         
     | 
| 
       75 
78 
     | 
    
         
             
                      cl.configure(self.options)
         
     | 
| 
       76 
79 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -25,9 +25,9 @@ module PoolParty 
     | 
|
| 
       25 
25 
     | 
    
         
             
                      setup_autosigning,
         
     | 
| 
       26 
26 
     | 
    
         
             
                      install_poolparty,
         
     | 
| 
       27 
27 
     | 
    
         
             
                      setup_poolparty,
         
     | 
| 
       28 
     | 
    
         
            -
                       
     | 
| 
      
 28 
     | 
    
         
            +
                      restart_puppetmaster,
         
     | 
| 
       29 
29 
     | 
    
         
             
                      run_first_time,
         
     | 
| 
       30 
     | 
    
         
            -
                       
     | 
| 
      
 30 
     | 
    
         
            +
                      create_local_node,
         
     | 
| 
       31 
31 
     | 
    
         
             
                    ] << configure_tasks
         
     | 
| 
       32 
32 
     | 
    
         
             
                  end
         
     | 
| 
       33 
33 
     | 
    
         | 
| 
         @@ -45,6 +45,7 @@ module PoolParty 
     | 
|
| 
       45 
45 
     | 
    
         
             
                    <<-EOS
         
     | 
| 
       46 
46 
     | 
    
         
             
            echo "Creating local host entry"
         
     | 
| 
       47 
47 
     | 
    
         
             
            if [ -z \"$(grep -v '#' /etc/hosts | grep 'puppet')" ]; then echo '#{@master_ip}           puppet master localhost' >> /etc/hosts; fi
         
     | 
| 
      
 48 
     | 
    
         
            +
            hostname master
         
     | 
| 
       48 
49 
     | 
    
         
             
                    EOS
         
     | 
| 
       49 
50 
     | 
    
         
             
                  end
         
     | 
| 
       50 
51 
     | 
    
         | 
| 
         @@ -116,11 +117,11 @@ wget http://rubyforge.org/frs/download.php/45546/rubyforge-1.0.1.gem -O rubyforg 
     | 
|
| 
       116 
117 
     | 
    
         
             
            wget http://rubyforge.org/frs/download.php/43954/rake-0.8.3.gem -O rake.gem 2>&1
         
     | 
| 
       117 
118 
     | 
    
         
             
            wget http://rubyforge.org/frs/download.php/45589/sexp_processor-3.0.0.gem -O sexp_processor.gem 2>&1
         
     | 
| 
       118 
119 
     | 
    
         
             
            wget http://github.com/auser/poolparty/tree/master%2Fpkg%2Fpoolparty.gem?raw=true -O poolparty.gem 2>&1
         
     | 
| 
       119 
     | 
    
         
            -
            wget http://rubyforge.org/frs/download.php/43666/amazon-ec2-0.3.1.gem -O amazon-ec2.gem 2>&1
         
     | 
| 
      
 120 
     | 
    
         
            +
            # wget http://rubyforge.org/frs/download.php/43666/amazon-ec2-0.3.1.gem -O amazon-ec2.gem 2>&1
         
     | 
| 
       120 
121 
     | 
    
         | 
| 
       121 
122 
     | 
    
         
             
            #{
         
     | 
| 
       122 
123 
     | 
    
         
             
              %w(rake lockfile rubyforge hoe ZenTest sexp_processor flexmock logging activesupport 
         
     | 
| 
       123 
     | 
    
         
            -
                  RubyInline ParseTree ruby2ruby xml-simple poolparty 
     | 
| 
      
 124 
     | 
    
         
            +
                  RubyInline ParseTree ruby2ruby xml-simple poolparty).map do |dep|
         
     | 
| 
       124 
125 
     | 
    
         
             
                "gem install --ignore-dependencies -y --no-ri --no-rdoc #{dep}.gem #{unix_hide_string}"
         
     | 
| 
       125 
126 
     | 
    
         
             
              end.join("\n")
         
     | 
| 
       126 
127 
     | 
    
         
             
            }
         
     | 
| 
         @@ -132,21 +133,24 @@ wget http://rubyforge.org/frs/download.php/43666/amazon-ec2-0.3.1.gem -O amazon- 
     | 
|
| 
       132 
133 
     | 
    
         
             
                  def restart_puppetmaster
         
     | 
| 
       133 
134 
     | 
    
         
             
                    <<-EOS
         
     | 
| 
       134 
135 
     | 
    
         
             
            echo "(Re)starting poolparty"
         
     | 
| 
       135 
     | 
    
         
            -
            . /etc/profile
         
     | 
| 
       136 
     | 
    
         
            -
            /etc/init.d/puppetmaster stop #{unix_hide_string}
         
     | 
| 
       137 
     | 
    
         
            -
            ps aux | grep puppetmaster | awk '{print $2}' | xargs kill #{unix_hide_string} # just in case
         
     | 
| 
       138 
     | 
    
         
            -
            rm -rf /etc/puppet/ssl
         
     | 
| 
       139 
     | 
    
         
            -
            # Start it back up
         
     | 
| 
       140 
     | 
    
         
            -
            # puppetmasterd --verbose
         
     | 
| 
      
 136 
     | 
    
         
            +
            # . /etc/profile
         
     | 
| 
      
 137 
     | 
    
         
            +
            # /etc/init.d/puppetmaster stop #{unix_hide_string}
         
     | 
| 
      
 138 
     | 
    
         
            +
            # ps aux | grep puppetmaster | awk '{print $2}' | xargs kill #{unix_hide_string} # just in case
         
     | 
| 
      
 139 
     | 
    
         
            +
            # rm -rf /etc/puppet/ssl
         
     | 
| 
      
 140 
     | 
    
         
            +
            # # Start it back up
         
     | 
| 
      
 141 
     | 
    
         
            +
            # # puppetmasterd --verbose
         
     | 
| 
       141 
142 
     | 
    
         
             
            /etc/init.d/puppetmaster start
         
     | 
| 
       142 
143 
     | 
    
         
             
                    EOS
         
     | 
| 
       143 
144 
     | 
    
         
             
                  end
         
     | 
| 
       144 
145 
     | 
    
         | 
| 
       145 
146 
     | 
    
         
             
                  def run_first_time
         
     | 
| 
       146 
147 
     | 
    
         
             
            <<-EOE
         
     | 
| 
       147 
     | 
    
         
            -
            echo " 
     | 
| 
      
 148 
     | 
    
         
            +
            echo "Running first time run"
         
     | 
| 
      
 149 
     | 
    
         
            +
            cp #{Base.remote_storage_path}/#{Base.template_directory}/puppetrerun /usr/bin/puppetrerun
         
     | 
| 
      
 150 
     | 
    
         
            +
            cp #{Base.remote_storage_path}/#{Base.template_directory}/puppetrunner /usr/bin/puppetrunner
         
     | 
| 
       148 
151 
     | 
    
         
             
            chmod +x /usr/bin/puppetrerun
         
     | 
| 
       149 
     | 
    
         
            -
             
     | 
| 
      
 152 
     | 
    
         
            +
            chmod +x /usr/bin/puppetrunner
         
     | 
| 
      
 153 
     | 
    
         
            +
            /bin/sh /usr/bin/server-update-hosts
         
     | 
| 
       150 
154 
     | 
    
         
             
            EOE
         
     | 
| 
       151 
155 
     | 
    
         
             
                  end
         
     | 
| 
       152 
156 
     | 
    
         | 
| 
         @@ -163,7 +167,7 @@ node default { 
     | 
|
| 
       163 
167 
     | 
    
         
             
            node "#{ri.name}" inherits default {}
         
     | 
| 
       164 
168 
     | 
    
         
             
                       EOS
         
     | 
| 
       165 
169 
     | 
    
         
             
                     end
         
     | 
| 
       166 
     | 
    
         
            -
            "echo '#{str}' >  
     | 
| 
      
 170 
     | 
    
         
            +
            "echo '#{str}' > #{Base.manifest_path}/../nodes/nodes.pp"
         
     | 
| 
       167 
171 
     | 
    
         
             
                  end
         
     | 
| 
       168 
172 
     | 
    
         | 
| 
       169 
173 
     | 
    
         
             
                  def move_templates
         
     | 
| 
         @@ -191,10 +195,9 @@ cp #{Base.remote_storage_path}/poolparty.pp /etc/puppet/manifests/classes/poolpa 
     | 
|
| 
       191 
195 
     | 
    
         
             
                  end
         
     | 
| 
       192 
196 
     | 
    
         | 
| 
       193 
197 
     | 
    
         
             
                  def restart_puppetd
         
     | 
| 
       194 
     | 
    
         
            -
                    terminate_string = "ps aux | grep puppetmaster | awk '{print $2}' | xargs kill #{unix_hide_string}; puppetmasterd --verbose"
         
     | 
| 
       195 
198 
     | 
    
         
             
                    <<-EOS
         
     | 
| 
       196 
199 
     | 
    
         
             
            echo "Running puppet manifest"
         
     | 
| 
       197 
     | 
    
         
            -
            /bin/sh /usr/bin/ 
     | 
| 
      
 200 
     | 
    
         
            +
            /bin/sh /usr/bin/puppetrunner
         
     | 
| 
       198 
201 
     | 
    
         
             
                    EOS
         
     | 
| 
       199 
202 
     | 
    
         
             
                  end
         
     | 
| 
       200 
203 
     | 
    
         
             
                end
         
     | 
| 
         @@ -4,6 +4,7 @@ module PoolParty 
     | 
|
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
                  def install_tasks
         
     | 
| 
       6 
6 
     | 
    
         
             
                    [ 
         
     | 
| 
      
 7 
     | 
    
         
            +
                      setup_poolparty,
         
     | 
| 
       7 
8 
     | 
    
         
             
                      setup_puppet,
         
     | 
| 
       8 
9 
     | 
    
         
             
                      setup_configs,
         
     | 
| 
       9 
10 
     | 
    
         
             
                      run_once_and_clean
         
     | 
| 
         @@ -18,7 +19,7 @@ module PoolParty 
     | 
|
| 
       18 
19 
     | 
    
         | 
| 
       19 
20 
     | 
    
         
             
                  def setup_poolparty
         
     | 
| 
       20 
21 
     | 
    
         
             
                    <<-EOE
         
     | 
| 
       21 
     | 
    
         
            -
            echo "#{open(File.join(template_directory, " 
     | 
| 
      
 22 
     | 
    
         
            +
            echo "#{open(File.join(template_directory, "puppetrunner")).read}" > /usr/bin/puppetrunner
         
     | 
| 
       22 
23 
     | 
    
         
             
                    EOE
         
     | 
| 
       23 
24 
     | 
    
         
             
                  end
         
     | 
| 
       24 
25 
     | 
    
         | 
| 
         @@ -10,8 +10,15 @@ module PoolParty 
     | 
|
| 
       10 
10 
     | 
    
         | 
| 
       11 
11 
     | 
    
         
             
                # Store block
         
     | 
| 
       12 
12 
     | 
    
         
             
                def store_block(&block)
         
     | 
| 
       13 
     | 
    
         
            -
                  @ 
     | 
| 
      
 13 
     | 
    
         
            +
                  @stored_block ||= block
         
     | 
| 
       14 
14 
     | 
    
         
             
                end
         
     | 
| 
      
 15 
     | 
    
         
            +
                
         
     | 
| 
      
 16 
     | 
    
         
            +
                # This will run the blocks after they are stored if there is a block
         
     | 
| 
      
 17 
     | 
    
         
            +
                # associated
         
     | 
| 
      
 18 
     | 
    
         
            +
                def run_stored_block      
         
     | 
| 
      
 19 
     | 
    
         
            +
                  self.run_in_context @stored_block if @stored_block
         
     | 
| 
      
 20 
     | 
    
         
            +
                end
         
     | 
| 
      
 21 
     | 
    
         
            +
                
         
     | 
| 
       15 
22 
     | 
    
         
             
                # Set instances with a range
         
     | 
| 
       16 
23 
     | 
    
         
             
                def instances(arg)
         
     | 
| 
       17 
24 
     | 
    
         
             
                  if arg.is_a?(Range)
         
     | 
| 
         @@ -70,17 +77,29 @@ module PoolParty 
     | 
|
| 
       70 
77 
     | 
    
         
             
                  ]
         
     | 
| 
       71 
78 
     | 
    
         
             
                end
         
     | 
| 
       72 
79 
     | 
    
         | 
| 
      
 80 
     | 
    
         
            +
                def context_stack
         
     | 
| 
      
 81 
     | 
    
         
            +
                  @@context_stack ||= []
         
     | 
| 
      
 82 
     | 
    
         
            +
                end
         
     | 
| 
      
 83 
     | 
    
         
            +
                def run_setup(parent, should_set_parent=true, &block)
         
     | 
| 
      
 84 
     | 
    
         
            +
                  context_stack.push parent
         
     | 
| 
      
 85 
     | 
    
         
            +
                  
         
     | 
| 
      
 86 
     | 
    
         
            +
                  set_parent if should_set_parent
         
     | 
| 
      
 87 
     | 
    
         
            +
                  run_in_context self, &block if block
         
     | 
| 
      
 88 
     | 
    
         
            +
                  
         
     | 
| 
      
 89 
     | 
    
         
            +
                  context_stack.pop
         
     | 
| 
      
 90 
     | 
    
         
            +
                end
         
     | 
| 
      
 91 
     | 
    
         
            +
                
         
     | 
| 
       73 
92 
     | 
    
         
             
                # Set the parent on the resource
         
     | 
| 
       74 
     | 
    
         
            -
                def set_parent( 
     | 
| 
       75 
     | 
    
         
            -
                  unless  
     | 
| 
       76 
     | 
    
         
            -
                    @parent =  
     | 
| 
      
 93 
     | 
    
         
            +
                def set_parent(sink_options=true)
         
     | 
| 
      
 94 
     | 
    
         
            +
                  # unless context_stack.last == self
         
     | 
| 
      
 95 
     | 
    
         
            +
                    @parent = context_stack.last
         
     | 
| 
       77 
96 
     | 
    
         
             
                    # Add self as a service on the parent
         
     | 
| 
       78 
     | 
    
         
            -
                     
     | 
| 
      
 97 
     | 
    
         
            +
                    parent.add_service(self) if parent.respond_to?(:add_service)
         
     | 
| 
       79 
98 
     | 
    
         
             
                    # Take the options of the parents
         
     | 
| 
       80 
     | 
    
         
            -
                    configure( 
     | 
| 
       81 
     | 
    
         
            -
                  end
         
     | 
| 
      
 99 
     | 
    
         
            +
                    configure(parent.options) if parent && parent.respond_to?(:options) && sink_options
         
     | 
| 
      
 100 
     | 
    
         
            +
                  # end
         
     | 
| 
       82 
101 
     | 
    
         
             
                end
         
     | 
| 
       83 
     | 
    
         
            -
             
     | 
| 
      
 102 
     | 
    
         
            +
                        
         
     | 
| 
       84 
103 
     | 
    
         
             
                def number_of_resources
         
     | 
| 
       85 
104 
     | 
    
         
             
                  arr = resources.map do |n, r|
         
     | 
| 
       86 
105 
     | 
    
         
             
                    r.size
         
     |