Class: Bork::Server
- Inherits:
-
Object
- Object
- Bork::Server
- Defined in:
- lib/bork/server.rb
Instance Attribute Summary collapse
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#flavor_id ⇒ Object
Returns the value of attribute flavor_id.
-
#image_id ⇒ Object
Returns the value of attribute image_id.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#name ⇒ Object
Returns the value of attribute name.
-
#packages(package_list) ⇒ Object
Returns the value of attribute packages.
-
#role ⇒ Object
Returns the value of attribute role.
Instance Method Summary collapse
- #after_install(*args) ⇒ Object
- #bootstrap! ⇒ Object
- #flavor(id) ⇒ Object
- #image(id) ⇒ Object
-
#initialize(role, *options, &block) ⇒ Server
constructor
A new instance of Server.
- #install_packages ⇒ Object
- #instance ⇒ Object
- #linked? ⇒ Boolean
- #setup! ⇒ Object
Constructor Details
#initialize(role, *options, &block) ⇒ Server
Returns a new instance of Server.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/bork/server.rb', line 5 def initialize(role, *, &block) = . @role = role.to_sym @packages = %w( build-essential zlib1g-dev libpcre3-dev git-core libxml2-dev libxslt-dev openssl libssl-dev curl ) @after_install = [] @environment = .delete(:environment) @name = "#{@environment.name}.#{@role}.#{Bork.application}.saxtonhorne.net" # TODO: Don't do this. @metadata = { 'application' => Bork.application, 'role' => role.to_s, 'environment' => environment.name.to_s } if block.arity == 1 block[self] else instance_eval &block end end |
Instance Attribute Details
#environment ⇒ Object
Returns the value of attribute environment.
3 4 5 |
# File 'lib/bork/server.rb', line 3 def environment @environment end |
#flavor_id ⇒ Object
Returns the value of attribute flavor_id.
3 4 5 |
# File 'lib/bork/server.rb', line 3 def flavor_id @flavor_id end |
#image_id ⇒ Object
Returns the value of attribute image_id.
3 4 5 |
# File 'lib/bork/server.rb', line 3 def image_id @image_id end |
#metadata ⇒ Object
Returns the value of attribute metadata.
3 4 5 |
# File 'lib/bork/server.rb', line 3 def @metadata end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/bork/server.rb', line 3 def name @name end |
#packages(package_list) ⇒ Object
Returns the value of attribute packages.
3 4 5 |
# File 'lib/bork/server.rb', line 3 def packages @packages end |
#role ⇒ Object
Returns the value of attribute role.
3 4 5 |
# File 'lib/bork/server.rb', line 3 def role @role end |
Instance Method Details
#after_install(*args) ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/bork/server.rb', line 40 def after_install(*args) = args. return @after_install if args.length == 0 args.each do |arg| arg.split("\n").each do |cmd| @after_install << cmd.strip end end end |
#bootstrap! ⇒ Object
50 51 52 53 |
# File 'lib/bork/server.rb', line 50 def bootstrap! @instance = do_bootstrap # We're providing our own bootstrap because I want some reporting @linked = true end |
#flavor(id) ⇒ Object
32 33 34 |
# File 'lib/bork/server.rb', line 32 def flavor(id) @flavor_id = id.to_i end |
#image(id) ⇒ Object
28 29 30 |
# File 'lib/bork/server.rb', line 28 def image(id) @image_id = id.to_i end |
#install_packages ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/bork/server.rb', line 68 def install_packages log "Updating apt" instance.ssh('apt-get -qq update') log "Installing packages" instance.ssh("apt-get -qqy install #{@packages.join(" ")}") end |
#instance ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/bork/server.rb', line 59 def instance return @instance if linked? @linked = false @instance = Bork.provider.servers.find do |server| @linked = true if server. == end end |
#linked? ⇒ Boolean
55 56 57 |
# File 'lib/bork/server.rb', line 55 def linked? @linked end |
#setup! ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/bork/server.rb', line 76 def setup! install_packages log "Running post-install hooks" @after_install.each do |cmd| log cmd instance.ssh cmd do |output| log output end end end |