vagrant-landrush / landrush

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

Unable to use with CentOS v5 boxes on vmware_fusion #165

Closed khaije1 closed 5 years ago

khaije1 commented 8 years ago

I get a similar error with any CentOSv5 VM I've tried. The below error happens while using this public CentOSv5 VM, but my packer-generated VM experiences the exact same problem.

With minor testing it appears that the 'ip' variable is being passed to '_gateway_for_ip(ip)' as a nil.

mentat:genesis-ctl khaije1$ vagrant init bento/centos-5.11 ; vagrant up
Bringing machine 'ness-scan-p1' up with 'vmware_fusion' provider...
==> ness-scan-p1: Cloning VMware VM: 'bento/centos-5.11'. This can take some time...
==> ness-scan-p1: Checking if box 'bento/centos-5.11' is up to date...
==> ness-scan-p1: Verifying vmnet devices are healthy...
==> ness-scan-p1: [landrush] Host DNS resolver config looks good.
==> ness-scan-p1: [landrush] starting dns server
[landrush] Starting daemon...
[landrush] Waiting for daemon to start...
==> ness-scan-p1: Preparing network adapters...
==> ness-scan-p1: Starting the VMware VM...
==> ness-scan-p1: Waiting for machine to boot. This may take a few minutes...
    ness-scan-p1: SSH address: 172.16.105.129:22
    ness-scan-p1: SSH username: vagrant
    ness-scan-p1: SSH auth method: private key
    ness-scan-p1: Warning: Connection refused. Retrying...
    ness-scan-p1: 
    ness-scan-p1: Vagrant insecure key detected. Vagrant will automatically replace
    ness-scan-p1: this with a newly generated keypair for better security.
    ness-scan-p1: 
    ness-scan-p1: Inserting generated public key within guest...
    ness-scan-p1: Removing insecure key from the guest if it's present...
    ness-scan-p1: Key inserted! Disconnecting and reconnecting using new SSH key...
==> ness-scan-p1: Machine booted and ready!
==> ness-scan-p1: [landrush] setting up machine's DNS to point to our server
==> ness-scan-p1: Stopping the VMware VM...
==> ness-scan-p1: Deleting the VM...
/Users/khaije1/.vagrant.d/gems/gems/landrush-0.18.0/lib/landrush/action/redirect_dns.rb:34:in `_gateway_for_ip': undefined method `split' for nil:NilClass (NoMethodError)
    from /Users/khaije1/.vagrant.d/gems/gems/landrush-0.18.0/lib/landrush/action/redirect_dns.rb:26:in `_target_host'
    from /Users/khaije1/.vagrant.d/gems/gems/landrush-0.18.0/lib/landrush/action/redirect_dns.rb:14:in `redirect_dns'
    from /Users/khaije1/.vagrant.d/gems/gems/landrush-0.18.0/lib/landrush/action/redirect_dns.rb:8:in `block in call'
    from /Users/khaije1/.vagrant.d/gems/gems/landrush-0.18.0/lib/landrush/action/common.rb:22:in `handle_action_stack'
    from /Users/khaije1/.vagrant.d/gems/gems/landrush-0.18.0/lib/landrush/action/redirect_dns.rb:7:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /Users/khaije1/.vagrant.d/gems/gems/landrush-0.18.0/lib/landrush/action/common.rb:24:in `handle_action_stack'
    from /Users/khaije1/.vagrant.d/gems/gems/landrush-0.18.0/lib/landrush/action/install_prerequisites.rb:7:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/builtin/wait_for_communicator.rb:71:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /Users/khaije1/.vagrant.d/gems/gems/vagrant-vmware-fusion-4.0.8/lib/vagrant-vmware-fusion/action_farm.rb:41:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /Users/khaije1/.vagrant.d/gems/gems/vagrant-vmware-fusion-4.0.8/lib/vagrant-vmware-fusion/action_farm.rb:336:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb:49:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /Users/khaije1/.vagrant.d/gems/gems/vagrant-vmware-fusion-4.0.8/lib/vagrant-vmware-fusion/action_farm.rb:1011:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /Users/khaije1/.vagrant.d/gems/gems/vagrant-vmware-fusion-4.0.8/lib/vagrant-vmware-fusion/action_farm.rb:1441:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/builtin/set_hostname.rb:16:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /Users/khaije1/.vagrant.d/gems/gems/vagrant-vmware-fusion-4.0.8/lib/vagrant-vmware-fusion/action_farm.rb:731:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /Users/khaije1/.vagrant.d/gems/gems/landrush-0.18.0/lib/landrush/action/common.rb:24:in `handle_action_stack'
    from /Users/khaije1/.vagrant.d/gems/gems/landrush-0.18.0/lib/landrush/action/setup.rb:7:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /Users/khaije1/.vagrant.d/gems/gems/vagrant-vmware-fusion-4.0.8/lib/vagrant-vmware-fusion/action_farm.rb:958:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/builtin/synced_folders.rb:87:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/builtin/synced_folder_cleanup.rb:28:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/plugins/synced_folders/nfs/action_cleanup.rb:25:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /Users/khaije1/.vagrant.d/gems/gems/vagrant-vmware-fusion-4.0.8/lib/vagrant-vmware-fusion/action_farm.rb:1030:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/builtin/provision.rb:80:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/builder.rb:116:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/runner.rb:66:in `block in run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/util/busy.rb:19:in `busy'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/runner.rb:66:in `run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/builtin/call.rb:53:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /Users/khaije1/.vagrant.d/gems/gems/vagrant-vmware-fusion-4.0.8/lib/vagrant-vmware-fusion/action_farm.rb:76:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /Users/khaije1/.vagrant.d/gems/gems/vagrant-vmware-fusion-4.0.8/lib/vagrant-vmware-fusion/action_farm.rb:1060:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/builder.rb:116:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/runner.rb:66:in `block in run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/util/busy.rb:19:in `busy'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/runner.rb:66:in `run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/builtin/call.rb:53:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/builtin/box_check_outdated.rb:78:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /Users/khaije1/.vagrant.d/gems/gems/vagrant-vmware-fusion-4.0.8/lib/vagrant-vmware-fusion/action_farm.rb:1352:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /Users/khaije1/.vagrant.d/gems/gems/vagrant-vmware-fusion-4.0.8/lib/vagrant-vmware-fusion/action_farm.rb:278:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /Users/khaije1/.vagrant.d/gems/gems/vagrant-vmware-fusion-4.0.8/lib/vagrant-vmware-fusion/action_farm.rb:148:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /Users/khaije1/.vagrant.d/gems/gems/vagrant-vmware-fusion-4.0.8/lib/vagrant-vmware-fusion/action_farm.rb:1139:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /Users/khaije1/.vagrant.d/gems/gems/vagrant-vmware-fusion-4.0.8/lib/vagrant-vmware-fusion/action_farm.rb:507:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/builtin/prepare_clone.rb:15:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/builtin/handle_box.rb:56:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/builder.rb:116:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/runner.rb:66:in `block in run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/util/busy.rb:19:in `busy'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/runner.rb:66:in `run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/builtin/call.rb:53:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /Users/khaije1/.vagrant.d/gems/gems/vagrant-vmware-fusion-4.0.8/lib/vagrant-vmware-fusion/action_farm.rb:1352:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /Users/khaije1/.vagrant.d/gems/gems/vagrant-vmware-fusion-4.0.8/lib/vagrant-vmware-fusion/action_farm.rb:104:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /Users/khaije1/.vagrant.d/gems/gems/vagrant-vmware-fusion-4.0.8/lib/vagrant-vmware-fusion/action_farm.rb:278:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /Users/khaije1/.vagrant.d/gems/gems/vagrant-vmware-fusion-4.0.8/lib/vagrant-vmware-fusion/action_farm.rb:165:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/builder.rb:116:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/runner.rb:66:in `block in run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/util/busy.rb:19:in `busy'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/runner.rb:66:in `run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/machine.rb:224:in `action_raw'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/machine.rb:199:in `block in action'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/environment.rb:561:in `lock'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/machine.rb:185:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/machine.rb:185:in `action'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/batch_action.rb:82:in `block (2 levels) in run'
mentat:genesis-ctl khaije1$ 
khaije1 commented 8 years ago

testing on v0.18.0

I commented out the '_gateway_for_ip' function body:

      # Poor man's gateway; strip the last octet and jam a 1 on there.
      def _gateway_for_ip(ip)
#        ip.split('.').tap(&:pop).push(1).join('.')
      end

which helped expose a different error ... looks like the hostname -I (note capital 'i') should use a lowercase 'i' in CentOS v5. I'll see if I can find locate where to make the change and submit a PR, but anyone should feel free to beat me to it ;-)

==> test-s1: Forwarding ports...
    test-s1: -- 22 => 2222
==> test-s1: Setting hostname...
==> test-s1: Configuring network adapters within the VM...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

hostname -I

Stdout from the command:

Stderr from the command:

hostname: invalid option -- I
Usage: hostname [-v] {hostname|-F file}      set hostname (from file)
       domainname [-v] {nisdomain|-F file}   set NIS domainname (from file)
       hostname [-v] [-d|-f|-s|-a|-i|-y|-n]  display formatted name
       hostname [-v]                         display hostname

       hostname -V|--version|-h|--help       print info and exit

    dnsdomainname=hostname -d, {yp,nis,}domainname=hostname -y

    -s, --short           short host name
    -a, --alias           alias names
    -i, --ip-address      addresses for the hostname
    -f, --fqdn, --long    long host name (FQDN)
    -d, --domain          DNS domain name
    -y, --yp, --nis       NIS/YP domainname
    -F, --file            read hostname or NIS domainname from given file

   This command can read or set the hostname or the NIS domainname. You can
   also read the DNS domain or the FQDN (fully qualified domain name).
   Unless you are using bind or NIS for host lookups you can change the
   FQDN (Fully Qualified Domain Name) and the DNS domain name (which is
   part of the FQDN) in the /etc/hosts file.
njam commented 8 years ago

Unfortunately as you noticed hostname -I is not working on all platforms.

We can have a CentOS-specific solution (hostname -i). Also there's a discussion about having a custom binary to read the IP address here: https://github.com/phinze/landrush/issues/114

khaije1 commented 8 years ago

Cheers @njam !

I was able to get my case working w/ these changes.

diff --git a/lib/landrush/action/redirect_dns.rb b/lib/landrush/action/redirect_dns.rb
index c2c92e0..8e4eb45 100644
--- a/lib/landrush/action/redirect_dns.rb
+++ b/lib/landrush/action/redirect_dns.rb
@@ -34,6 +34,8 @@ module Landrush

       # Poor man's gateway; strip the last octet and jam a 1 on there.
       def _gateway_for_ip(ip)
+        ip = machine.guest.capability(:read_host_visible_ip_address) if ip.nil?
+        ip = ip.first if ip.instance_of?(Array)
         ip.split('.').tap(&:pop).push(1).join('.')
       end
     end
diff --git a/lib/landrush/cap/linux/read_host_visible_ip_address.rb b/lib/landrush/cap/linux/read_host_visible_ip_address.rb
index e34e08f..01f3ba7 100644
--- a/lib/landrush/cap/linux/read_host_visible_ip_address.rb
+++ b/lib/landrush/cap/linux/read_host_visible_ip_address.rb
@@ -39,7 +39,7 @@ module Landrush
         end

         def self.command
-          %Q(hostname -I)
+          %Q(hostname -I || /sbin/ip route | awk 'NR==/ src /&&/ dev /{print $NF}')
         end
       end
     end

This made it possible for me to unblock myself but wasn't extensively considered. No doubt the solution in #114 is a better long term solution.

Please feel free to close this issue unless it looks suitable to merge, in which case I'd be happy to submit a PR.

khaije1 commented 8 years ago

On second thought, please hold off on closing this. While the OS is now booting, the landrush-specific functionality isn't working.

The iptables redirect rule isn't being set, or at least is absent when I check for it after boot. When the redirect rule is manually added, DNS works as expected and the problem resolves. Now to figure why it's not being setup ...

Here are the possible factors that I'm aware of to check while evaluating for a fix (not necessarily a list of established problems):

Any pointers or anything else to look out for?

njam commented 8 years ago

Hm the rule should be added in https://github.com/phinze/landrush/blob/master/lib/landrush/cap/linux/add_iptables_rule.rb - any errors should be printed. Maybe you could remove that 2> /dev/null and run vagrant up again?

dshimkoski commented 8 years ago

A workaround for this is to override hostname on the guest system at the top of your provisioning script:

echo 'hostname () { if [ "$1" = "-I" ]; then /bin/hostname -i; else /bin/hostname "$@"; fi }' >> .bashrc

Then only run landrush if you're not provisioning:

if !ENV['SETUP']
  config.landrush.enabled = true
end

On first run:

SETUP=1 vagrant up
vagrant reload
khaije1 commented 8 years ago

This snippet, (changed in ~/.vagrant.d/gems/gems/landrush-0.19.0/lib/landrush/cap/linux/read_host_visible_ip_address.rb), has been helpful for me:

def self.command
  %Q(hostname -I 2>/dev/null || /sbin/ip ad | sed -ne 's/^\\W*inet \\([0-9.]*\\).* global .*$/\\1/p' 2>/dev/null)
end
hferentschik commented 8 years ago

So if the issue is the use of hostname in _read_host_visible_ipaddress.rb, then this might be getting addressed by this pull request - #193. I'll give it a go.

hferentschik commented 8 years ago

So, after some quick testing it seems indeed that pull request #193 will take care of this.

hferentschik commented 8 years ago

So I tried the following. Two directories with the following Vagrantfile in each:

Vagrant.configure('2') do |config|
  config.vm.box = 'centos/7'

  config.vm.synced_folder '.', '/vagrant', disabled: true

  config.landrush.enabled = true
  config.landrush.tld = 'foo'
end

I can boot each VM and then ssh into it. On each VM I can ping the name of the other VM and I can see in the Landrush log files on my host that the DNS queries are directed to Landrush. Looking good so far.

If I add 'config.vm.hostname = 'my-host'

==> default: Setting hostname...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

# Update sysconfig
sed -i 's/\(HOSTNAME=\).*/\1my-host/' /etc/sysconfig/network

# Update DNS
sed -i 's/\(DHCP_HOSTNAME=\).*/\1"my-host"/' /etc/sysconfig/network-scripts/ifcfg-*

# Set the hostname - use hostnamectl if available
echo 'my-host' > /etc/hostname
if command -v hostnamectl; then
  hostnamectl set-hostname 'my-host'
else
  hostname 'my-host'
fi

# Remove comments and blank lines from /etc/hosts
sed -i'' -e 's/#.*$//' -e '/^$/d' /etc/hosts

# Prepend ourselves to /etc/hosts
grep -w 'my-host' /etc/hosts || {
  sed -i'' '1i 127.0.0.1\tmy-host\tmy-host' /etc/hosts
}

# Restart network
service network restart

Stdout from the command:

/bin/hostnamectl
Restarting network (via systemctl):  [FAILED]

Stderr from the command:

Job for network.service failed. See 'systemctl status network.service' and 'journalctl -xn' for     details.

For:

Vagrant.configure('2') do |config|
  config.vm.box = 'bento/centos-5.11'

  config.vm.synced_folder '.', '/vagrant', disabled: true

  config.landrush.enabled = true
end

I get:

==> default: Configuring and enabling network interfaces...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

# Down the interface before munging the config file. This might
# fail if the interface is not actually set up yet so ignore
# errors.
/sbin/ifdown '' || true

# Move new config into place
mv '/tmp/vagrant-network-entry--1466676309-0' '/etc/sysconfig/network-scripts/ifcfg-'

# Bring the interface up
ARPCHECK=no /sbin/ifup ''

Stdout from the command:

Stderr from the command:

usage: ifdown <device name>
Usage: ifup <device name>

So definitely more work needed, but it probably needs to be guest specific.

hferentschik commented 5 years ago

This issue cannot be reproduced anymore.