roadworker 0.5.9.beta5 → 0.5.9.beta6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +13 -3
- data/lib/roadworker/client.rb +18 -4
- data/lib/roadworker/dsl-converter.rb +2 -1
- data/lib/roadworker/dsl.rb +4 -3
- data/lib/roadworker/route53-exporter.rb +1 -1
- data/lib/roadworker/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1eb8c3a93ef58551d55534c8a67cb588e7e85ca
|
4
|
+
data.tar.gz: e34029aac5acf924a1898f74856069ee5e8e00e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f03d84f50cd76e0f9f6f4e861e3e521c2ac0eea19bcfa7ce1167b764cec2fa7ad2f0fbae5383a49770788be2026bf4c4ef32785fc0adc6f27be5df093b06379a
|
7
|
+
data.tar.gz: 07da904da92920d8be762e6cb090a960195d3ec28b77feef76b10bac579ef5deae12f97a469c42fc0810d7eebce0de0e4e084f4a5965e50e90181beeec060329
|
data/README.md
CHANGED
@@ -183,13 +183,23 @@ end
|
|
183
183
|
### Dynamic private DNS example
|
184
184
|
|
185
185
|
```ruby
|
186
|
+
require 'aws-sdk'
|
187
|
+
|
186
188
|
hosted_zone "us-east-1.my.local." do
|
187
189
|
vpc "us-east-1", "vpc-xxxxxxxx"
|
188
190
|
|
189
|
-
|
190
|
-
|
191
|
+
resp = Aws::EC2::Client.new(region: "us-east-1").describe_instances(filters:[{ name: 'vpc-id', values: ["vpc-xxxxxxxx"] }])
|
192
|
+
instances = resp.reservations.each_with_object({}) do |reservation, reservations|
|
193
|
+
reservations.merge!(reservation.instances.each_with_object({}) do |instance, instances|
|
194
|
+
tag_name = instance.tags.find {|tag| tag['key'] == 'Name' }
|
195
|
+
instances[instance.private_ip_address] = tag_name['value'] if tag_name and tag_name['value'] != ''
|
196
|
+
end)
|
197
|
+
end
|
198
|
+
|
199
|
+
instances.each {|private_ip_address, tag_name|
|
200
|
+
rrset "#{tag_name}.us-east-1.my.local.", "A" do
|
191
201
|
ttl 300
|
192
|
-
resource_records
|
202
|
+
resource_records private_ip_address
|
193
203
|
end
|
194
204
|
}
|
195
205
|
end
|
data/lib/roadworker/client.rb
CHANGED
@@ -63,13 +63,23 @@ module Roadworker
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def walk_hosted_zones(dsl)
|
66
|
-
expected = collection_to_hash(dsl.hosted_zones) {|i| [normalize_name(i.name), i.vpcs.
|
67
|
-
actual = collection_to_hash(@route53.hosted_zones) {|i| [normalize_name(i.name), i.vpcs.
|
66
|
+
expected = collection_to_hash(dsl.hosted_zones) {|i| [normalize_name(i.name), i.vpcs.empty?, normalize_id(i.id)] }
|
67
|
+
actual = collection_to_hash(@route53.hosted_zones) {|i| [normalize_name(i.name), i.vpcs.empty?, normalize_id(i.id)] }
|
68
68
|
|
69
69
|
expected.each do |keys, expected_zone|
|
70
|
-
name = keys
|
70
|
+
name, private_zone, id = keys
|
71
71
|
next unless matched_zone?(name)
|
72
|
-
|
72
|
+
if id
|
73
|
+
actual_zone = actual.delete(keys)
|
74
|
+
unless actual_zone
|
75
|
+
log(:warn, "Hosted zone not found", :yellow, "#{name} (#{id})")
|
76
|
+
next
|
77
|
+
end
|
78
|
+
else
|
79
|
+
actual_keys, actual_zone = actual.find {|(n, p, _), _| n == name && p == private_zone }
|
80
|
+
actual.delete(actual_keys) if actual_keys
|
81
|
+
end
|
82
|
+
|
73
83
|
actual_zone ||= @route53.hosted_zones.create(name, :vpc => expected_zone.vpcs.first)
|
74
84
|
|
75
85
|
walk_vpcs(expected_zone, actual_zone)
|
@@ -171,5 +181,9 @@ module Roadworker
|
|
171
181
|
name.downcase.sub(/\.\z/, '')
|
172
182
|
end
|
173
183
|
|
184
|
+
def normalize_id(id)
|
185
|
+
id.sub(%r!^/hostedzone/!, '') if id
|
186
|
+
end
|
187
|
+
|
174
188
|
end # Client
|
175
189
|
end # Roadworker
|
@@ -88,12 +88,13 @@ module Roadworker
|
|
88
88
|
|
89
89
|
def output_zone(zone)
|
90
90
|
name = zone[:name].inspect
|
91
|
+
id = zone[:id].sub(%r!^/hostedzone/!, '').inspect
|
91
92
|
rrsets = zone[:rrsets]
|
92
93
|
vpcs = output_vpcs(zone[:vpcs])
|
93
94
|
vpcs = " #{vpcs}\n\n" if vpcs
|
94
95
|
|
95
96
|
return(<<-EOS)
|
96
|
-
hosted_zone #{name} do
|
97
|
+
hosted_zone #{name}#{zone[:vpcs].empty? ? '' : ", #{id}"} do
|
97
98
|
#{vpcs
|
98
99
|
}#{rrsets.map {|i| output_rrset(i) }.join("\n").chomp}
|
99
100
|
end
|
data/lib/roadworker/dsl.rb
CHANGED
@@ -50,8 +50,8 @@ module Roadworker
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
def hosted_zone(name, &block)
|
54
|
-
@result.hosted_zones << Hostedzone.new(@context, name, [], &block).result
|
53
|
+
def hosted_zone(name, id = nil, &block)
|
54
|
+
@result.hosted_zones << Hostedzone.new(@context, name, id, [], &block).result
|
55
55
|
end
|
56
56
|
|
57
57
|
class Hostedzone
|
@@ -59,11 +59,12 @@ module Roadworker
|
|
59
59
|
|
60
60
|
attr_reader :result
|
61
61
|
|
62
|
-
def initialize(context, name, rrsets = [], &block)
|
62
|
+
def initialize(context, name, id, rrsets = [], &block)
|
63
63
|
@name = name
|
64
64
|
@context = context.merge(:hosted_zone_name => name)
|
65
65
|
|
66
66
|
@result = OpenStruct.new({
|
67
|
+
:id => id,
|
67
68
|
:name => name,
|
68
69
|
:vpcs => [],
|
69
70
|
:resource_record_sets => rrsets,
|
@@ -29,7 +29,7 @@ module Roadworker
|
|
29
29
|
Collection.batch(@options.route53.list_hosted_zones, :hosted_zones) do |zone|
|
30
30
|
next unless matched_zone?(zone.name)
|
31
31
|
resp = @options.route53.get_hosted_zone(id: zone.id)
|
32
|
-
zone_h = { name: zone.name, vpcs: resp.vp_cs }
|
32
|
+
zone_h = { id: zone.id, name: zone.name, vpcs: resp.vp_cs }
|
33
33
|
hosted_zones << zone_h
|
34
34
|
|
35
35
|
rrsets = []
|
data/lib/roadworker/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roadworker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.9.
|
4
|
+
version: 0.5.9.beta6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- winebarrel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|