vagrant-hostmanager
vagrant-hostmanager copied to clipboard
When adding large amount of hosts plugin breaks the hosts file on ubuntu
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
...
@bbrala I can confirm this happens on Mac OS X as well. I think it also affects changing /etc/exports when using NFS shares.
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.