vagrant-dns 0.5.0 → 0.6.0.beta1
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 +7 -0
- data/.gitignore +1 -0
- data/CHANGELOG.md +10 -0
- data/Gemfile +25 -7
- data/Rakefile +5 -0
- data/lib/vagrant-dns/command.rb +10 -9
- data/lib/vagrant-dns/installers/mac.rb +41 -11
- data/lib/vagrant-dns/version.rb +1 -1
- data/tasks/acceptance.rake +25 -0
- data/test/acceptance/dns/dns_spec.rb +72 -0
- data/test/acceptance/skeletons/dns/Vagrantfile +12 -0
- data/{Vagrantfile → testdrive/Vagrantfile} +5 -5
- data/testdrive/bin/vagrant +6 -0
- data/vagrant-dns.gemspec +3 -1
- data/vagrant-spec.config.rb +15 -0
- metadata +35 -21
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 50a969b5fa509b2a185b0962b5b13afad83c4254
|
4
|
+
data.tar.gz: 9e3c9a15a55c8d3c42283b13650f118b3945deb5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2ffb83a8cd804bbcf2af794a31756bbd3e6428ea00db3feb5ef0d9dc872fc4c4e3d50063c8e0ab779d4fe2bbcaa30def4a5f7f94ac2e3af7cfae87880335278f
|
7
|
+
data.tar.gz: 3d3c4d0c8d0476f6d627f58135003cdf16eafdc6b4435f85e87b9bd408548f565e0586094b3d265825e0fb4242cf3c991aa11f7f92cdacf3fb13a1a92f6893db
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
# 0.6.0 (unreleased / beta1)
|
2
|
+
|
3
|
+
This is a intermediate release towards v1.0.0
|
4
|
+
|
5
|
+
* Using RubyDNS ~> 0.8.4
|
6
|
+
* New option to un/install system files using `sudo` (restoring 0.4 behavior). Add `--with-sudo` to `--install`, `--uninstall` or `--purge`. [GH-26]
|
7
|
+
* Use new vagrant >= 1.5 development patterns [GH-31]
|
8
|
+
* Add acceptance test using vagrant-spec
|
9
|
+
* Moved sample `Vagrantfile` into `/testdrive` which also contains a small wrapper script `bin/vagrant` to move "vagrant home" into a sandbox.
|
10
|
+
|
1
11
|
# v0.4.1
|
2
12
|
|
3
13
|
* Fixes an issue with not configured private networks [GH-21], [GH-19]
|
data/Gemfile
CHANGED
@@ -1,11 +1,29 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
|
+
ruby '2.0.0'
|
2
3
|
|
3
|
-
|
4
|
-
gemspec
|
4
|
+
ENV['TEST_VAGRANT_VERSION'] ||= '~> v1.6.2'
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
# Using the :plugins group causes Vagrant to automagially load auto_network
|
7
|
+
# during acceptance tests.
|
8
|
+
group :plugins do
|
9
|
+
gemspec
|
10
|
+
end
|
11
|
+
|
12
|
+
group :test, :development do
|
13
|
+
if ENV['TEST_VAGRANT_VERSION'] == 'HEAD'
|
14
|
+
gem 'vagrant', :github => 'mitchellh/vagrant', :branch => 'master'
|
15
|
+
else
|
16
|
+
gem 'vagrant', :github => 'mitchellh/vagrant', :tag => ENV['TEST_VAGRANT_VERSION']
|
17
|
+
end
|
18
|
+
gem 'rubydns', :github => 'ioquatix/rubydns', :branch => 'master'
|
19
|
+
end
|
20
|
+
|
21
|
+
group :test do
|
22
|
+
# Pinned on 05/05/2014. Compatible with Vagrant 1.5.x and 1.6.x.
|
23
|
+
gem 'vagrant-spec', :github => 'mitchellh/vagrant-spec', :ref => 'aae28ee'
|
24
|
+
gem 'rake'
|
25
|
+
end
|
26
|
+
|
27
|
+
if File.exists? "#{__FILE__}.local"
|
28
|
+
eval(File.read("#{__FILE__}.local"), binding)
|
11
29
|
end
|
data/Rakefile
CHANGED
data/lib/vagrant-dns/command.rb
CHANGED
@@ -11,7 +11,7 @@ module VagrantDNS
|
|
11
11
|
def execute
|
12
12
|
options = {}
|
13
13
|
opts = OptionParser.new do |opts|
|
14
|
-
opts.banner = "Usage: vagrant dns [vm-name] [-i|--install] [-u|--uninstall] [--pruge] [-s|--start] [-S|--stop] [-r|--restart] [-o|--ontop]"
|
14
|
+
opts.banner = "Usage: vagrant dns [vm-name] [-i|--install] [-u|--uninstall] [--with-sudo] [--pruge] [-s|--start] [-S|--stop] [-r|--restart] [-o|--ontop]"
|
15
15
|
opts.separator ""
|
16
16
|
|
17
17
|
opts.on("--install", "-i", "Install DNS config for machine domain") do
|
@@ -22,8 +22,11 @@ module VagrantDNS
|
|
22
22
|
options[:uninstall] = true
|
23
23
|
end
|
24
24
|
|
25
|
+
opts.on("--with-sudo", "In conjunction with `--install`, `--uninstall`, `--purge`: Run using `sudo` instead of `osascript`. Useful for automated scripts running as sudoer.") do
|
26
|
+
options[:installer_opts] = { exec_style: :sudo }
|
27
|
+
end
|
28
|
+
|
25
29
|
opts.on("--purge", "Uninstall DNS config and remove DNS configurations of all machines.") do
|
26
|
-
options[:uninstall] = true
|
27
30
|
options[:purge] = true
|
28
31
|
end
|
29
32
|
|
@@ -49,14 +52,9 @@ module VagrantDNS
|
|
49
52
|
|
50
53
|
vms = argv unless argv.empty?
|
51
54
|
|
52
|
-
if options[:uninstall]
|
55
|
+
if options[:uninstall] || options[:purge]
|
53
56
|
manage_service(vms, options.merge(stop: true))
|
54
57
|
manage_installation(vms, options)
|
55
|
-
|
56
|
-
if options[:purge]
|
57
|
-
require 'fileutils'
|
58
|
-
FileUtils.rm_r(tmp_path)
|
59
|
-
end
|
60
58
|
else
|
61
59
|
build_config(vms, options)
|
62
60
|
manage_service(vms, options)
|
@@ -69,12 +67,15 @@ module VagrantDNS
|
|
69
67
|
|
70
68
|
def manage_installation(vms, options)
|
71
69
|
if Vagrant::Util::Platform.darwin?
|
72
|
-
|
70
|
+
installer_options = options.fetch(:installer_opts, {})
|
71
|
+
installer = VagrantDNS::Installers::Mac.new(tmp_path, installer_options)
|
73
72
|
|
74
73
|
if options[:install]
|
75
74
|
installer.install!
|
76
75
|
elsif options[:uninstall]
|
77
76
|
installer.uninstall!
|
77
|
+
elsif options[:purge]
|
78
|
+
installer.purge!
|
78
79
|
end
|
79
80
|
else
|
80
81
|
raise 'installing and uninstalling is only supported on Mac OS X at the moment.'
|
@@ -1,36 +1,66 @@
|
|
1
1
|
module VagrantDNS
|
2
2
|
module Installers
|
3
3
|
class Mac
|
4
|
-
|
4
|
+
EXEC_STYLES = %i{osa sudo}
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
attr_accessor :tmp_path, :install_path, :exec_style
|
7
|
+
|
8
|
+
def initialize(tmp_path, options = {})
|
9
|
+
self.tmp_path = tmp_path
|
10
|
+
self.install_path = options.fetch(:install_path, "/etc/resolver")
|
11
|
+
self.exec_style = options.fetch(:exec_style, :osa)
|
8
12
|
end
|
9
13
|
|
10
14
|
def install!
|
11
15
|
require 'fileutils'
|
12
16
|
|
13
|
-
|
14
|
-
|
15
|
-
|
17
|
+
commands = [
|
18
|
+
['mkdir', '-p', install_path]
|
19
|
+
]
|
20
|
+
|
21
|
+
commands += registered_resolvers.map do |resolver|
|
22
|
+
['ln', '-sf', resolver.shellescape, install_path.shellescape]
|
16
23
|
end
|
17
|
-
|
24
|
+
|
25
|
+
exec(*commands)
|
18
26
|
end
|
19
27
|
|
20
28
|
def uninstall!
|
21
29
|
require 'fileutils'
|
22
30
|
|
23
|
-
|
24
|
-
registered_resolvers.each do |r|
|
31
|
+
commands = registered_resolvers.map do |r|
|
25
32
|
installed_resolver = File.join(install_path, File.basename(r))
|
26
|
-
|
33
|
+
['rm', '-rf', installed_resolver]
|
27
34
|
end
|
28
|
-
|
35
|
+
|
36
|
+
exec(*commands)
|
37
|
+
end
|
38
|
+
|
39
|
+
def purge!
|
40
|
+
require 'fileutils'
|
41
|
+
uninstall!
|
42
|
+
FileUtils.rm_r(tmp_path)
|
29
43
|
end
|
30
44
|
|
31
45
|
def registered_resolvers
|
32
46
|
Dir[File.join(tmp_path, "resolver", "*")]
|
33
47
|
end
|
48
|
+
|
49
|
+
def exec(*commands)
|
50
|
+
return if !commands || commands.empty?
|
51
|
+
|
52
|
+
case exec_style
|
53
|
+
when :osa
|
54
|
+
cmd_script = commands.map {|line| line.join ' ' }.join($/)
|
55
|
+
system 'osascript', '-e', "do shell script \"#{cmd_script}\" with administrator privileges"
|
56
|
+
when :sudo
|
57
|
+
commands.each do |c|
|
58
|
+
system 'sudo', *c
|
59
|
+
end
|
60
|
+
else
|
61
|
+
raise ArgumentError, "Unsupported execution style: #{exec_style}. Use one of #{EXEC_STYLES.map(&:inspect).join(' ')}"
|
62
|
+
end
|
63
|
+
end
|
34
64
|
end
|
35
65
|
end
|
36
66
|
end
|
data/lib/vagrant-dns/version.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
namespace :acceptance do
|
2
|
+
ARTIFACT_DIR = File.join('test', 'acceptance', 'artifacts')
|
3
|
+
TEST_BOXES = {
|
4
|
+
:virtualbox => 'http://files.vagrantup.com/precise32.box'
|
5
|
+
}
|
6
|
+
|
7
|
+
directory ARTIFACT_DIR
|
8
|
+
TEST_BOXES.each do |(provider, box_url)|
|
9
|
+
file File.join(ARTIFACT_DIR, "#{provider}.box") => ARTIFACT_DIR do |path|
|
10
|
+
puts 'Downloading: ' + box_url
|
11
|
+
Kernel.system 'curl', '-L', '-o', path.to_s, box_url
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
desc 'downloads test boxes and other artifacts'
|
16
|
+
task :setup => TEST_BOXES.map { |(provider, box_url)| File.join(ARTIFACT_DIR, "#{provider}.box") }
|
17
|
+
|
18
|
+
desc 'runs acceptance tests'
|
19
|
+
task :run => :setup do
|
20
|
+
command = 'vagrant-spec test'
|
21
|
+
puts command
|
22
|
+
puts
|
23
|
+
exec(command)
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
shared_examples 'provider/dns' do |provider, options|
|
2
|
+
|
3
|
+
if !File.file?(options[:box])
|
4
|
+
raise ArgumentError,
|
5
|
+
"A box file #{options[:box]} must be downloaded for provider: #{provider}. Try: rake acceptance:setup"
|
6
|
+
end
|
7
|
+
|
8
|
+
include_context 'acceptance'
|
9
|
+
|
10
|
+
let(:box_ip) { '10.10.10.101' }
|
11
|
+
let(:tld) { 'spec' }
|
12
|
+
let(:name) { 'single.testbox.spec' }
|
13
|
+
|
14
|
+
before do
|
15
|
+
ENV['VAGRANT_DEFAULT_PROVIDER'] = provider
|
16
|
+
environment.skeleton('dns')
|
17
|
+
end
|
18
|
+
|
19
|
+
describe 'installation' do
|
20
|
+
it 'creates and removes resolver link' do
|
21
|
+
assert_execute('vagrant', 'dns', '--install', '--with-sudo')
|
22
|
+
assert_execute('ls', "/etc/resolver/#{tld}")
|
23
|
+
|
24
|
+
assert_execute('vagrant', 'dns', '--uninstall', '--with-sudo')
|
25
|
+
result = execute('ls', "/etc/resolver/#{tld}")
|
26
|
+
expect(result).to_not exit_with(0)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'running' do
|
31
|
+
before do
|
32
|
+
assert_execute('vagrant', 'box', 'add', 'box', options[:box])
|
33
|
+
assert_execute('vagrant', 'dns', '--install', '--with-sudo')
|
34
|
+
assert_execute('vagrant', 'up', "--provider=#{provider}")
|
35
|
+
end
|
36
|
+
|
37
|
+
after do
|
38
|
+
# Ensure any VMs that survived tests are cleaned up.
|
39
|
+
assert_execute('vagrant', 'destroy', '--force', log: false)
|
40
|
+
assert_execute('vagrant', 'dns', '--uninstall', '--with-sudo')
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'auto-starts the DNS daemon' do
|
44
|
+
assert_execute('pgrep', '-lf', 'vagrant-dns')
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'registered as a resolver' do
|
48
|
+
expected_output = <<-TXT
|
49
|
+
domain : #{tld}
|
50
|
+
nameserver[0] : 127.0.0.1
|
51
|
+
port : 5333
|
52
|
+
flags : Request A records, Request AAAA records
|
53
|
+
reach : Reachable,Local Address
|
54
|
+
TXT
|
55
|
+
|
56
|
+
result = assert_execute('scutil', '--dns')
|
57
|
+
expect(result.stdout).to include(expected_output)
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'responds to host-names' do
|
61
|
+
result = assert_execute('dscacheutil', '-q', 'host', '-a', 'name', "#{name}")
|
62
|
+
expect(result.stdout).to include("ip_address: #{box_ip}")
|
63
|
+
|
64
|
+
result = assert_execute('dscacheutil', '-q', 'host', '-a', 'name', "www.#{name}")
|
65
|
+
expect(result.stdout).to include("ip_address: #{box_ip}")
|
66
|
+
|
67
|
+
result = execute('dscacheutil', '-q', 'host', '-a', 'name', "notthere.#{tld}")
|
68
|
+
expect(result.stdout).to_not include("ip_address: #{box_ip}")
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# -*- mode: ruby -*-
|
2
|
+
# vi: set ft=ruby :
|
3
|
+
|
4
|
+
Vagrant.configure("2") do |config|
|
5
|
+
config.vm.box = "box"
|
6
|
+
config.vm.network :private_network, ip: '10.10.10.101'
|
7
|
+
|
8
|
+
config.dns.tld = 'spec'
|
9
|
+
config.dns.patterns = /^.*single.testbox.spec$/
|
10
|
+
|
11
|
+
VagrantDNS::Config.listen = [[:udp, "0.0.0.0", 5333]]
|
12
|
+
end
|
@@ -1,21 +1,21 @@
|
|
1
1
|
# -*- mode: ruby -*-
|
2
2
|
# vi: set ft=ruby :
|
3
3
|
|
4
|
-
|
5
4
|
Vagrant.configure("2") do |config|
|
6
5
|
# All Vagrant configuration is done here. The most common configuration
|
7
6
|
# options are documented and commented below. For a complete reference,
|
8
7
|
# please see the online documentation at vagrantup.com.
|
9
8
|
|
10
9
|
# Every Vagrant virtual environment requires a box to build off of.
|
11
|
-
config.vm.box
|
10
|
+
config.vm.box = 'precise32'
|
11
|
+
config.vm.box_url = 'http://files.vagrantup.com/precise32.box'
|
12
12
|
|
13
|
-
config.dns.tld
|
14
|
-
config.dns.patterns = /^.*machine.
|
13
|
+
config.dns.tld = "test"
|
14
|
+
config.dns.patterns = /^.*machine.test$/
|
15
15
|
|
16
16
|
config.vm.hostname = "machine"
|
17
17
|
config.vm.network :private_network, ip: "33.33.33.60"
|
18
18
|
|
19
|
-
|
19
|
+
|
20
20
|
VagrantDNS::Config.listen = [[:udp, "0.0.0.0", 5300]]
|
21
21
|
end
|
data/vagrant-dns.gemspec
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require "vagrant-spec/acceptance"
|
3
|
+
|
4
|
+
Vagrant::Spec::Acceptance.configure do |c|
|
5
|
+
acceptance_dir = Pathname.new File.expand_path("../test/acceptance", __FILE__)
|
6
|
+
|
7
|
+
c.component_paths = [acceptance_dir.to_s]
|
8
|
+
c.skeleton_paths = [(acceptance_dir + 'skeletons').to_s]
|
9
|
+
|
10
|
+
c.provider 'virtualbox',
|
11
|
+
box: (acceptance_dir + 'artifacts' + 'virtualbox.box').to_s,
|
12
|
+
env_vars: {
|
13
|
+
'VBOX_USER_HOME' => '{{homedir}}',
|
14
|
+
}
|
15
|
+
end
|
metadata
CHANGED
@@ -1,48 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-dns
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.6.0.beta1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Florian Gilcher
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-05-17 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: daemons
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rubydns
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ~>
|
36
32
|
- !ruby/object:Gem::Version
|
37
|
-
version: 0.
|
33
|
+
version: 0.8.4
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ~>
|
44
39
|
- !ruby/object:Gem::Version
|
45
|
-
version: 0.
|
40
|
+
version: 0.8.4
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 2.14.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 2.14.0
|
46
55
|
description: vagrant-dns is a vagrant plugin that manages DNS records associated with
|
47
56
|
local machines.
|
48
57
|
email:
|
@@ -58,7 +67,6 @@ files:
|
|
58
67
|
- PLATFORM_SUPPORT.md
|
59
68
|
- README.md
|
60
69
|
- Rakefile
|
61
|
-
- Vagrantfile
|
62
70
|
- lib/vagrant-dns.rb
|
63
71
|
- lib/vagrant-dns/command.rb
|
64
72
|
- lib/vagrant-dns/config.rb
|
@@ -67,30 +75,36 @@ files:
|
|
67
75
|
- lib/vagrant-dns/restart_middleware.rb
|
68
76
|
- lib/vagrant-dns/service.rb
|
69
77
|
- lib/vagrant-dns/version.rb
|
78
|
+
- tasks/acceptance.rake
|
79
|
+
- test/acceptance/dns/dns_spec.rb
|
80
|
+
- test/acceptance/skeletons/dns/Vagrantfile
|
81
|
+
- testdrive/Vagrantfile
|
82
|
+
- testdrive/bin/vagrant
|
70
83
|
- vagrant-dns.gemspec
|
84
|
+
- vagrant-spec.config.rb
|
71
85
|
homepage: ''
|
72
86
|
licenses: []
|
87
|
+
metadata: {}
|
73
88
|
post_install_message:
|
74
89
|
rdoc_options: []
|
75
90
|
require_paths:
|
76
91
|
- lib
|
77
92
|
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
-
none: false
|
79
93
|
requirements:
|
80
|
-
- -
|
94
|
+
- - '>='
|
81
95
|
- !ruby/object:Gem::Version
|
82
96
|
version: '0'
|
83
97
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
-
none: false
|
85
98
|
requirements:
|
86
|
-
- -
|
99
|
+
- - '>'
|
87
100
|
- !ruby/object:Gem::Version
|
88
|
-
version:
|
101
|
+
version: 1.3.1
|
89
102
|
requirements: []
|
90
103
|
rubyforge_project:
|
91
|
-
rubygems_version:
|
104
|
+
rubygems_version: 2.0.14
|
92
105
|
signing_key:
|
93
|
-
specification_version:
|
106
|
+
specification_version: 4
|
94
107
|
summary: vagrant-dns manages DNS records of vagrant machines
|
95
|
-
test_files:
|
96
|
-
|
108
|
+
test_files:
|
109
|
+
- test/acceptance/dns/dns_spec.rb
|
110
|
+
- test/acceptance/skeletons/dns/Vagrantfile
|