class Seedee::Farm
The servers in the Digital Ocean farm
Public Instance Methods
provision_client_node()
click to toggle source
# File lib/seedee/farm.rb, line 8 def provision_client_node name = "client-#{SecureRandom.uuid}" puts "Provisioning node #{name}" droplet = cloud_provider.new_droplet(name) # wait 20 seconds for droplet to be available sleep(20) bootstrap(name, droplet) end
Private Instance Methods
bootstrap(name, droplet)
click to toggle source
# File lib/seedee/farm.rb, line 21 def bootstrap(name, droplet) puts "Boostraping node #{name} with ip #{droplet.public_ip} " \ "having droplet attributes #{droplet.as_json}" result = provisioner.bootstrap(droplet, name, 'transit.tips::client') raise 'knife bootstrap failed to execute' if result.nil? raise 'knife bootstrap returned 1' if result == false rescue => exception puts exception cloud_provider.destroy_droplet(droplet.id) # Exit the script with failure status code raise end
cloud_provider()
click to toggle source
# File lib/seedee/farm.rb, line 36 def cloud_provider @cloud_provider ||= DigitalOcean.new end
provisioner()
click to toggle source
# File lib/seedee/farm.rb, line 40 def provisioner @provisioner ||= Chef.new end