maxbyte9p / oelabox

Infrastructure in a box designed for Enterprise Linux development. Utilizes Vagrant and Ansible for virtual machine provisioning.
GNU General Public License v3.0
15 stars 2 forks source link

Figure out a way to sync the tools directory into virtual machines. #10

Closed maxbyte9p closed 5 months ago

maxbyte9p commented 5 months ago

Directory sharing/syncing is a bit buggy for whatever reason. NFS doesn't want to work, Vagrant's default way of doing it also doesn't want to work, the vagrant-sshfs plugin makes the vms unstable. I don't want to use rsync as that requires running a command inside a VM or restarting a VM. virtiofs may be a good option, so will look into that.

maxbyte9p commented 5 months ago

Working on this now.

maxbyte9p commented 5 months ago

Adding this code to the Vagrant file seems to work. Will have to keep an eye on stability however.

config.vm.provider :libvirt do |v|
    v.memorybacking :access, :mode => "shared"
end

config.vm.synced_folder "./", "/vagrant", type: "virtiofs"

vagrant-libvirt docs: https://vagrant-libvirt.github.io/vagrant-libvirt/examples.html#synced-folders

Also need to note Rocky 9.3 has libvirt 9.5.0

maxbyte9p commented 5 months ago

It seems that for the IPA server virtiofs or the shared memory mode makes the network unstable for the IPA server. Once the provisioning playbook gets to the "Setup CA" the VM becomes disconnected and fails to provision.

maxbyte9p commented 5 months ago

If it's because of shared memory mode It's hard to say whether it's because the test VM also using shared memory mode running Oela Box nested or just a weird quirk.

maxbyte9p commented 5 months ago

Having a virtual machine using shared memory run nested virtual machines using shared memory no worky. I setup Oela Box to use virtiofs on my host and it now works. I don't know if disabling shared memory for the test VM will work or not yet.

maxbyte9p commented 5 months ago

virtiofs just doesn't work for nested VMs

maxbyte9p commented 5 months ago

Found something kinda hacky, weird and neat to get around these issues. I've been messing with 9p server written in rust and a 9p client written in go which correctly handles mounting it as a FUSE filesystem.

I've been able to get the client and the server to communicate from inside a Vagrant virtual machine. It may be possible to have a reliable file share between the host and the VMs without much hacking around.

Note: need to open 9p server port for libvirt zone, so guest can communicate with host

A custom 9p server could also prove useful as a way to do some interesting experiments. I have some old ideas I'm interested in recycling. We'll see.

maxbyte9p commented 5 months ago

So I think I found the way to do this. I found a 9p client implementation on a 9fans forum post and found a 9p file sharing server implementation from the p9 library. The 9fans 9p fuse client uses the p9 library as well.

I'm planning on forking p9 and the 9fans program and bundling them together. I've already got a proof of concept working for file sharing in Oela Box. It works with nested VMs and Oela Box provisioned without any issues.

maxbyte9p commented 5 months ago

So I think I found the way to do this. I found a 9p client implementation on a 9fans forum post and found a 9p file sharing server implementation from the p9 library. The 9fans 9p fuse client uses the p9 library as well.

I'm planning on forking p9 and the 9fans program and bundling them together. I've already got a proof of concept working for file sharing in Oela Box. It works with nested VMs and Oela Box provisioned without any issues.

The 9fans program is the program mentioned previously btw. This setup also requires opening the server port for the libvirt zone.

maxbyte9p commented 5 months ago

I think I figured out a better way to do this. That is to just use Ansible. I'm still keeping 9p in mind for later use though.

maxbyte9p commented 5 months ago

Went with the method of essentially using Ansible as a package manager. It's a just good enough solution.