Last active
August 29, 2015 14:13
-
-
Save jkeiser/006b9af3c00dddae0a24 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| class AWSRoute53RS < LWRPBase | |
| def initialize(*args) | |
| # parse @name | |
| end | |
| attribute :zone | |
| attribute :subdomain | |
| attribute :type | |
| attribute :ttl | |
| attribute :priority | |
| attribute :resource_records | |
| attribute :addresses | |
| attribute :raw_options | |
| end | |
| resource_records ,... | |
| addresses ... | |
| machines ... | |
| class AWSRoute53RSMX < AWSRoute53RSA | |
| def type | |
| 'MX' | |
| end | |
| end | |
| class AWSRoute53RSA < AWSRoute53RS | |
| def type | |
| 'A' | |
| end | |
| attribute :addresses | |
| # aws_route_53_rs_a 'me.supercool.com.' do | |
| # addresses # prints current value | |
| # addresses %w(1.2.3.4 2.3.4.5 3.4.5.6) # sets addresses to these only | |
| # addresses %w(web1 web2 web3) # it assumes that names mean machine names | |
| # addresses '1.2.3.4', '2.3.4.5', '3.4.5.6' # set addresses to these only | |
| # end | |
| def addresses(*addresses) | |
| # If they passed no arguments, they wanted to *get* the current addresses. | |
| if addresses.size == 0 | |
| return resource_records.map { |record| record[:value] } | |
| end | |
| # If the user passed an array, use that as the list of addresses | |
| if addresses.size == 1 && addresses[0].is_a?(Array) | |
| addresses = addresses[0] | |
| end | |
| # Inflate the actual resource_records. | |
| resource_records addresses.map { |address| { value: address } } | |
| end | |
| # Set machines | |
| # machines [ 'web1', 'web2' ] | |
| # machines 'web1', 'web2' | |
| def machines(*machine_names) | |
| # We'd have to reverse look up the machine name from the IP, which while | |
| # technically possible, isn't super useful. | |
| if machine_names.size == 0 | |
| raise NotImplementedError, "Cannot get machines, use addresses instead" | |
| end | |
| # If the user passed an array, use that as the list of addresses | |
| if machine_names.size == 1 && machine_names[0].is_a?(Array) | |
| machine_names = machine_names[0] | |
| end | |
| # Turn them into IP addresses and call "addresses" with that. | |
| addresses machine_names.map do |machine_name| | |
| get_ip_address_for_machine(machine_name) | |
| end | |
| end | |
| end | |
| class AWSRoute53RSCname < AWSRoute53RS | |
| attribute :somethings | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment