I’m working with Trellis, which is a framework around a Vagrant VM and an Ansible setup. It has a quite extensive Vagrantfile
There are a couple of conditionals in the Vagrantfile, so I was hoping to see which of the conditionals was ‘hit’, after the setup has completed.
I was hoping for a:
vagrant info-command or something, where I could see:
- Shared folder: Which folders are shared. And if they’re using NFS or not. And ideally more info, to be able to debug this further.
Plugins: If Vagrant registers the
vagrant-hostmanager-plugin to be installed? I mean, I can see that is it writing:
vagrant plugin list, but it would be cool to confirm that the running instance agree with my reading it off that list.
vconfig: In above-linked Vagrantfile, the settings for the VM is ‘built’, by adding stuff to
vconfig-variables throughout the Vagrantfile. Can I access what those variables contains, after
vagrant uphas been done?
Solution attempt 1:
puts-commands in Vagrantfile
Since the Vagrantfile is Ruby, then I could add
puts-lines throughout the Vagrantfile, and then see what they output, when running
vagrant up. It just seems hacky.
UPDATE: DON’T DO THIS!! It can add these debug-lines to other files, such as
~/.ssh/config and stop other stuff from working (like
ssh-ing into the VM).
This also taught me, that the Vagrantfile is parsed/gone through/handled several times during the
vagrant up-command. Interesting!
Solution attempt 2: Documentation
I looked through Vagrants documentation.
I also tried writing
vagrant -h in my terminal, but couldn’t see any either.
Solution attempt 3: Reading through output, when running
vagrant up, it outputs a bunch of info. Reading through that, gives some kind of and idea of what has happened. But not entirely.
I’m experiencing some poor performance - and I think I can track it down to the network-interface being overloaded, due to a high amount of files in the ‘shared folder’.
The VM is using vagrant-bindfs. If i run this command inside the box:
tcpdump -i any port not 22 -nnvvS, while having bpytop installed, that the network interface is reeeeeally burdened, every 15 seconds or so. It seems to match when a bunch of NFS-requests are shown in the
tcpdump. So I’m trying to verify how Vagrant are sync’ing those files between the host machine and the VM.
Here are an example of the output from the
tcpdump-command from above:
11:57:05.667828 IP (tos 0x0, ttl 64, id 17549, offset 0, flags [none], proto UDP (17), length 140) 192.168.50.1.2049 > 192.168.50.5.709: NFS reply xid 2975816564 reply ok 112 getattr REG 644 ids 501/20 sz 374 11:57:05.668087 IP (tos 0x0, ttl 64, id 3408, offset 0, flags [DF], proto UDP (17), length 156) 192.168.50.5.709 > 192.168.50.1.2049: NFS request xid 2992593780 128 getattr fh Unknown/4E580000477DBD310000000200000000080000001B41590000000000 11:57:05.668231 IP (tos 0x0, ttl 64, id 5446, offset 0, flags [none], proto UDP (17), length 140) 192.168.50.1.2049 > 192.168.50.5.709: NFS reply xid 2992593780 reply ok 112 getattr REG 644 ids 501/20 sz 374 11:57:05.692617 IP (tos 0x0, ttl 64, id 3413, offset 0, flags [DF], proto UDP (17), length 156) 192.168.50.5.709 > 192.168.50.1.2049: NFS request xid 3009370996 128 getattr fh Unknown/4E580000477DBD310000000200000000080000004464890000000000 11:57:05.692894 IP (tos 0x0, ttl 64, id 19213, offset 0, flags [none], proto UDP (17), length 140) 192.168.50.1.2049 > 192.168.50.5.709: NFS reply xid 3009370996 reply ok 112 getattr DIR 755 ids 501/20 sz 256