Search code examples
linuxvagrantopnsense

Vagrant disable guest capability in Vagrantfile


I would like to disable one specific guest capability: "persist_mount_shared_folder"
Is this possible somehow in the Vagrantfile?

Reason:
The setting "config.vm.allow_fstab_modification = false" does not work as expected by me and still tries to clean up the fstab file.
See: https://github.com/hashicorp/vagrant/blob/main/lib/vagrant/action/builtin/synced_folders.rb#L140
So, setting that setting to "false" only sets the synced_folder list to "nil", which leads in the capability "persist_mount_shared_folder.rb" to try to remove all entries from fstab. (Which I did not expect to happen, because I set the setting do not allow for any modifications of the fstab file ...?)

I am building an OPNSense box (v21). Starting that box results in an error after connecting with SSH. The error is about the "sed" command which tries to cleanup the /etc/fstab file. Unfortunately that sed command does not work on this OPNSense version:

==> opnsense21: Machine booted and ready!
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

sed -i '/#VAGRANT-BEGIN/,/#VAGRANT-END/d' /etc/fstab

Stdout from the command:

Stderr from the command:
sed: 1: "/etc/fstab": invalid command code f

The sed command is defined in "persist_mount_shared_folder.rb line 66" but I do not know how to alter this command. So that's why I am trying to disable the capability.
The VM does not need any synced folders


Solution

  • I could resolve the issue myself by looking for other installed shells.
    I found the 'tcsh' shell. Setting it as the default shell for the communication during vagrant provision the error does not happen anymore, and I can proceed.

    config.ssh.shell = "tcsh"