I wanted to use office software in a VM, while being able to edit files on the host machine. Usually, people create a VM in VirtualBox and map the host directory into this VM using shared folders. But, because it is a long process, I decided to automate it using Vagrant.
TL;DR
- Go to this GitHub repository
- Download
Vagrantfile
and place it into your documents directory - Open your favourite CLI and change into that directory
- Run
vagrant up
to configure the VM and wait for a while - Run
vagrant rdp
and use vagrant as login and as password - Open LibreOffice and configure your personal data, so the documents with data fields can set them to appropriate values
- Edit your documents on the host system!
Design decisions
The Vagrantfile
must be placed into directory with documents you want to edit. Of course, I could add the default documents directory on the host OS, but I decided against it: first, it would create additional maintenance burden (especially if the syntax for default OS paths changes), and second, it would not work on systems, where the documents directory was moved to another location. So, for now, the entry for synchronised directory is
config.vm.synced_folder ".", "/home/vagrant/Documents", mount_options: ["dmode=775,fmode=664"]
The VM created by Vagrant is based on Ubuntu Bionic x64. The Vagrantfile
installs the packages xubuntu-desktop
and libreoffice
. Then it also enables Remote Desktop connexions by installing xrdp
, by starting it automatically as a service and by enabling port 3389. The forwarding to the port is configured with
config.vm.network "forwarded_port", guest: 3389, host: 33389, protocol: "tcp", auto_correct: true
The automatic start of XFCE session is enabled by adding xfce4-session
to the file .xsession
. Everything is run as the default Vagrant user vagrant
.
Top comments (0)