landrush 1.1.0.beta.1 → 1.1.0.beta.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -0
  3. data/.rubocop_todo.yml +5 -14
  4. data/.travis.yml +1 -1
  5. data/README.md +29 -5
  6. data/lib/landrush.rb +0 -2
  7. data/lib/landrush/action/setup.rb +2 -12
  8. data/lib/landrush/cap/{all → guest/all}/read_host_visible_ip_address.rb +0 -0
  9. data/lib/landrush/cap/{debian → guest/debian}/install_iptables.rb +0 -0
  10. data/lib/landrush/cap/{debian → guest/debian}/iptables_installed.rb +0 -0
  11. data/lib/landrush/cap/{linux → guest/linux}/add_iptables_rule.rb +1 -1
  12. data/lib/landrush/cap/{linux → guest/linux}/configured_dns_servers.rb +0 -0
  13. data/lib/landrush/cap/{linux → guest/linux}/redirect_dns.rb +0 -0
  14. data/lib/landrush/cap/{redhat → guest/redhat}/install_iptables.rb +0 -0
  15. data/lib/landrush/cap/{redhat → guest/redhat}/iptables_installed.rb +0 -0
  16. data/lib/landrush/cap/host/darwin/configure_visibility_on_host.rb +62 -0
  17. data/lib/landrush/cap/host/debian/dnsmasq_installed.rb +11 -0
  18. data/lib/landrush/cap/host/debian/host.rb +11 -0
  19. data/lib/landrush/cap/host/debian/install_dnsmasq.rb +12 -0
  20. data/lib/landrush/cap/host/debian/restart_dnsmasq.rb +11 -0
  21. data/lib/landrush/cap/host/linux/configure_visibility_on_host.rb +18 -0
  22. data/lib/landrush/cap/host/linux/create_dnsmasq_config.rb +65 -0
  23. data/lib/landrush/cap/host/redhat/dnsmasq_installed.rb +11 -0
  24. data/lib/landrush/cap/host/redhat/install_dnsmasq.rb +14 -0
  25. data/lib/landrush/cap/host/redhat/restart_dnsmasq.rb +23 -0
  26. data/lib/landrush/cap/host/ubuntu/host.rb +12 -0
  27. data/lib/landrush/cap/host/windows/configure_visibility_on_host.rb +187 -0
  28. data/lib/landrush/config.rb +22 -15
  29. data/lib/landrush/plugin.rb +68 -8
  30. data/lib/landrush/version.rb +1 -1
  31. data/test/landrush/action/setup_test.rb +4 -34
  32. data/test/landrush/cap/{all → guest/all}/read_host_visible_ip_address_test.rb +1 -1
  33. data/test/landrush/cap/{linux → guest/linux}/configured_dns_servers_test.rb +1 -1
  34. data/test/landrush/cap/{linux → guest/linux}/redirect_dns_test.rb +2 -5
  35. data/test/landrush/cap/host/darwin/configure_visibility_on_host_test.rb +56 -0
  36. data/test/landrush/cap/host/linux/configure_visibility_on_host_test.rb +34 -0
  37. data/test/landrush/cap/host/windows/configure_visibility_on_host_test.rb +70 -0
  38. data/test/test_helper.rb +28 -17
  39. metadata +34 -26
  40. data/lib/landrush/resolver_config.rb +0 -68
  41. data/lib/landrush/win_network_config.rb +0 -185
  42. data/test/landrush/resolver_config_test.rb +0 -19
  43. data/test/landrush/win_network_config_test.rb +0 -70
  44. data/test/support/fake_resolver_config.rb +0 -25
  45. data/test/support/fake_ui.rb +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e6fdf85d7935a91c069c3502b4be6a10c97937e5
4
- data.tar.gz: d3ee3e5dc3b09473d3a401225e97ee631d450e39
3
+ metadata.gz: 89f28bf5fa282162cba9dc132f50560eb81c75d9
4
+ data.tar.gz: 25859eb10f91b1c228f8c4b0e80db1a6f27b664f
5
5
  SHA512:
6
- metadata.gz: 3ef9fea8ed8a474c5eb6ee8e4ee6af181c5321941c8c4a249ed9599a621daf331d4313ae436d0ccffb3d6abb2ec56b312ef0126c029c79ec44d7b2eb4c023a95
7
- data.tar.gz: 6b09eba1246096affd1f44a999fb80048c84df0efc8b0f8db0df006dcd07aa5769980ce02992992a4f623a405087198bf910f029e75e35eba11cdf23b80f1237
6
+ metadata.gz: b407b73d6ad43a9c40407d31e2512526180044f82705d7434476f8e22be53cec32ec8748edb4ef63890355365917eb1a5290dfc1016ae026da7784ff12cc3f7e
7
+ data.tar.gz: db40198c92d2efc3933ca00e9339ceba69c7f607d5118a438d0d2c9614ba2a183914ce3f26b5c028515d60e936fd6b132ef19698218732fa773f2b94678dae07
data/.rubocop.yml CHANGED
@@ -5,3 +5,4 @@ AllCops:
5
5
  - 'build/**/*'
6
6
  - 'vendor/**/*'
7
7
  - 'tmp/**/*'
8
+
data/.rubocop_todo.yml CHANGED
@@ -89,7 +89,6 @@ Style/GuardClause:
89
89
  Exclude:
90
90
  - 'lib/landrush/action/teardown.rb'
91
91
  - 'lib/landrush/server.rb'
92
- - 'test/support/fake_resolver_config.rb'
93
92
  - 'test/support/test_server_daemon.rb'
94
93
 
95
94
  # Offense count: 13
@@ -107,7 +106,6 @@ Style/IfUnlessModifier:
107
106
  - 'lib/landrush/action/common.rb'
108
107
  - 'lib/landrush/config.rb'
109
108
  - 'lib/landrush/server.rb'
110
- - 'test/support/fake_resolver_config.rb'
111
109
  - 'test/support/test_server_daemon.rb'
112
110
 
113
111
  # Offense count: 4
@@ -117,13 +115,6 @@ Style/IfUnlessModifier:
117
115
  Style/IndentArray:
118
116
  EnforcedStyle: consistent
119
117
 
120
-
121
- # Offense count: 5
122
- # Cop supports --auto-correct.
123
- Style/MutableConstant:
124
- Exclude:
125
- - 'issues/vbox/Vagrantfile'
126
-
127
118
  # Offense count: 1
128
119
  # Cop supports --auto-correct.
129
120
  # Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles.
@@ -138,7 +129,7 @@ Style/Next:
138
129
  Style/PercentLiteralDelimiters:
139
130
  Exclude:
140
131
  - 'landrush.gemspec'
141
- - 'lib/landrush/cap/linux/redirect_dns.rb'
132
+ - 'lib/landrush/cap/guest/linux/redirect_dns.rb'
142
133
  - 'test/landrush/action/setup_test.rb'
143
134
  - 'test/landrush/store_test.rb'
144
135
 
@@ -148,7 +139,7 @@ Style/PercentLiteralDelimiters:
148
139
  # SupportedStyles: lower_case_q, upper_case_q
149
140
  Style/PercentQLiterals:
150
141
  Exclude:
151
- - 'lib/landrush/cap/linux/read_host_visible_ip_address.rb'
142
+ - 'lib/landrush/cap/guest/linux/read_host_visible_ip_address.rb'
152
143
 
153
144
 
154
145
  # Offense count: 7
@@ -200,7 +191,7 @@ Style/StringLiterals:
200
191
  # IgnoredMethods: respond_to
201
192
  Style/SymbolProc:
202
193
  Exclude:
203
- - 'lib/landrush/cap/linux/read_host_visible_ip_address.rb'
194
+ - 'lib/landrush/cap/guest/linux/read_host_visible_ip_address.rb'
204
195
 
205
196
  # Offense count: 2
206
197
  # Cop supports --auto-correct.
@@ -216,5 +207,5 @@ Style/TrivialAccessors:
216
207
  Style/UnneededPercentQ:
217
208
  Exclude:
218
209
  - 'landrush.gemspec'
219
- - 'lib/landrush/cap/linux/add_iptables_rule.rb'
220
- - 'lib/landrush/cap/linux/read_host_visible_ip_address.rb'
210
+ - 'lib/landrush/cap/guest/linux/add_iptables_rule.rb'
211
+ - 'lib/landrush/cap/guest/linux/read_host_visible_ip_address.rb'
data/.travis.yml CHANGED
@@ -8,7 +8,7 @@ cache: bundler
8
8
  rvm:
9
9
  - 2.0.0
10
10
 
11
- sudo: false
11
+ sudo: required
12
12
 
13
13
  addons:
14
14
  apt:
data/README.md CHANGED
@@ -28,6 +28,7 @@ problems using Landrush on Windows please let us know.
28
28
  - [Additional CLI commands](#additional-cli-commands)
29
29
  - [Miscellaneous Tricks and Tips](#miscellaneous-tricks-and-tips)
30
30
  - [How to avoid providing sudo password on OS X](#how-to-avoid-providing-sudo-password-on-os-x)
31
+ - [Guest is unable to access the Internet](#guest-is-unable-to-access-the-internet)
31
32
  - [Development](#development)
32
33
  - [Help Out!](#help-out)
33
34
 
@@ -146,8 +147,9 @@ work for anything.
146
147
  <a name="unmatched-queries"></a>
147
148
  ### Unmatched Queries
148
149
 
149
- Any DNS queries that do not match will be passed through to an upstream DNS server, so this will be
150
- able to serve as the one-stop shop for your guests' DNS needs.
150
+ Any DNS queries that do not match any of Landrush'es configuration data, will be passed
151
+ through to an upstream DNS server. Per default Landrush uses Google's DNS server with the
152
+ IP _8.8.8.8_.
151
153
 
152
154
  If you would like to configure your own upstream servers, add upstream entries to your
153
155
  `Vagrantfile` like so:
@@ -177,7 +179,12 @@ through the host's VPN connection).
177
179
  ### Visibility on the Host
178
180
 
179
181
  Visibility on the host means that the hostname of the VMs can be resolved on the host's DNS system.
180
- Depending on the OS this might require some manual configuration.
182
+ Landrush will attempt an automatic configuration of the host, but depending on the OS, manual
183
+ configuration might be required as well.
184
+
185
+ To disable this functionality:
186
+
187
+ config.landrush.host_redirect_dns = false
181
188
 
182
189
  <a name="os-x"></a>
183
190
  #### OS X
@@ -190,8 +197,11 @@ that points lookups for hostnames ending in your `config.landrush.tld` domain to
190
197
  <a name="linux"></a>
191
198
  #### Linux
192
199
 
193
- Though it's not automatically set up by Landrush, similar behavior can be achieved on Linux hosts
194
- with `dnsmasq`. You can integrate Landrush with `dnsmasq` on Ubuntu like so (tested on Ubuntu 13.10):
200
+ Landrush tries to achieve the same behavior on Linux hosts using
201
+ `dnsmasq`. For some Linux distributions this happens automatically (you might
202
+ have to provide your _sudo_ password). If Landrush does not know how to install and
203
+ start `dnsmasq` on your favorite Linux distribution, you can adjust the following
204
+ example from Ubuntu:
195
205
 
196
206
  sudo apt-get install -y resolvconf dnsmasq
197
207
  sudo sh -c 'echo "server=/vagrant.test/127.0.0.1#10053" > /etc/dnsmasq.d/vagrant-landrush'
@@ -308,6 +318,20 @@ configuration. Make sure to edit your `/etc/sudoers` configuration via `sudo vis
308
318
  %admin ALL=(ALL) NOPASSWD: VAGRANT_LANDRUSH_HOST_MKDIR, VAGRANT_LANDRUSH_HOST_CP, VAGRANT_LANDRUSH_HOST_CHMOD
309
319
  # End Landrush config
310
320
 
321
+ <a name="guest-is-unable-to-access-the-internet"></a>
322
+ ### Guest is unable to access the Internet
323
+
324
+ In some network configuration the access to outside DNS servers is restricted
325
+ (firewalls, VPN, etc). Since unmatched DNS queries are per default passed through to
326
+ Google's DNS servers, this can lead to the fact that the guest cannot access anything
327
+ in the outside world.
328
+ If you are having problem with the guest's DNS, verify that you can access Google's
329
+ DNS server under _8.8.8.8_. If it does not work, you will need to set a custom
330
+ upstream DNS server. Check your network configuration on the host or ask your network
331
+ administrator about the right DNS server address to use. You can set the custom
332
+ DNS server via the _config.landrush.upstream_ option (see section about
333
+ [unmatched queries](#unmatched-queries)).
334
+
311
335
  <a name="development"></a>
312
336
  ## Development
313
337
 
data/lib/landrush.rb CHANGED
@@ -12,8 +12,6 @@ require 'rubydns'
12
12
 
13
13
  require 'landrush/dependent_vms'
14
14
  require 'landrush/plugin'
15
- require 'landrush/resolver_config'
16
- require 'landrush/win_network_config'
17
15
  require 'landrush/server'
18
16
  require 'landrush/store'
19
17
  require 'landrush/version'
@@ -34,24 +34,14 @@ module Landrush
34
34
  def post_boot_setup
35
35
  record_machine_dns_entry
36
36
  setup_static_dns
37
- setup_host_resolver(env)
37
+ return unless machine.config.landrush.host_redirect_dns?
38
+ env[:host].capability(:configure_visibility_on_host, host_ip_address, config.tld)
38
39
  end
39
40
 
40
41
  def record_dependent_vm
41
42
  DependentVMs.add(machine_hostname)
42
43
  end
43
44
 
44
- def setup_host_resolver(env)
45
- if Vagrant::Util::Platform.windows?
46
- network_config = WinNetworkConfig.new(env)
47
- if network_config.ensure_prerequisites
48
- network_config.update_network_adapter(host_ip_address, '127.0.0.1', config.tld)
49
- end
50
- elsif Vagrant::Util::Platform.darwin?
51
- ResolverConfig.new(env).ensure_config_exists!
52
- end
53
- end
54
-
55
45
  def add_prerequisite_network_interface
56
46
  return unless virtualbox? && !private_network_exists?
57
47
 
@@ -3,7 +3,7 @@ module Landrush
3
3
  module Linux
4
4
  module AddIptablesRule
5
5
  def self.add_iptables_rule(machine, rule)
6
- _run(machine, %Q(iptables -C #{rule} 2> /dev/null || iptables -A #{rule}))
6
+ _run(machine, %(iptables -C #{rule} 2> /dev/null || iptables -A #{rule}))
7
7
  end
8
8
 
9
9
  def self._run(machine, command)
@@ -0,0 +1,62 @@
1
+ module Landrush
2
+ module Cap
3
+ module Darwin
4
+ class ConfigureVisibilityOnHost
5
+ class << self
6
+ attr_writer :sudo, :config_dir
7
+
8
+ def configure_visibility_on_host(env, *_args)
9
+ @env = env
10
+ if contents_match?
11
+ info 'Host DNS resolver config looks good.'
12
+ else
13
+ info 'Need to configure the host.'
14
+ write_config!
15
+ end
16
+ end
17
+
18
+ private
19
+
20
+ def sudo
21
+ @sudo ||= 'sudo'
22
+ end
23
+
24
+ def config_dir
25
+ @config_dir ||= Pathname('/etc/resolver')
26
+ end
27
+
28
+ def info(msg)
29
+ @env.ui.info("[landrush] #{msg}") unless @env.nil?
30
+ end
31
+
32
+ def desired_contents
33
+ <<-EOS.gsub(/^ /, '')
34
+ # Generated by landrush, a vagrant plugin
35
+ nameserver 127.0.0.1
36
+ port #{Server.port}
37
+ EOS
38
+ end
39
+
40
+ def config_file
41
+ config_dir.join(@env.vagrantfile.config.landrush.tld)
42
+ end
43
+
44
+ def contents_match?
45
+ config_file.exist? && File.read(config_file) == desired_contents
46
+ end
47
+
48
+ def write_config!
49
+ info 'Momentarily using sudo to put the host config in place...'
50
+ system "#{self.class.sudo} mkdir #{config_dir}" unless config_dir.directory?
51
+ Tempfile.open('vagrant_landrush_host_config') do |f|
52
+ f.write(desired_contents)
53
+ f.close
54
+ system "#{sudo} cp #{f.path} #{config_file}"
55
+ system "#{sudo} chmod 644 #{config_file}"
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,11 @@
1
+ module Landrush
2
+ module Cap
3
+ module Debian
4
+ class DnsmasqInstalled
5
+ def self.dnsmasq_installed(_env)
6
+ system('dpkg -s dnsmasq > /dev/null 2>&1')
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Landrush
2
+ module Cap
3
+ module Debian
4
+ class DebianHost < Vagrant.plugin('2', 'host')
5
+ def detect?(_env)
6
+ system("cat /etc/issue | grep 'Debian' > /dev/null 2>&1")
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ module Landrush
2
+ module Cap
3
+ module Debian
4
+ class InstallDnsmasq
5
+ def self.install_dnsmasq(_env)
6
+ system('sudo apt-get update > /dev/null 2>&1')
7
+ system('sudo apt-get install -y resolvconf dnsmasq > /dev/null 2>&1')
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,11 @@
1
+ module Landrush
2
+ module Cap
3
+ module Debian
4
+ class RestartDnsmasq
5
+ def self.restart_dnsmasq(_env)
6
+ system('sudo service dnsmasq restart > /dev/null 2>&1')
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,18 @@
1
+ module Landrush
2
+ module Cap
3
+ module Linux
4
+ class ConfigureVisibilityOnHost
5
+ class << self
6
+ def configure_visibility_on_host(env, ip, tld)
7
+ env[:host].capability(:install_dnsmasq) unless env[:host].capability(:dnsmasq_installed)
8
+ env[:host].capability(:create_dnsmasq_config, ip, tld)
9
+ env[:host].capability(:restart_dnsmasq)
10
+ rescue Vagrant::Errors::CapabilityNotFound
11
+ env[:ui].info('Unable to automatically configure your host. Check the documentation for manual ' \
12
+ 'instructions to configure the visibility on the host.')
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,65 @@
1
+ module Landrush
2
+ module Cap
3
+ module Linux
4
+ module CreateDnsmasqConfig
5
+ class << self
6
+ def create_dnsmasq_config(env, _ip, tld)
7
+ @env = env
8
+ @tld = tld
9
+ if contents_match?
10
+ info 'Host dnsmasq config looks good.'
11
+ else
12
+ info 'Need to configure dnsmasq on host.'
13
+ write_config!
14
+ end
15
+ end
16
+
17
+ private
18
+
19
+ def info(msg)
20
+ @env.ui.info("[landrush] #{msg}") unless @env.nil?
21
+ end
22
+
23
+ def config_dir
24
+ @config_dir ||= Pathname('/etc/dnsmasq.d')
25
+ end
26
+
27
+ def desired_contents
28
+ <<-EOS.gsub(/^ +/, '')
29
+ # Generated by landrush, a vagrant plugin
30
+ server=/#{@tld}/127.0.0.1#10053
31
+ EOS
32
+ end
33
+
34
+ def config_file
35
+ config_dir.join("vagrant-landrush-#{@tld}")
36
+ end
37
+
38
+ def contents_match?
39
+ config_file.exist? && File.read(config_file) == desired_contents
40
+ end
41
+
42
+ def write_config!
43
+ info 'Momentarily using sudo to put the host config in place...'
44
+ system "sudo mkdir #{config_dir}" unless config_dir.directory?
45
+ Tempfile.open('vagrant_landrush_host_config') do |f|
46
+ f.write(desired_contents)
47
+ f.close
48
+ system "sudo cp #{f.path} #{config_file}"
49
+ system "sudo chmod 644 #{config_file}"
50
+ end
51
+ end
52
+
53
+ def ensure_config_exists!
54
+ if contents_match?
55
+ info 'Host DNS resolver config looks good.'
56
+ else
57
+ info 'Need to configure the host.'
58
+ write_config!
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,11 @@
1
+ module Landrush
2
+ module Cap
3
+ module Redhat
4
+ module DnsmasqInstalled
5
+ def self.dnsmasq_installed(_env, *_args)
6
+ system('rpm -qa | grep dnsmasq > /dev/null 2>&1')
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,14 @@
1
+ module Landrush
2
+ module Cap
3
+ module Redhat
4
+ module InstallDnsmasq
5
+ class << self
6
+ def install_dnsmasq(_env)
7
+ system('sudo yum clean all > /dev/null 2>&1')
8
+ system('sudo yum install -y -q dnsmasq > /dev/null 2>&1')
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end