landrush 0.5.0 → 0.6.0

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.
data/README.md CHANGED
@@ -24,7 +24,7 @@ Enable the plugin in your `Vagrantfile`:
24
24
 
25
25
  config.landrush.enable
26
26
 
27
- Bring up a machine that has a private network IP address and a hostname (see the `Vagrantfile` for an example)
27
+ Bring up a machine that has a hostname set (see the `Vagrantfile` for an example)
28
28
 
29
29
  $ vagrant up
30
30
 
data/examples/Vagrantfile CHANGED
@@ -17,8 +17,6 @@ Vagrant.configure("2") do |config|
17
17
 
18
18
  config.landrush.enable
19
19
 
20
- config.vm.network :private_network, ip: '172.16.32.111'
21
-
22
20
  config.vm.hostname = "myhost.vagrant.dev"
23
21
 
24
22
  config.landrush.host 'static1.example.com', '1.2.3.4'
@@ -0,0 +1,61 @@
1
+ module Landrush
2
+ module Action
3
+ module Common
4
+ SUPPORTED_PROVIDERS = {
5
+ 'VagrantPlugins::ProviderVirtualBox::Provider' => :virtualbox,
6
+ 'HashiCorp::VagrantVMwarefusion::Provider' => :vmware_fusion,
7
+ 'Landrush::FakeProvider' => :fake_provider,
8
+ }
9
+
10
+ def self.included(base)
11
+ base.send :attr_reader, :app, :env
12
+ end
13
+
14
+ def initialize(app, env)
15
+ @app = app
16
+ end
17
+
18
+ def handle_action_stack(env)
19
+ @env = env
20
+
21
+ yield
22
+
23
+ app.call(env)
24
+ end
25
+
26
+ def virtualbox?
27
+ provider == :virtualbox
28
+ end
29
+
30
+ def vmware?
31
+ provider == :vmware_fusion
32
+ end
33
+
34
+ def provider
35
+ SUPPORTED_PROVIDERS.fetch(machine.provider.class.name) { |key|
36
+ raise "The landrush plugin does not support the #{key} provider yet!"
37
+ }
38
+ end
39
+
40
+ def global_config
41
+ env[:global_config]
42
+ end
43
+
44
+ def machine
45
+ env[:machine]
46
+ end
47
+
48
+ def machine_hostname
49
+ machine.config.vm.hostname
50
+ end
51
+
52
+ def enabled?
53
+ global_config.landrush.enabled?
54
+ end
55
+
56
+ def info(msg)
57
+ env[:ui].info "[landrush] #{msg}"
58
+ end
59
+ end
60
+ end
61
+ end
@@ -1,25 +1,18 @@
1
1
  module Landrush
2
2
  module Action
3
3
  class InstallPrerequisites
4
- def initialize(app, env)
5
- @app = app
6
- end
4
+ include Common
7
5
 
8
6
  def call(env)
9
- if env[:global_config].landrush.enabled?
10
- @machine = env[:machine]
11
- @machine.ui.info('setting up prerequisites')
12
-
13
- install_prerequisites
7
+ handle_action_stack(env) do
8
+ install_prerequisites if enabled?
14
9
  end
15
-
16
- @app.call(env)
17
10
  end
18
11
 
19
12
  def install_prerequisites
20
- unless @machine.guest.capability(:iptables_installed)
21
- @machine.ui.info('iptables not installed, installing it')
22
- @machine.guest.capability(:install_iptables)
13
+ unless machine.guest.capability(:iptables_installed)
14
+ info 'iptables not installed, installing it'
15
+ machine.guest.capability(:install_iptables)
23
16
  end
24
17
  end
25
18
  end
@@ -1,32 +1,25 @@
1
1
  module Landrush
2
2
  module Action
3
3
  class RedirectDns
4
- SUPPORTED_PROVIDERS = {
5
- 'VagrantPlugins::ProviderVirtualBox::Provider' => :virtualbox,
6
- 'HashiCorp::VagrantVMwarefusion::Provider' => :vmware_fusion,
7
- }
8
-
9
- def initialize(app, env)
10
- @app = app
11
- end
4
+ include Common
12
5
 
13
6
  def call(env)
14
- if env[:global_config].landrush.enabled?
15
- @machine = env[:machine]
7
+ handle_action_stack(env) do
8
+ redirect_dns if enabled?
9
+ end
10
+ end
16
11
 
17
- @machine.ui.info "setting up machine's DNS to point to our server"
18
- @machine.guest.capability(:redirect_dns, host: _target_host, port: 10053)
12
+ def redirect_dns
13
+ info "setting up machine's DNS to point to our server"
14
+ machine.guest.capability(:redirect_dns, host: _target_host, port: 10053)
19
15
 
20
- @machine.config.vm.networks.each do |type, options|
21
- @machine.ui.info "network: #{type.inspect}, #{options.inspect}"
22
- end
16
+ machine.config.vm.networks.each do |type, options|
17
+ info "network: #{type.inspect}, #{options.inspect}"
23
18
  end
24
-
25
- @app.call(env)
26
19
  end
27
20
 
28
21
  def _target_host
29
- case _provider
22
+ case provider
30
23
  when :virtualbox then
31
24
  '10.0.2.2'
32
25
  when :vmware_fusion then
@@ -34,12 +27,6 @@ module Landrush
34
27
  end
35
28
  end
36
29
 
37
- def _provider
38
- SUPPORTED_PROVIDERS.fetch(@machine.provider.class.name) { |key|
39
- raise "I don't support the #{key} provider yet!"
40
- }
41
- end
42
-
43
30
  # Poor man's gateway; strip the last octet and jam a 1 on there.
44
31
  def _gateway_for_ip(ip)
45
32
  ip.split('.').tap(&:pop).push(1).join('.')
@@ -1,41 +1,62 @@
1
1
  module Landrush
2
2
  module Action
3
3
  class Setup
4
- def initialize(app, env)
5
- @app = app
6
- end
4
+ include Common
7
5
 
8
6
  def call(env)
9
- if env[:global_config].landrush.enabled?
10
- DependentVMs.add(env[:machine])
11
- start_server_if_necessary(env)
12
- setup_machine_dns(env)
13
- setup_static_dns(env)
7
+ handle_action_stack(env) do
8
+ pre_boot_setup if enabled?
14
9
  end
15
- @app.call(env)
10
+
11
+ # This is after the middleware stack returns, which, since we're right
12
+ # before the Network action, should mean that all interfaces are good
13
+ # to go.
14
+ record_machine_dns_entry if enabled?
16
15
  end
17
16
 
18
- def start_server_if_necessary(env)
19
- if Server.running?
20
- env[:ui].info "[landrush] dns server already running"
21
- else
22
- env[:ui].info "[landrush] starting dns server"
23
- Server.start
24
- end
17
+ def pre_boot_setup
18
+ record_dependent_vm
19
+ add_prerequisite_network_interface
20
+ start_server
21
+ setup_static_dns
22
+ end
23
+
24
+ def record_dependent_vm
25
+ DependentVMs.add(machine_hostname)
25
26
  end
26
27
 
27
- def setup_machine_dns(env)
28
- hostname, ip_address = Util.host_and_ip(env[:machine])
29
- env[:ui].info "[landrush] adding machine entry: #{hostname} => #{ip_address}"
30
- Store.hosts.set(hostname, ip_address)
28
+ def add_prerequisite_network_interface
29
+ return unless virtualbox? && !private_network_exists?
30
+
31
+ info 'virtualbox requires an additional private network; adding it'
32
+ machine.config.vm.network :private_network, type: :dhcp
31
33
  end
32
34
 
33
- def setup_static_dns(env)
34
- env[:global_config].landrush.hosts.each do |hostname, ip_address|
35
- env[:ui].info "[landrush] adding static entry: #{hostname} => #{ip_address}"
35
+ def start_server
36
+ return if Server.running?
37
+
38
+ info 'starting dns server'
39
+ Server.start
40
+ end
41
+
42
+ def setup_static_dns
43
+ global_config.landrush.hosts.each do |hostname, ip_address|
44
+ info "adding static entry: #{hostname} => #{ip_address}"
36
45
  Store.hosts.set hostname, ip_address
37
46
  end
38
47
  end
48
+
49
+ def record_machine_dns_entry
50
+ ip_address = machine.guest.capability(:read_host_visible_ip_address)
51
+
52
+ info "adding machine entry: #{machine_hostname} => #{ip_address}"
53
+
54
+ Store.hosts.set(machine_hostname, ip_address)
55
+ end
56
+
57
+ def private_network_exists?
58
+ machine.config.vm.networks.any? { |type, _| type == :private_network }
59
+ end
39
60
  end
40
61
  end
41
62
  end
@@ -1,48 +1,42 @@
1
1
  module Landrush
2
2
  module Action
3
3
  class Teardown
4
- def initialize(app, env)
5
- @app = app
6
- end
4
+ include Common
7
5
 
8
6
  def call(env)
9
- @env = env
10
- teardown if env[:global_config].landrush.enabled?
11
- @app.call(@env)
7
+ handle_action_stack(env) do
8
+ teardown if enabled?
9
+ end
12
10
  end
13
11
 
14
12
  def teardown
15
13
  teardown_machine_dns
16
- DependentVMs.remove(@env[:machine])
14
+ DependentVMs.remove(machine_hostname)
17
15
 
18
16
  if DependentVMs.none?
19
17
  teardown_static_dns
20
18
  teardown_server
21
19
  else
22
20
  info "there are #{DependentVMs.count} VMs left, leaving DNS server and static entries"
21
+ info DependentVMs.list.map { |dvm| " - #{dvm}" }.join("\n")
23
22
  end
24
23
  end
25
24
 
26
25
  def teardown_machine_dns
27
- hostname = Util.hostname(@env[:machine])
28
- info "removing machine entry: #{hostname}"
29
- Store.hosts.delete(hostname)
26
+ info "removing machine entry: #{machine_hostname}"
27
+ Store.hosts.delete(machine_hostname)
30
28
  end
31
29
 
32
30
  def teardown_static_dns
33
- @env[:global_config].landrush.hosts.each do |hostname, _|
34
- info "removing static entry: #{hostname}"
35
- Store.hosts.delete hostname
31
+ global_config.landrush.hosts.each do |static_hostname, _|
32
+ info "removing static entry: #{static_hostname}"
33
+ Store.hosts.delete static_hostname
36
34
  end
37
35
  end
38
36
 
39
37
  def teardown_server
40
38
  Server.stop
41
39
  end
42
-
43
- def info(msg)
44
- @env[:ui].info "[landrush] #{msg}"
45
- end
46
40
  end
47
41
  end
48
42
  end
@@ -0,0 +1,36 @@
1
+ module Landrush
2
+ module Cap
3
+ module Linux
4
+ module ReadHostVisibleIpAddress
5
+ #
6
+ # !!!!!!!!!!!!
7
+ # !! NOTE !!
8
+ # !!!!!!!!!!!!
9
+ #
10
+ # This is a fragile heuristic: we are simply assuming the IP address of
11
+ # the last interface non-localhost IP address is the host-visible one.
12
+ #
13
+ # For VMWare, the interface that Vagrant uses is host accessible, so we
14
+ # expect this to be the same as `read_ip_address`.
15
+ #
16
+ # For VirtualBox, the Vagrant interface is not host visible, so we add
17
+ # our own private_network, which we expect this to return for us.
18
+ #
19
+ # If the Vagrantfile sets up any sort of fancy networking, this has the
20
+ # potential to fail, which will break things.
21
+ #
22
+ # TODO: Find a better heuristic for this implementation.
23
+ #
24
+ def self.read_host_visible_ip_address(machine)
25
+ command = "ifconfig | grep 'inet addr:' | grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1 }'"
26
+ result = ""
27
+ machine.communicate.execute(command) do |type, data|
28
+ result << data if type == :stdout
29
+ end
30
+
31
+ result.chomp.split("\n").last
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -30,13 +30,10 @@ module Landrush
30
30
  end
31
31
 
32
32
  def validate(machine)
33
- if @enabled
34
- unless Util.hostname(machine).to_s.length > 0
33
+ if enabled?
34
+ unless machine.config.vm.hostname.to_s.length > 0
35
35
  return { 'landrush' => ['you must specify a hostname so we can make a DNS entry for it'] }
36
36
  end
37
- unless Util.ip_address(machine)
38
- return { 'landrush' => ['you must specify a private network or else DNS makes no sense'] }
39
- end
40
37
  end
41
38
  {}
42
39
  end
@@ -13,12 +13,12 @@ module Landrush
13
13
  (dir.directory? ? dir.children : []).each(&block)
14
14
  end
15
15
 
16
- def self.add(machine)
17
- FileUtils.touch(file_for(machine))
16
+ def self.add(hostname)
17
+ FileUtils.touch(file_for(hostname))
18
18
  end
19
19
 
20
- def self.remove(machine)
21
- file_for(machine).tap { |f| f.delete if f.exist? }
20
+ def self.remove(hostname)
21
+ file_for(hostname).tap { |f| f.delete if f.exist? }
22
22
  end
23
23
 
24
24
  def self.list
@@ -29,8 +29,8 @@ module Landrush
29
29
  dir.rmtree
30
30
  end
31
31
 
32
- def self.file_for(machine)
33
- dir.join(Util.hostname(machine))
32
+ def self.file_for(hostname)
33
+ dir.join(hostname)
34
34
  end
35
35
 
36
36
  def self.dir
@@ -13,19 +13,17 @@ module Landrush
13
13
  end
14
14
 
15
15
  action_hook 'landrush_setup', :machine_action_up do |hook|
16
+ require_relative 'action/common'
16
17
  require_relative 'action/setup'
17
18
  require_relative 'action/install_prerequisites'
18
19
  require_relative 'action/redirect_dns'
19
20
 
20
- register_boot_hooks = lambda { |boot_action|
21
- hook.before(boot_action, pre_boot_actions)
22
- hook.after(boot_action, post_boot_actions)
23
- }
24
-
25
- register_boot_hooks.call(VagrantPlugins::ProviderVirtualBox::Action::Boot)
21
+ hook.before(VagrantPlugins::ProviderVirtualBox::Action::Network, pre_boot_actions)
22
+ hook.after(Vagrant::Action::Builtin::WaitForCommunicator, post_boot_actions)
26
23
 
27
24
  if defined?(HashiCorp::VagrantVMwarefusion)
28
- register_boot_hooks.call(HashiCorp::VagrantVMwarefusion::Action::Boot)
25
+ hook.before(HashiCorp::VagrantVMwarefusion::Action::Network, pre_boot_actions)
26
+ hook.after(HashiCorp::VagrantVMwarefusion::Action::Boot, post_boot_actions)
29
27
  end
30
28
  end
31
29
 
@@ -43,11 +41,13 @@ module Landrush
43
41
  end
44
42
 
45
43
  action_hook 'landrush_teardown', :machine_action_halt do |hook|
44
+ require_relative 'action/common'
46
45
  require_relative 'action/teardown'
47
46
  hook.after(Vagrant::Action::Builtin::GracefulHalt, Action::Teardown)
48
47
  end
49
48
 
50
49
  action_hook 'landrush_teardown', :machine_action_destroy do |hook|
50
+ require_relative 'action/common'
51
51
  require_relative 'action/teardown'
52
52
  hook.after(Vagrant::Action::Builtin::GracefulHalt, Action::Teardown)
53
53
  end
@@ -76,5 +76,10 @@ module Landrush
76
76
  require_relative 'cap/linux/add_iptables_rule'
77
77
  Cap::Linux::AddIptablesRule
78
78
  end
79
+
80
+ guest_capability('linux', 'read_host_visible_ip_address') do
81
+ require_relative 'cap/linux/read_host_visible_ip_address'
82
+ Cap::Linux::ReadHostVisibleIpAddress
83
+ end
79
84
  end
80
85
  end
@@ -20,7 +20,9 @@ module Landrush
20
20
 
21
21
  def find(search)
22
22
  current_config.keys.detect do |key|
23
- search == key || search.match(/\.#{key}$/)
23
+ key == search ||
24
+ search =~ /#{key}$/ ||
25
+ key =~ /^#{search}\./
24
26
  end
25
27
  end
26
28
 
@@ -1,3 +1,3 @@
1
1
  module Landrush
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.0"
3
3
  end
data/lib/landrush.rb CHANGED
@@ -21,7 +21,6 @@ require 'landrush/plugin'
21
21
  require 'landrush/resolver_config'
22
22
  require 'landrush/server'
23
23
  require 'landrush/store'
24
- require 'landrush/util'
25
24
  require 'landrush/version'
26
25
 
27
26
  require 'ext/rexec'
@@ -1,4 +1,5 @@
1
1
  require 'test_helper'
2
+ require 'landrush/action/common'
2
3
  require 'landrush/action/setup'
3
4
 
4
5
  module Landrush
@@ -14,16 +15,6 @@ module Landrush
14
15
  env[:called].must_equal true
15
16
  end
16
17
 
17
- it "stores the machine's hostname => ip address" do
18
- app = Proc.new {}
19
- setup = Setup.new(app, nil)
20
- env = fake_environment_with_machine('somehost.vagrant.dev', '1.2.3.4')
21
-
22
- setup.call(env)
23
-
24
- Store.hosts.get('somehost.vagrant.dev').must_equal '1.2.3.4'
25
- end
26
-
27
18
  it "records the booting host as a dependent VM" do
28
19
  app = Proc.new {}
29
20
  setup = Setup.new(app, nil)
@@ -66,7 +57,30 @@ module Landrush
66
57
  env[:global_config].landrush.disable
67
58
  setup.call(env)
68
59
 
69
- Store.hosts.get('somehost.vagrant.dev').must_equal nil
60
+ DependentVMs.list.must_equal []
61
+ end
62
+
63
+ describe 'after boot' do
64
+ it "stores the machine's hostname => ip address" do
65
+ app = Proc.new {}
66
+ setup = Setup.new(app, nil)
67
+ env = fake_environment_with_machine('somehost.vagrant.dev', '1.2.3.4')
68
+
69
+ setup.call(env)
70
+
71
+ Store.hosts.get('somehost.vagrant.dev').must_equal '1.2.3.4'
72
+ end
73
+
74
+ it "does nothing if it is not enabled via config" do
75
+ app = Proc.new {}
76
+ setup = Setup.new(app, nil)
77
+ env = fake_environment_with_machine('somehost.vagrant.dev', '1.2.3.4')
78
+
79
+ env[:global_config].landrush.disable
80
+ setup.call(env)
81
+
82
+ Store.hosts.get('somehost.vagrant.dev').must_equal nil
83
+ end
70
84
  end
71
85
  end
72
86
  end
@@ -1,4 +1,5 @@
1
1
  require 'test_helper'
2
+ require 'landrush/action/common'
2
3
  require 'landrush/action/teardown'
3
4
 
4
5
  module Landrush
@@ -30,7 +31,7 @@ module Landrush
30
31
  teardown = Teardown.new(app, nil)
31
32
  env = fake_environment_with_machine('somehost.vagrant.dev', '1.2.3.4')
32
33
 
33
- DependentVMs.add(env[:machine])
34
+ DependentVMs.add('somehost.vagrant.dev')
34
35
  teardown.call(env)
35
36
 
36
37
  DependentVMs.list.must_equal []
@@ -51,8 +52,7 @@ module Landrush
51
52
  app = Proc.new {}
52
53
  teardown = Teardown.new(app, nil)
53
54
  env = fake_environment_with_machine('somehost.vagrant.dev', '1.2.3.4')
54
- other_machine = fake_machine('otherhost.vagrant.dev', '2.3.4.5')
55
- DependentVMs.add(other_machine)
55
+ DependentVMs.add('otherhost.vagrant.dev')
56
56
 
57
57
  Server.start
58
58
  teardown.call(env)
@@ -64,8 +64,7 @@ module Landrush
64
64
  app = Proc.new {}
65
65
  teardown = Teardown.new(app, nil)
66
66
  env = fake_environment_with_machine('somehost.vagrant.dev', '1.2.3.4')
67
- other_machine = fake_machine('otherhost.vagrant.dev', '1.2.3.4')
68
- DependentVMs.add(other_machine)
67
+ DependentVMs.add('otherhost.vagrant.dev')
69
68
 
70
69
  fake_static_entry(env, 'static.vagrant.dev', '3.4.5.6')
71
70
 
@@ -8,24 +8,20 @@ module Landrush
8
8
  end
9
9
 
10
10
  it "reports true once a machine has been added" do
11
- env = fake_environment_with_machine('recordme.example.dev', '1.2.3.4')
12
- DependentVMs.add(env[:machine])
11
+ DependentVMs.add('recordme.example.dev')
13
12
  DependentVMs.any?.must_equal true
14
13
  end
15
14
 
16
15
  it "reports false if a machine has been added then removed" do
17
- env = fake_environment_with_machine('recordme.example.dev', '1.2.3.4')
18
- DependentVMs.add(env[:machine])
19
- DependentVMs.remove(env[:machine])
16
+ DependentVMs.add('recordme.example.dev')
17
+ DependentVMs.remove('recordme.example.dev')
20
18
  DependentVMs.any?.must_equal false
21
19
  end
22
20
 
23
21
  it "reports true if not all machines have been removed" do
24
- first_env = fake_environment_with_machine('recordme.example.dev', '1.2.3.4')
25
- second_env = fake_environment_with_machine('alsome.example.dev', '2.3.4.5')
26
- DependentVMs.add(first_env[:machine])
27
- DependentVMs.add(second_env[:machine])
28
- DependentVMs.remove(first_env[:machine])
22
+ DependentVMs.add('recordme.example.dev')
23
+ DependentVMs.add('alsome.example.dev')
24
+ DependentVMs.remove('recordme.example.dev')
29
25
  DependentVMs.any?.must_equal true
30
26
  end
31
27
  end
@@ -66,6 +66,15 @@ module Landrush
66
66
  @store.set('somehost.vagrant.dev', 'here')
67
67
  @store.find('somehost.vagrant.dev').must_equal 'somehost.vagrant.dev'
68
68
  end
69
+
70
+ it "returns for prefix searches as well" do
71
+ @store.set('somehost.vagrant.dev', 'here')
72
+
73
+ @store.find('somehost').must_equal 'somehost.vagrant.dev'
74
+ @store.find('somehost.vagrant').must_equal 'somehost.vagrant.dev'
75
+ @store.find('somehost.vagr').must_equal nil
76
+ @store.find('someh').must_equal nil
77
+ end
69
78
  end
70
79
  end
71
80
  end
data/test/test_helper.rb CHANGED
@@ -18,16 +18,54 @@ def fake_environment_with_machine(hostname, ip)
18
18
  { machine: machine, ui: FakeUI, global_config: env.config_global }
19
19
  end
20
20
 
21
- def fake_machine(hostname, ip, env = Vagrant::Environment.new)
22
- provider_cls = Class.new do
23
- def initialize(machine)
21
+ class RecordingCommunicator
22
+ attr_reader :commands, :responses
23
+
24
+ def initialize
25
+ @commands = Hash.new([])
26
+ @responses = Hash.new('')
27
+ end
28
+
29
+ def stub_command(command, response)
30
+ responses[command] = response
31
+ end
32
+
33
+ def sudo(command)
34
+ puts "SUDO: #{command}"
35
+ commands[:sudo] << command
36
+ responses[command]
37
+ end
38
+
39
+ def execute(command, &block)
40
+ commands[:execute] << command
41
+ responses[command].split("\n").each do |line|
42
+ block.call(:stdout, "#{line}\n")
24
43
  end
25
- end
44
+ end
45
+
46
+ def test(command)
47
+ commands[:test] << command
48
+ true
49
+ end
50
+
51
+ def ready?
52
+ true
53
+ end
54
+ end
26
55
 
56
+ class Landrush::FakeProvider
57
+ def initialize(machine)
58
+ end
59
+
60
+ def ssh_info
61
+ end
62
+ end
63
+
64
+ def fake_machine(hostname, ip, env = Vagrant::Environment.new)
27
65
  machine = Vagrant::Machine.new(
28
66
  'fake_machine',
29
67
  'fake_provider',
30
- provider_cls,
68
+ Landrush::FakeProvider,
31
69
  'provider_config',
32
70
  {}, # provider_options
33
71
  env.config_global,
@@ -36,9 +74,15 @@ def fake_machine(hostname, ip, env = Vagrant::Environment.new)
36
74
  env
37
75
  )
38
76
 
77
+ machine.instance_variable_set("@communicator", RecordingCommunicator.new)
78
+ machine.communicate.stub_command(
79
+ "ifconfig | grep 'inet addr:' | grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1 }'",
80
+ "#{ip}\n"
81
+ )
82
+
39
83
  machine.config.landrush.enable
40
84
  machine.config.vm.hostname = hostname
41
- machine.config.vm.network :private_network, ip: ip
85
+
42
86
 
43
87
  machine
44
88
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: landrush
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-02 00:00:00.000000000 Z
12
+ date: 2013-10-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rubydns
@@ -91,6 +91,7 @@ files:
91
91
  - landrush.gemspec
92
92
  - lib/ext/rexec.rb
93
93
  - lib/landrush.rb
94
+ - lib/landrush/action/common.rb
94
95
  - lib/landrush/action/install_prerequisites.rb
95
96
  - lib/landrush/action/redirect_dns.rb
96
97
  - lib/landrush/action/setup.rb
@@ -99,6 +100,7 @@ files:
99
100
  - lib/landrush/cap/debian/iptables_installed.rb
100
101
  - lib/landrush/cap/linux/add_iptables_rule.rb
101
102
  - lib/landrush/cap/linux/configured_dns_server.rb
103
+ - lib/landrush/cap/linux/read_host_visible_ip_address.rb
102
104
  - lib/landrush/cap/linux/redirect_dns.rb
103
105
  - lib/landrush/command.rb
104
106
  - lib/landrush/config.rb
@@ -107,7 +109,6 @@ files:
107
109
  - lib/landrush/resolver_config.rb
108
110
  - lib/landrush/server.rb
109
111
  - lib/landrush/store.rb
110
- - lib/landrush/util.rb
111
112
  - lib/landrush/version.rb
112
113
  - test/landrush/action/setup_test.rb
113
114
  - test/landrush/action/teardown_test.rb
@@ -136,7 +137,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
136
137
  version: '0'
137
138
  segments:
138
139
  - 0
139
- hash: -227825973048311947
140
+ hash: 901975285541024268
140
141
  required_rubygems_version: !ruby/object:Gem::Requirement
141
142
  none: false
142
143
  requirements:
@@ -145,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
146
  version: '0'
146
147
  segments:
147
148
  - 0
148
- hash: -227825973048311947
149
+ hash: 901975285541024268
149
150
  requirements: []
150
151
  rubyforge_project:
151
152
  rubygems_version: 1.8.23
data/lib/landrush/util.rb DELETED
@@ -1,25 +0,0 @@
1
- module Landrush
2
- module Util
3
- def self.host_and_ip(machine)
4
- [hostname(machine), ip_address(machine)]
5
- end
6
-
7
- def self.hostname(machine)
8
- return nil unless machine
9
-
10
- machine.config.vm.hostname
11
- end
12
-
13
- def self.ip_address(machine)
14
- return nil unless machine
15
-
16
- machine.config.vm.networks.each do |type, options|
17
- if type == :private_network && options[:ip].is_a?(String)
18
- return options[:ip]
19
- end
20
- end
21
-
22
- nil
23
- end
24
- end
25
- end