Sha256: a2470110003d713569885f6d3d096699282ded1e21f1b8a1fa068cc8b71d467e
Contents?: true
Size: 1.38 KB
Versions: 19
Compression:
Stored size: 1.38 KB
Contents
module Vpsb module Tasks class CreateDroplet < BaseTask include AskSupport include ShellSupport prepare_squence :do_image, :do_region, :do_size, :do_droplet_ssh_key def call prepare ask_loop(proc {|r| process(r)}) do ap preparation_results puts "Save this configuration y[es]/n[o]?" end create_droplet puts "Your droplet has been created. Congratulations! Visit https://cloud.digitalocean.com/ to see more details" end private def process(r) return true if r[0].to_s.downcase == 'y' reprepare false end def create_droplet puts "Creating droplet please wait... It may take a couple of minutes" command = [ "knife digital_ocean droplet create", "--server-name #{core.get(:do_host)}", "--image #{core.get(:do_image)}", "--location #{core.get(:do_region)}", "--size #{core.get(:do_size)}", "--ssh-keys #{core.get(:do_droplet_ssh_key)}", ].join(' ') output = run(core.get(:server_app_path), command) ip = output.split("\n").find{ |x| x.include?('IPv4 address is:')}.split(':').last.strip core.data[:do_host_ip] = ip puts output end def run(where, what) %x{cd #{where} && #{what}} end end end end
Version data entries
19 entries across 19 versions & 1 rubygems