goodhosts / vagrant

Vagrant plugin that use goodhosts to manipulate hosts files
https://rubygems.org/gems/vagrant-goodhosts/
MIT License
17 stars 8 forks source link

Vagrant reload up/provision hooks not executed #35

Closed ghost closed 3 years ago

ghost commented 3 years ago

we need a hook when someone does a vagrant reload --provision so that the hosts get readded. Currently right now. when doing a vagrant reload --provision the hosts get removed and do not get added back to the hosts file.

Mte90 commented 3 years ago

I need a log to confirm the bug. I am studying the vagrant code for some hints in the meantime.

Mte90 commented 3 years ago

My guess is that on reload the the provision execute different hooks but they are already available: https://github.com/goodhosts/vagrant/blob/master/lib/vagrant-goodhosts/plugin.rb

ghost commented 3 years ago

this is the vagrant reload log

benlumia007@balthasar:~/VVV$ vagrant reload
__ __ __ __
\ V\ V\ V / Varying Vagrant Vagrants
 \_/\_/\_/  v3.7.0-git::develop(1575dff)

Platform: platform-linux-gnu shell:/bin/bash systemd  vagrant-goodhosts CaseSensitiveFS shared_db_folder_disabled, VVV Path: "/home/benlumia007/VVV"
Vagrant: v2.2.15, virtualbox: v6.1.18

Docs:       https://varyingvagrantvagrants.org/
Contribute: https://github.com/varying-vagrant-vagrants/vvv
Dashboard:  http://vvv.test

==> default: Running action triggers before reload ...
==> default: Running trigger: VVV Pre-Reload...
    default: Running: inline script
    default:  * Performing Database Backups
    default:  * Fetching Database names
    default:    - skipped information_schema
    default:    - skipped mysql
    default:    - skipped performance_schema
    default:    - skipped wordpress_unit_tests
    default:    -  0/2 Backing up 'benjlu'                to 'database/backups/benjlu.sql'
    default:    -  1/2 Backing up 'getbenonit'            to 'database/backups/getbenonit.sql'
    default:  * Finished backing up databases to the database/sql/backups folder
    default:    .  ★         ☁           ★          .
    default: Z        ☽    ★         .        ☁
    default:  Z ▄▀▀▀▄▄▄▄▄▄▄▀▀▀▄   ★            __★__ __ __
    default: ☁ z█▒▒░░░░░░░░░▒▒█    Sleep tight \ V\ V\ V /
    default:  ★  █░░▁░░░░░▁░░█  ★               \_/\_/\_/
    default:    . █░░░▀█▀░░░█ .          ★
    default:  ★   ▀▄░░░░░░░▄▀  ★     .
    default: 
==> default: [vagrant-goodhosts] Removing hosts
==> default: [vagrant-goodhosts] - found entry for: 192.168.50.4 vvv.test
==> default: [vagrant-goodhosts] - found entry for: 192.168.50.4 benjlu.test
==> default: [vagrant-goodhosts] - found entry for: 192.168.50.4 getbenonit.test
==> default: Attempting graceful shutdown of VM...
==> default: Checking if box 'ubuntu/bionic64' version '20210415.0.0' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default: 
    default: Guest Additions Version: 5.2.8_KernelUbuntu r120774
    default: VirtualBox Version: 6.1
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
    default: /srv/www => /home/benlumia007/VVV/www
    default: /srv/config => /home/benlumia007/VVV/config
    default: /var/log/php => /home/benlumia007/VVV/log/php
    default: /srv/database => /home/benlumia007/VVV/database/sql
    default: /srv/provision => /home/benlumia007/VVV/provision
    default: /var/log/nginx => /home/benlumia007/VVV/log/nginx
    default: /srv/certificates => /home/benlumia007/VVV/certificates
    default: /var/log/memcached => /home/benlumia007/VVV/log/memcached
    default: /var/log/provisioners => /home/benlumia007/VVV/log/provisioners
==> default: Detected mount owner ID within mount options. (uid: 0 guestpath: /var/log/memcached)
==> default: Detected mount group ID within mount options. (gid: 106 guestpath: /var/log/memcached)
==> default: Detected mount owner ID within mount options. (uid: 0 guestpath: /var/log/nginx)
==> default: Detected mount group ID within mount options. (gid: 106 guestpath: /var/log/nginx)
==> default: Detected mount owner ID within mount options. (uid: 0 guestpath: /var/log/php)
==> default: Detected mount group ID within mount options. (gid: 106 guestpath: /var/log/php)
==> default: Detected mount owner ID within mount options. (uid: 0 guestpath: /var/log/provisioners)
==> default: Detected mount group ID within mount options. (gid: 106 guestpath: /var/log/provisioners)
==> default: Detected mount owner ID within mount options. (uid: 1000 guestpath: /srv/www)
==> default: Detected mount group ID within mount options. (gid: 33 guestpath: /srv/www)
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
==> default: Running action triggers after reload ...
==> default: Running trigger: VVV Post-Reload...
    default: Running: inline script
    default:  * Restarting Nginx
    default:  * Restarting MariaDB
    default:  * Syncing clocks
    default: 27 Apr 16:29:32 ntpdate[3219]: adjust time server 91.189.91.157 offset 0.002041 sec
    default: 
    default:   ✧ ▄▀▀▀▄▄▄▄▄▄▄▀▀▀▄ ✧  Thanks for  __ __ __ __
    default:    ✧█▒▒░░░░░░░░░▒▒█    using       \ V\ V\ V /
    default:  ✧   █░░█░░░░░█░░█ ✧                \_/\_/\_/
    default:   ▄▄  █░░░▀█▀░░░█  ▄▄✧ 
    default:  █░░█ ▀▄░░░░░░░▄▀ █░░█ Vagrant Up has finished! Visit http://vvv.test
    default: ──────────────────────────────────────────────────────────────────────
ghost commented 3 years ago

basically vagrant reload --provision or vagrant reload does not trigger the Action::UpdateHosts

Mte90 commented 3 years ago

I guess that is this line where updatehosts is different: https://github.com/goodhosts/vagrant/blob/master/lib/vagrant-goodhosts/plugin.rb#L25

I will do some tests thanks :-)

Mte90 commented 3 years ago

Ticket opened on Vagrant: https://github.com/hashicorp/vagrant/issues/12334

ghost commented 3 years ago

seems like vagrant destroy doesn't trigger the removeHosts as well. in this case, we need a better title for this ticket.

Mte90 commented 3 years ago

So the provision hook is executed on provision I think that on reload they are not executed.

ghost commented 3 years ago

how about the vagrant destroy, that's not removing the hosts.

Mte90 commented 3 years ago

new release should fix this https://github.com/goodhosts/vagrant/releases/tag/1.0.16 I am closing it, in case is not working yet I will reopen the ticket.