roadworker 0.5.9.beta7 → 0.5.9.beta9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 707ba9abafc59de743d86538de2a4566dfa325fd
4
- data.tar.gz: a7485c93fdbafc8108efe91192e7f42e4d97820c
2
+ SHA256:
3
+ metadata.gz: 8b3e4a8978dd100d8c27b1dca7fb25405eddfc9d72ad8ef6a9e794c591b6fed6
4
+ data.tar.gz: 702e28502b895284f95df074180c6960b99cb4c4ea84302d39bfbab460ff2db9
5
5
  SHA512:
6
- metadata.gz: a618ae5c559428fb579c254db1257c2b022ad9ab2c4516be7d64eb3a59935c27cf28b190515d9caf7b1f6620fe2cd278fd0f279e49dc74219300f18047283533
7
- data.tar.gz: e696932bff763107137582d4a7c0ad571ee584c7d61b21950158ed18b31aeb76e9e2fbad03af5b528ce0b80c33b7a7ffd14c10bf1b1711620003ebb83451f636
6
+ metadata.gz: e9b69f9f92d7dae71edc710e9645ce847241e349f6f0d6b426d62df8c3b801890187e9b6bf603285245d3cc2f744144725d8bc771faab05bce51f059afe5cd50
7
+ data.tar.gz: 233d99f686c86292ab92e9e7c8c6a277f53fcf99980e6144acd5244db33ef0515d1e1b837e487401836a6f0af3e2d89f3e80a389facbfe66f2eb118efbf3fcd7
@@ -22,7 +22,7 @@ proc {
22
22
  end
23
23
  }.call
24
24
 
25
- require 'net/dns'
25
+ require 'dnsruby'
26
26
 
27
27
  module Roadworker
28
28
  class DSL
@@ -30,6 +30,7 @@ module Roadworker
30
30
  include Roadworker::Log
31
31
  include Roadworker::Utils::Helper
32
32
 
33
+ DEFAULT_CONFIG_FILE = '/etc/resolv.conf'
33
34
  DEFAULT_NAMESERVERS = ['8.8.8.8', '8.8.4.4']
34
35
  ASTERISK_PREFIX = 'asterisk-of-wildcard'
35
36
  RETRY = 3
@@ -87,11 +88,9 @@ module Roadworker
87
88
  actual_value = response.answer.map {|i|
88
89
  case type
89
90
  when 'TXT', 'SPF'
90
- i.txt
91
- when 'SRV'
92
- [i.priority, i.weight, i.port, fix_srv_host(name, i.host)].join(' ')
91
+ i.data
93
92
  else
94
- i.value
93
+ i.rdata_to_string
95
94
  end
96
95
  }.map {|i| i.strip }.sort
97
96
  actual_ttls = response.answer.map {|i| i.ttl }
@@ -118,11 +117,13 @@ module Roadworker
118
117
  log(:debug, " #{logmsg_expected}\n #{logmsg_actual}", :white)
119
118
 
120
119
  is_same = false
120
+ check_ttl = true
121
121
 
122
122
  if fetch_dns_name(record.dns_name)
123
123
  # A(Alias)
124
124
  case fetch_dns_name(record.dns_name).sub(/\.\z/, '')
125
125
  when /\.elb\.amazonaws\.com/i
126
+ check_ttl = false
126
127
  is_same = response.answer.all? {|a|
127
128
  response_query_ptr = query(a.value, 'PTR', error_messages)
128
129
 
@@ -135,6 +136,7 @@ module Roadworker
135
136
  end
136
137
  }
137
138
  when /\As3-website-(?:[^.]+)\.amazonaws\.com\z/
139
+ check_ttl = false
138
140
  response_answer_ip_1_2 = response.answer.map {|a| a.value.split('.').slice(0, 2) }.uniq
139
141
 
140
142
  # try 3 times
@@ -152,6 +154,7 @@ module Roadworker
152
154
  }
153
155
  end
154
156
  when /\.cloudfront\.net\z/
157
+ check_ttl = false
155
158
  is_same = response.answer.all? {|a|
156
159
  response_query_ptr = query(a.value, 'PTR', error_messages)
157
160
 
@@ -176,7 +179,7 @@ module Roadworker
176
179
  is_same = (expected_value == actual_value)
177
180
  end
178
181
 
179
- if is_same
182
+ if is_same && check_ttl
180
183
  unless actual_ttls.all? {|i| i <= expected_ttl }
181
184
  is_same = false
182
185
  end
@@ -225,7 +228,7 @@ module Roadworker
225
228
  response = query(name, type)
226
229
 
227
230
  if response
228
- asterisk_answers[key] = response.answer.map {|i| (%w(TXT SPF).include?(type) ? i.txt : i.value).strip }
231
+ asterisk_answers[key] = response.answer.map {|i| (%w(TXT SPF).include?(type) ? i.data : i.rdata_to_string).strip }
229
232
  end
230
233
  end
231
234
 
@@ -269,16 +272,14 @@ module Roadworker
269
272
  resolver_opts = {}
270
273
  resolver_opts[:port] = @options.port if @options.port
271
274
 
272
- if File.exist?(Net::DNS::Resolver::Defaults[:config_file])
273
- resolver_opts[:nameservers] = @options.nameservers if @options.nameservers
274
- Net::DNS::Resolver.new(resolver_opts)
275
- else
276
- Tempfile.open(File.basename(__FILE__)) do |f|
277
- resolver_opts.updated(:config_file => f.path, :nameservers => DEFAULT_NAMESERVERS)
278
- resolver_opts[:nameservers] = @options.nameservers if @options.nameservers
279
- Net::DNS::Resolver.new(resolver_opts)
280
- end
275
+ unless File.exist?(DEFAULT_CONFIG_FILE)
276
+ resolver_opts[:nameservers] = DEFAULT_NAMESERVERS
281
277
  end
278
+
279
+ resolver_opts[:nameservers] = @options.nameservers if @options.nameservers
280
+ resolver = Dnsruby::Resolver.new(resolver_opts)
281
+ resolver.do_caching = false
282
+ resolver
282
283
  end
283
284
 
284
285
  def fetch_records(dsl)
@@ -303,12 +304,11 @@ module Roadworker
303
304
  end
304
305
 
305
306
  def query(name, type, error_messages = nil)
306
- ctype = Net::DNS.const_get(type)
307
307
  response = nil
308
308
 
309
309
  RETRY.times do |i|
310
310
  begin
311
- response = @resolver.query(name, ctype)
311
+ response = @resolver.query(name, type)
312
312
  break
313
313
  rescue => e
314
314
  if (i + 1) < RETRY
@@ -66,6 +66,26 @@ module Aws
66
66
  'us-west-2' => 'Z38NKT9BP95V3O',
67
67
  }
68
68
 
69
+ # https://docs.aws.amazon.com/general/latest/gr/rande.html#apigateway_region
70
+ API_GATEWAY_HOSTED_ZONE_NAME_IDS = {
71
+ "us-east-2" => "ZOJJZC49E0EPZ",
72
+ "us-east-1" => "Z1UJRXOUMOOFQ8",
73
+ "us-west-1" => "Z2MUQ32089INYE",
74
+ "us-west-2" => "Z2OJLYMUO9EFXC",
75
+ "ap-south-1" => "Z3VO1THU9YC4UR",
76
+ "ap-northeast-3" => "Z2YQB5RD63NC85",
77
+ "ap-northeast-2" => "Z20JF4UZKIW1U8",
78
+ "ap-southeast-1" => "ZL327KTPIQFUL",
79
+ "ap-southeast-2" => "Z2RPCDW04V8134",
80
+ "ap-northeast-1" => "Z1YSHQZHG15GKL",
81
+ "ca-central-1" => "Z19DQILCV0OWEC",
82
+ "eu-central-1" => "Z1U9ULNL0V5AJ3",
83
+ "eu-west-1" => "ZLY8HYME6SFDD",
84
+ "eu-west-2" => "ZJ5UAJN8Y3Z2Q",
85
+ "eu-west-3" => "Z3KY65QIEKYHQQ",
86
+ "sa-east-1" => "ZCMLWB8V5SYIT"
87
+ }
88
+
69
89
  class << self
70
90
  def normalize_dns_name_options(src)
71
91
  dst = {}
@@ -100,6 +120,8 @@ module Aws
100
120
  elsif name =~ /\.([^.]+)\.elasticbeanstalk\.com\z/i
101
121
  region = $1.downcase
102
122
  eb_dns_name_to_alias_target(name, region)
123
+ elsif name =~ /(\A|\.)\.execute-api\.([^.]+)\.amazonaws\.com\z/i
124
+ apigw_dns_name_to_alias_target(name, hosted_zone_id, options)
103
125
  else
104
126
  raise "Invalid DNS Name: #{name}"
105
127
  end
@@ -143,6 +165,14 @@ module Aws
143
165
  }
144
166
  end
145
167
 
168
+ def apigw_dns_name_to_alias_target(name, region, hosted_zone_id)
169
+ {
170
+ :hosted_zone_id => API_GATEWAY_HOSTED_ZONE_NAME_IDS[region],
171
+ :dns_name => name,
172
+ :evaluate_target_health => false, # XXX:
173
+ }
174
+ end
175
+
146
176
  def cf_dns_name_to_alias_target(name)
147
177
  {
148
178
  :hosted_zone_id => CF_HOSTED_ZONE_ID,
@@ -1,3 +1,3 @@
1
1
  module Roadworker
2
- VERSION = "0.5.9.beta7"
2
+ VERSION = "0.5.9.beta9"
3
3
  end
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.beta7
4
+ version: 0.5.9.beta9
5
5
  platform: ruby
6
6
  authors:
7
7
  - winebarrel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-20 00:00:00.000000000 Z
11
+ date: 2018-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-route53
@@ -39,19 +39,19 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: net-dns2
42
+ name: dnsruby
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 0.8.6
47
+ version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 0.8.6
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: uuid
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -252,7 +252,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
252
252
  version: 1.3.1
253
253
  requirements: []
254
254
  rubyforge_project:
255
- rubygems_version: 2.6.13
255
+ rubygems_version: 2.7.6
256
256
  signing_key:
257
257
  specification_version: 4
258
258
  summary: Roadworker is a tool to manage Route53.