Created
October 17, 2016 13:51
-
-
Save lwoodson/ce478674d7748cf3185b5dcec5d60821 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
raise "must set DIGITAL_OCEAN_SSH_KEY" unless ENV['DIGITAL_OCEAN_SSH_KEY'] | |
# Floating ips cannot have tags as a limitation of DigitalOcean's resource | |
# model. Floating ips for environments need to be created via console and | |
# set here. These are the primary entry points for everything and are in | |
# the sfo2 datacenter. There is a request to enable labelling for floating | |
# ips, this should be changed whenever that is available. | |
FLOATING_IPS = { | |
"sfo2" => { | |
"dev" => '138.68.37.45', | |
"prod" => 'need one' | |
} | |
} | |
Marianas::stack "gateway" do | |
droplet "gateway" do |gateway| | |
gateway.image = lookup(:image, :slug => 'centos-7-0-x64').id | |
gateway.size = '512mb' | |
gateway.ssh_keys = [ | |
lookup(:ssh_key, :name => ENV['DIGITAL_OCEAN_SSH_KEY']).id | |
] | |
gateway.private_networking = true | |
gateway.after_create do |stack, context, client| | |
# Lookup and assign our floating ip | |
floating_ip = FLOATING_IPS[stack.region][stack.env] | |
client.floating_ip_actions.assign(ip: floating_ip, droplet_id: id) | |
end | |
gateway.before_destroy do |stack, context, client| | |
# Lookup and unassign our floating ip | |
floating_ip = FLOATING_IPS[stack.region][stack.env] | |
client.floating_ip_actions.unassign(ip: floating_ip) rescue nil | |
end | |
end | |
# TODO floa |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment