Skip to content

Instantly share code, notes, and snippets.

@futoase
Created February 13, 2018 23:59
Show Gist options
  • Save futoase/6ed1b0648c9ae079f8bb372929435082 to your computer and use it in GitHub Desktop.
Save futoase/6ed1b0648c9ae079f8bb372929435082 to your computer and use it in GitHub Desktop.
network-address-digital-ocean-instance
require 'droplet_kit'
# get access token from https://www.digitalocean.com/community/tutorials/how-to-use-the-digitalocean-api-v2
# export DIGITAL_OCEAN_TOKEN=XXXXXXXXXXXX
client = DropletKit::Client.new(access_token: ENV['DIGITAL_OCEAN_TOKEN'])
client.droplets.all().map do |i|
i.networks.each do |network|
if network&.first&.ip_address
puts "#{network&.first&.ip_address}"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment