vagrant-command-dns 0.2.1 → 0.2.2

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
2
  SHA1:
3
- metadata.gz: b411197419ba64b4a43e66157cae7983eea8fa08
4
- data.tar.gz: f4285387240a7f19431a60306937d1f80427e084
3
+ metadata.gz: a921c3aac515f2f952652dde47523061eeb45681
4
+ data.tar.gz: 88cdba1cfb041273376cd368307727c0ddaf1350
5
5
  SHA512:
6
- metadata.gz: cdc10966cde761d47c266c74f463cf352b505b5c7d82798a7a7e0b0cb02097881eeadecfbaa5ab245d586a0d0326fa0f904e922b08667f54a935b7766b160873
7
- data.tar.gz: 41e08550046de23227dc4af2a457174078d3b04cc39141862d33fc57c1f8c38647b4a1da0eb1a47f018df99ee103d726a798d157cbb608c3b66fedfba630a599
6
+ metadata.gz: 787e056efa6e7ba10ffc7d4dc101160cd19dba72443fae8d9918c010a8b6b0012f268daa771e84dd3254eb9496e283c60e74f72bb67c14ea77c4caa711ef850f
7
+ data.tar.gz: 8b17d9639e287d830151c490b70cd93a32d89e030734a962e2bf03fec12ac6092ccdcb09eec27fd7ac47e818ba13d2c0f42f6bdbe5e37d4fd3e030e9834eaf28
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  group :development do
4
- gem 'vagrant', '~> 1.7.4'
4
+ gem 'vagrant', '~> 1.8.1'
5
5
  end
6
6
 
7
7
  group :plugins do
data/README.md CHANGED
@@ -6,6 +6,25 @@ VagrantPlugins::CommandDns
6
6
  Todo:
7
7
  - add confirm to destroy subcommands
8
8
  - add windows support
9
+ - add guest /etc/hosts editing
10
+ - add dns server option
11
+
12
+
13
+ ## Motivation
14
+ - Hostsupdater does not have an enable/disable option
15
+ - Hostsupdater requires that a Vagrantfile specify a static address
16
+ - External DNS support should not be tied to the vagrant provider
17
+ - Action hooks are a poor way to manage DNS
18
+
19
+
20
+ ## Goals
21
+ - Create a plugin that can incorporate all other existing DNS plugins
22
+ - ?
23
+ - Profit!
24
+
25
+
26
+ ## Is it any good?
27
+ [Yes](http://news.ycombinator.com/item?id=3067434)
9
28
 
10
29
 
11
30
  # Installation
@@ -21,10 +21,6 @@ module VagrantPlugins
21
21
  File.open('/etc/hosts', 'r') do |file|
22
22
  file.each_line do |line|
23
23
  env[:record_map].each do |hostname, ip|
24
- if env[:machine].config.dns.skip_aliases.include? hostname
25
- env[:ui].info(I18n.t('vagrant_command_dns.command.common.skip_alias', hostname: hostname))
26
- next
27
- end
28
24
  precise_pattern = Regexp.new('^\s*' + ip + '\s+' + hostname)
29
25
  loose_pattern = Regexp.new('^\s*[0-9]{1,3}[0-9]{1,3}[0-9]{1,3}[0-9]{1,3}\s+' + hostname)
30
26
  if line.match(/#{precise_pattern}/)
@@ -39,7 +35,11 @@ module VagrantPlugins
39
35
 
40
36
  lines = []
41
37
  record_map.each do |hostname, ip|
42
- lines.push("#{ip} #{hostname}")
38
+ if env[:machine].config.dns.host_skip_aliases.include?(hostname)
39
+ env[:ui].info(I18n.t('vagrant_command_dns.command.host.skip_alias', hostname: hostname))
40
+ else
41
+ lines.push("#{ip} #{hostname}")
42
+ end
43
43
  end
44
44
 
45
45
  if lines.length > 0
@@ -18,50 +18,51 @@ module VagrantPlugins
18
18
  end
19
19
 
20
20
  env[:record_map].each do |hostname, ip|
21
- if env[:machine].config.dns.skip_aliases.include? hostname
22
- env[:ui].info(I18n.t('vagrant_command_dns.command.common.skip_alias', hostname: hostname))
21
+ if env[:machine].config.dns.route53_skip_aliases.include?(hostname)
22
+ env[:ui].info(I18n.t('vagrant_command_dns.command.route53.skip_alias', hostname: hostname))
23
23
  next
24
- end
25
- @logger.info("Checking for existing '#{hostname}' Route53 record...")
26
-
27
- record_name = hostname + '.' unless hostname.end_with?('.')
24
+ else
25
+ @logger.info("Checking for existing '#{hostname}' Route53 record...")
28
26
 
29
- begin
30
- zone = env[:route53].zones.get(env[:machine].config.dns.route53_zone_id)
31
- record = zone.records.get(record_name)
32
- rescue Excon::Errors::SocketError
33
- env[:ui].error(I18n.t('vagrant_command_dns.command.route53.fog_error',
34
- message: 'Unable to reach AWS. Are you connected to the internet?'))
35
- rescue Fog::DNS::AWS::Error => err
36
- env[:ui].error(I18n.t('vagrant_command_dns.command.route53.fog_error',
37
- message: err.message))
38
- end
27
+ record_name = hostname + '.' unless hostname.end_with?('.')
39
28
 
40
- if record.nil? || record.attributes[:name] != record_name
41
- @logger.info('Creating Route53 record...')
42
29
  begin
43
- new_record = zone.records.new({
44
- :value => ip,
45
- :name => record_name,
46
- :type => 'A',
47
- :ttl => '60'
48
- })
49
- new_record.save
30
+ zone = env[:route53].zones.get(env[:machine].config.dns.route53_zone_id)
31
+ record = zone.records.get(record_name)
32
+ rescue Excon::Errors::SocketError
33
+ env[:ui].error(I18n.t('vagrant_command_dns.command.route53.fog_error',
34
+ message: 'Unable to reach AWS. Are you connected to the internet?'))
50
35
  rescue Fog::DNS::AWS::Error => err
51
36
  env[:ui].error(I18n.t('vagrant_command_dns.command.route53.fog_error',
52
- message: err.message))
37
+ message: err.message))
53
38
  end
54
- env[:ui].info(I18n.t('vagrant_command_dns.command.route53.create_success',
55
- ip: ip, hostname: hostname))
56
39
 
57
- elsif record.attributes[:value][0] == ip
58
- env[:ui].info(I18n.t('vagrant_command_dns.command.route53.create_exists_match',
59
- ip: ip, hostname: hostname))
40
+ if record.nil? || record.attributes[:name] != record_name
41
+ @logger.info('Creating Route53 record...')
42
+ begin
43
+ new_record = zone.records.new({
44
+ :value => ip,
45
+ :name => record_name,
46
+ :type => 'A',
47
+ :ttl => '60'
48
+ })
49
+ new_record.save
50
+ rescue Fog::DNS::AWS::Error => err
51
+ env[:ui].error(I18n.t('vagrant_command_dns.command.route53.fog_error',
52
+ message: err.message))
53
+ end
54
+ env[:ui].info(I18n.t('vagrant_command_dns.command.route53.create_success',
55
+ ip: ip, hostname: hostname))
56
+
57
+ elsif record.attributes[:value][0] == ip
58
+ env[:ui].info(I18n.t('vagrant_command_dns.command.route53.create_exists_match',
59
+ ip: ip, hostname: hostname))
60
60
 
61
- elsif record.attributes[:value][0] != ip
62
- env[:ui].warn(I18n.t('vagrant_command_dns.command.route53.create_exists_conflict',
63
- ip: ip, hostname: hostname))
61
+ elsif record.attributes[:value][0] != ip
62
+ env[:ui].warn(I18n.t('vagrant_command_dns.command.route53.create_exists_conflict',
63
+ ip: ip, hostname: hostname))
64
64
 
65
+ end
65
66
  end
66
67
  end
67
68
 
@@ -7,12 +7,19 @@ module VagrantPlugins
7
7
  # @return [Array<String>]
8
8
  attr_accessor :aliases
9
9
 
10
+ ### Host Settings
11
+
10
12
  # List of disallowed aliases in FQDN format
11
13
  #
12
14
  # @return [Array<String>]
13
- attr_accessor :skip_aliases
15
+ attr_accessor :host_skip_aliases
16
+
17
+ ### AWS Route53 Settings
14
18
 
15
- # AWS Route53 Settings
19
+ # List of disallowed aliases in FQDN format
20
+ #
21
+ # @return [Array<String>]
22
+ attr_accessor :route53_skip_aliases
16
23
 
17
24
  # The version of the AWS api to use
18
25
  #
@@ -43,8 +50,10 @@ module VagrantPlugins
43
50
 
44
51
  def initialize
45
52
  @aliases = UNSET_VALUE
46
- @skip_aliases = UNSET_VALUE
47
53
 
54
+ @host_skip_aliases = UNSET_VALUE
55
+
56
+ @route53_skip_aliases = UNSET_VALUE
48
57
  @route53_version = UNSET_VALUE
49
58
  @route53_access_key_id = UNSET_VALUE
50
59
  @route53_secret_access_key = UNSET_VALUE
@@ -57,7 +66,10 @@ module VagrantPlugins
57
66
 
58
67
  def finalize!
59
68
  @aliases = [] if @aliases == UNSET_VALUE
60
- @skip_aliases = [] if @skip_aliases == UNSET_VALUE
69
+
70
+ @host_skip_aliases = [] if @host_skip_aliases == UNSET_VALUE
71
+
72
+ @route53_skip_aliases = [] if @route53_skip_aliases == UNSET_VALUE
61
73
 
62
74
  @route53_version = nil if @route53_version == UNSET_VALUE
63
75
  @route53_zone_id = nil if @route53_zone_id == UNSET_VALUE
@@ -72,6 +84,10 @@ module VagrantPlugins
72
84
  def validate(machine)
73
85
  errors = _detected_errors
74
86
 
87
+ errors << I18n.t('vagrant_command_dns.config.common.aliases_list_required') unless @aliases.kind_of? Array
88
+
89
+ errors << I18n.t('vagrant_command_dns.config.host.skip_aliases_list_required') unless @host_skip_aliases.kind_of? Array
90
+
75
91
  if machine.provider_name == :aws
76
92
  aws_config = machine.provider_config
77
93
  # If these values are still not set and the AWS provider is being used, borrow it's config values
@@ -81,10 +97,9 @@ module VagrantPlugins
81
97
  @route53_session_token = aws_config.session_token if @route53_session_token == nil
82
98
  end
83
99
 
84
- errors << I18n.t('vagrant_command_dns.config.aliases_list_required') unless @aliases.kind_of? Array
85
- errors << I18n.t('vagrant_command_dns.config.skip_aliases_list_required') unless @skip_aliases.kind_of? Array
100
+ errors << I18n.t('vagrant_command_dns.config.route53.skip_aliases_list_required') unless @route53_skip_aliases.kind_of? Array
86
101
 
87
- { 'DNS' => errors }
102
+ { :DNS => errors }
88
103
  end
89
104
 
90
105
  end
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module CommandDns
3
- VERSION = '0.2.1'
3
+ VERSION = '0.2.2'
4
4
  end
5
5
  end
data/locales/en.yml CHANGED
@@ -10,10 +10,13 @@ en:
10
10
  %{errors}
11
11
  missing_field: "The following settings are missing: %{field}"
12
12
  aliases_list_required: "'aliases' must be a list of FQDNs."
13
- skip_aliases_list_required: "'skip_aliases' must be a list of FQDNs."
14
13
  network_skip: "Skip requested for network in Vagrantfile."
15
14
 
15
+ host:
16
+ skip_aliases_list_required: "'host_skip_aliases' must be a list of FQDNs."
17
+
16
18
  route53:
19
+ skip_aliases_list_required: "'route53_skip_aliases' must be a list of FQDNs."
17
20
  access_key_id_required: "An access key ID must be specified via 'route53_access_key_id'"
18
21
  secret_access_key_required: "A secret access key is required via 'route53_secret_access_key'"
19
22
 
@@ -35,6 +38,7 @@ en:
35
38
  create_exists_match: "/etc/hosts record exists for %{ip} %{hostname}."
36
39
  create_exists_conflict: "Potentially conflicting entries found in /etc/hosts. Please update manually..."
37
40
  destroy_success: "/etc/hosts record destroyed for %{hostname}."
41
+ skip_alias: "%{hostname} specified via 'host_skip_aliases'. Skipping creation..."
38
42
 
39
43
  route53:
40
44
  fog_error: "AWS error: %{message}"
@@ -44,3 +48,4 @@ en:
44
48
  destroy_success: "Route53 record destroyed for %{hostname}."
45
49
  destroy_conflict: "Route53 record for %{hostname} does not match. Expected %{expected} got %{got}. Please update manually..."
46
50
  destroy_not_found: "Route53 record for %{hostname} not found. Skipping..."
51
+ skip_alias: "%{hostname} specified via 'route53_skip_aliases'. Skipping creation..."
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-command-dns
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - cornfeedhobo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-07 00:00:00.000000000 Z
11
+ date: 2016-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog