devopsgroup-io / vagrant-hostmanager

:pencil: A Vagrant plugin that manages hosts files within a multi-machine environment.
Mozilla Public License 2.0
1.46k stars 146 forks source link

vagrant becoming root on login stalls vagrant-hostmanager #221

Open Eimert opened 7 years ago

Eimert commented 7 years ago

Issue Vagrant is stuck at the step '==> buildserver: Updating /etc/hosts file on active guest machines...'.

Cause I added echo "sudo -i" >> /home/vagrant/.bashrc to my provisioner script. My aim is to become root after login. It seems that the vagrant-hostmanager plugin cannot handle this (yet); After removing the sudo -i line, vagrant works just fine.

Tried a workaround Putting the vagrant-hostmanager plugin as the last step didn't work either, because I have three machines and the plugin cannot update the /etc/hosts file on the first machine (since that machine does a sudo -i on login).

Reproduction The issue can be reproduced by doing a vagrant up on the attached Vagrantfile and provisioner script.

vagrant-hostmanager-issue.zip

Eimert commented 7 years ago

Possible fix: adding sudo -i to $HOME/.bash_profile, since that file is only loaded on interactive logins.