vagrant-landrush / landrush

A Vagrant plugin that provides a simple DNS server for Vagrant guests
MIT License
666 stars 78 forks source link

Landrush plugin fails to set hostname on busybox type guest os #175

Open bertramn opened 8 years ago

bertramn commented 8 years ago

Hi there,

I tried to run a busybox based vagrant box (alpine linux) together with landrush which fails unfortunately. It appears that landrush tries to modify the hostname of the guest but fails to recognise the subtile difference of the busy box utilities.

I posted the debug trace showing the error below. Also is there a way to switch off landrush for specific machines in a Vagrantfile as a temp workaround?

Many thanks Niels

ERROR vagrant: #<Vagrant::Errors::VagrantError: The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

hostname -I

Stderr from the command:

hostname: unrecognized option: I
BusyBox v1.24.1 (2015-12-16 08:00:02 GMT) multi-call binary.

Usage: hostname [OPTIONS] [HOSTNAME | -F FILE]

Get or set hostname or DNS domain name

    -s  Short
    -i  Addresses for the hostname
    -d  DNS domain name
    -f  Fully qualified domain name
    -F FILE Use FILE's content as hostname
>

ERROR vagrant: /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/plugins/communicators/ssh/communicator.rb:236:in `execute'
/Users/bertramn/.vagrant.d/gems/gems/landrush-0.19.0/lib/landrush/cap/linux/read_host_visible_ip_address.rb:26:in `read_host_visible_ip_address'
/opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/capability_host.rb:111:in `call'
/opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/capability_host.rb:111:in `capability'
/opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/guest.rb:43:in `capability'
/Users/bertramn/.vagrant.d/gems/gems/landrush-0.19.0/lib/landrush/action/setup.rb:73:in `record_machine_dns_entry'
/Users/bertramn/.vagrant.d/gems/gems/landrush-0.19.0/lib/landrush/action/setup.rb:14:in `call'
/opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
/opt/vagrant/embedded/gems/gems/vagrant-1.8.1/plugins/providers/virtualbox/action/clear_network_interfaces.rb:26:in `call'
/opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
/opt/vagrant/embedded/gems/gems/vagrant-1.8.1/plugins/providers/virtualbox/action/prepare_nfs_settings.rb:18:in `call'
/opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
/Users/bertramn/.vagrant.d/gems/gems/vagrant-proxyconf-1.5.2/lib/vagrant-proxyconf/action/only_once.rb:21:in `call'
/opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
/opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/builtin/synced_folders.rb:87:in `call'
/opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
/opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/builtin/synced_folder_cleanup.rb:28:in `call'
/opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
/opt/vagrant/embedded/gems/gems/vagrant-1.8.1/plugins/synced_folders/nfs/action_cleanup.rb:25:in `call'
/opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
/opt/vagrant/embedded/gems/gems/vagrant-1.8.1/plugins/providers/virtualbox/action/prepare_nfs_valid_ids.rb:12:in `call'
/opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
/opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb:49:in `call'
/opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
/opt/vagrant/embedded/gems/gems/vagrant-1.8.1/plugins/providers/virtualbox/action/prepare_forwarded_port_collision_params.rb:30:in `call'
/opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
/opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/builtin/env_set.rb:19:in `call'
/opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
/Users/bertramn/.vagrant.d/gems/gems/vagrant-hostmanager-1.8.1/lib/vagrant-hostmanager/action/update_all.rb:24:in `call'
/opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
/opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/builtin/config_validate.rb:25:in `call'

Example Vagrantfile that should lead to the error above when run on Vagrant 1.8.1 on OSX

# -*- mode: ruby -*-
# vi: set ft=ruby :

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.require_version ">= 1.7.2"

# make sure the dns plugin is loaded
unless Vagrant.has_plugin?("landrush")
  raise 'Please type this command then try again: vagrant plugin install landrush'
end

# we use alpine for the ha proxy
unless Vagrant.has_plugin?("vagrant-alpine")
  raise 'Please type this command then try again: vagrant plugin install vagrant-alpine'
end

# start VM configuration
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

  config.landrush.enabled = true
  config.landrush.guest_redirect_dns = false # this stuffs up on alpine too as the busybox distro has no iptables capability
  config.landrush.tld = tld

  if Vagrant.has_plugin?("vagrant-vbguest")
    config.vbguest.auto_update = false
  end

  config.vm.define "haproxy" do |haproxy|
    haproxy.vm.box = "maier/alpine-3.3.1-x86_64"
    haproxy.vm.hostname = "proxy.vagrant.dev"
    haproxy.vm.synced_folder '.', '/vagrant', disabled: true
    haproxy.vm.provider "virtualbox" do |vb|
      vb.gui = false
      vb.name = "haproxy"
      vb.memory = 512
      vb.cpus = 2
      vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
    end
  end

end
hferentschik commented 8 years ago

The _read_host_visible_ipaddress issue is resolved by #114, but now I get this when trying to boot the VM :-)

Vagrant attempted to execute the capability 'iptables_installed'
on the detect guest OS 'linux', but the guest doesn't
support that capability. This capability is required for your
configuration of Vagrant. Please either reconfigure Vagrant to
avoid this capability or fix the issue by creating the capability.
hferentschik commented 8 years ago

Apart from Landrush, it seems even when it comes to pure Vagrant configuration, busybox/alpine seems to be very limited on what it supports. Not sure how much work we should put into this.