Class: PoolParty::Provider

Inherits:
Object show all
Includes:
Sprinkle
Defined in:
lib/poolparty/provider.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.define_custom_package(name = :userpackages, &block) ⇒ Object



26
27
28
29
# File 'lib/poolparty/provider.rb', line 26

def self.define_custom_package name=:userpackages, &block
  (user_install_packages << name).uniq!
  user_packages << yield if block_given?
end

.install_poolparty(testing = false) ⇒ Object



95
96
97
# File 'lib/poolparty/provider.rb', line 95

def install_poolparty(testing=false)
  singleton.install_poolparty(testing)
end

.singletonObject



98
99
100
# File 'lib/poolparty/provider.rb', line 98

def singleton
  @singleton ||= new
end

.user_install_packagesObject



43
44
45
# File 'lib/poolparty/provider.rb', line 43

def self.user_install_packages
  @load_strings ||= []
end

.user_packagesObject



39
40
41
# File 'lib/poolparty/provider.rb', line 39

def self.user_packages
  @user_packages ||= []
end

Instance Method Details

#install_poolparty(testing = false) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/poolparty/provider.rb', line 5

def install_poolparty(testing=false)
  PoolParty.message "Installing required poolparty paraphernalia"
  load_packages
  user_packages.map {|blk| blk.call if blk }

  policy :poolparty, :roles => :app do
    requires :ruby
    requires :heartbeat
    requires :haproxy
    requires :s3fs
    requires :rsync
    requires :required_gems
    
    PoolParty::Provider.user_install_packages.each do |req|
      self.send :requires, req.to_sym
    end
  end
  
  testing ? show_process : process
end

#load_packagesObject



47
48
49
50
51
# File 'lib/poolparty/provider.rb', line 47

def load_packages
  Dir["#{File.expand_path(File.dirname(__FILE__))}/provider/*"].each do |f| 
    load f
  end
end

#processObject



72
73
74
75
# File 'lib/poolparty/provider.rb', line 72

def process
  set_start_with_sprinkle
  @deployment.process if @deployment
end

#set_start_with_sprinkleObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/poolparty/provider.rb', line 53

def set_start_with_sprinkle
  deployment do
    delivery :vlad do
      set :user, "#{Application.username}"
      
      Master.cloud_ips.each do |ip|
        role :app, "#{Application.username}@#{ip}"
      end
    end
  
    source do
      prefix   '/usr/local'
      archives '/root/sources'
      builds   '/root/builds'
    end
  end
  
end

#show_processObject



77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/poolparty/provider.rb', line 77

def show_process
  Sprinkle::OPTIONS[:testing] = true
  Sprinkle::OPTIONS[:verbose] = true      
  Object.logger.level = ActiveSupport::BufferedLogger::Severity::DEBUG
  deployment do
    delivery :vlad do
    end
    source do
      prefix   '/usr/local'
      archives '/root/sources'
      builds   '/root/builds'
    end
  end.process
end

#user_install_packagesObject



35
36
37
# File 'lib/poolparty/provider.rb', line 35

def user_install_packages
  self.class.user_install_packages
end

#user_packagesObject



31
32
33
# File 'lib/poolparty/provider.rb', line 31

def user_packages
  self.class.user_packages
end