Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When adding large amount of hosts plugin breaks the hosts file on ubuntu #261

Open
bbrala opened this issue Apr 23, 2018 · 2 comments
Open

Comments

@bbrala
Copy link

bbrala commented Apr 23, 2018

We add quite a few entries with this plugin and the resulting hostsfile on the linux hosts file is being cut off.

We run on Windows Hyper-V but im not sure if that really matters. I think some variable is running out of space. But im not entirely sure.

I've made a Vagrantfile which shows the problem in action. The resulting file in /etc/hosts

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

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
  config.vm.box = "generic/ubuntu1604"

  if Vagrant.has_plugin?("vagrant-hostmanager")

    PROJECT_HOSTS = Array.new

    hostCount = 2000
    puts "#{hostCount} hosts for hostsfile"
    while hostCount > 0
        hostCount -= 1

        PROJECT_HOSTS.push("domain#{hostCount}.testing.tld")
    end

    config.hostmanager.enabled = false
    config.hostmanager.manage_host = true
    config.hostmanager.manage_guest = true
    config.hostmanager.ignore_private_ip = false
    config.hostmanager.include_offline = true
    config.hostmanager.aliases = PROJECT_HOSTS

    config.vm.provision :hostmanager, run: 'always'
  end
end

The resulting hosts file:

vagrant@ubuntu1604:~$ head /etc/hosts -n 30
ting.tld
172.16.0.136    domain912.testing.tld
172.16.0.136    domain911.testing.tld
172.16.0.136    domain910.testing.tld
172.16.0.136    domain909.testing.tld
172.16.0.136    domain908.testing.tld
172.16.0.136    domain907.testing.tld
...
@tdm4
Copy link

tdm4 commented Jun 25, 2018

@bbrala I can confirm this happens on Mac OS X as well.
I think it also affects changing /etc/exports when using NFS shares.

@bbrala
Copy link
Author

bbrala commented Jun 25, 2018

My guts tell me is runs out of space in a string but i don't really know the specifics Ruby good enough to be sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants