Skip to content

tgrants/dev-vm-ansible

Repository files navigation

dev-vm-ansible

Automated development virtual machine setup for students using Ansible. Created to reduce the time spent in classrooms downloading and configuring virtual machines.

Features

  • Lightweight - Runs smoothly on modest hardware (tested with 2 GiB RAM)
  • Compact - Initial VirtualBox disk size: ~4 GiB (<1 GiB compressed)
  • Preconfigured tools - comes with development software and setup scripts to quickly install more

Tools

Category Tools Install scripts
Editors VSCode, VS Code Server
Languages PHP 8.4, Python 3.13
Databases Sqlite3 MariaDB
Version Control Git GitHub CLI
Browsers Firefox
Dependency management Composer

Download

If you don't require a custom configuration, you can use one of these premade virtual machines.

Note

It is recommended to use the latest available stable version. Older versions could be different - make sure you follow the corresponding version of the docs.

Name Size, GiB Compressed, GiB Date Link
dvm_v7-dev.2.tar.xz 2.97 0.68 2025-11-24 Google Drive
dvm_v6.tar.xz 3.66 0.86 2025-11-20 Google Drive
dvm_v6_preview.tar.xz 3.90 1.02 2025-10-20 Google Drive
dvm_v5.tar.xz [1] 4.12 1.15 2025-09-11 Google Drive
dvm_v3.tar.xz [1][2] 3.94 0.75 2024-09-28 Google Drive

[1] Virtual Disk Image only
[2] Password is 'changeme'

Similar projects

Instructions

Control machine

To run the playbook, you need to install Ansible on your control machine.

Virtualbox

Create the virtual machine

  • Create a Virtualbox VM
    • At least 2 GiB RAM is recommended for using an IDE and a browser at the same time
    • A 20 GB VDI disk should be enough, adjust for your requirements
  • Install Debian 13
    • In the installer menu, press TAB and add expert priority=low
    • Choose language en_US.UTF-8 locale
    • Load installer components from installation media
    • Configure the network
      • Set the hostname e.g. devvm
    • Set up users and passwords
    • Create users (or update hosts)
      • Create a root user with password pass, allow login as root`
      • Create user with password pass
    • Configure the clock
    • Detect and partition disks
      • Select "Guided - use entire disk" and "All files in one partiton" for a simple setup
      • Manually create a single partition for a swapless setup
        • Partition table type - msdos
        • Use as: Ext4 journaling file system
        • Mount point: /
        • Bootable flag: on
    • Install the base system
      • Drivers to include in initrd: targeted
    • Configure the package manager
    • Install the GRUB boot loader
    • Select and install software
      • Select only SSH server, deselect everything else
  • Prepare the VM for Ansible (after booting it for the first time)
    • Log in as root
    • Update VM network settings in VirtualBox Settings > Network > Attached to > Bridged Adapter
    • Restart network service systemctl restart networking
    • Get the ip address with ip a and update hosts in this repository
    • Install sudo and python for Ansible apt install sudo python3
    • Add user to sudoers adduser user sudo
    • Copy key by SSH-ing into the VM from the control machine ssh user@ip_address
  • Setup the VM
    • Copy and adjust the hosts file cp hosts.example hosts
      • Replace VM_IP_ADDRESS with the ip from the previous step
    • Edit files to customize your setup
    • Run the setup playbook ansible-playbook playbooks/setup.yml
      • Some checks may throw an error when run for the first time
    • Reboot

Telemetry

Some data is collected to estimate the amount of premade VMs in use and their versions. Settings are defined in combine.conf. You can enable and disable this by running combine on/off or editing the config manually.

The following data is collected: public_ip, timestamp, id and version.

Trim virtual disk

  • Remove all unnecessary files ansible-playbook playbooks/cleanup.yml
  • On VM, run clear-disk, then shut it down
  • On host, run vboxmanage modifymedium /mnt/storage/VBOX/dev_vm/dev_vm.vdi --compact
    • Edit this path to match your .vdi file

Updates

It is recommended to run new versions of these playbooks on a fresh Debian install. Re-running them should work most of the time, but may occasionally cause issues.

For details on changes, check the Releases page on GitHub.

Contributing

Before submitting a pull request, please discuss your proposed changes in an issue first. Feel free to open an issue if you encounter a problem or have any questions.

License

This project is licensed under the terms of the MIT license (v4+). See the LICENSE file for more information.