Skip to content

Instantly share code, notes, and snippets.

@annashipman
Last active July 8, 2021 10:39
Show Gist options
  • Save annashipman/2f3a9454e0c1a41f9357a9196f34b0b0 to your computer and use it in GitHub Desktop.
Save annashipman/2f3a9454e0c1a41f9357a9196f34b0b0 to your computer and use it in GitHub Desktop.
Vagrantfile for running Ubiquiti controller software
## Vagrantfile for running Ubiquiti controller software
## Requires a folder alongside it called backup
Vagrant.configure("2") do |config|
  config.vm.box = "bento/ubuntu-20.04"
  config.vm.hostname = "unifi"
  config.vm.provider "virtualbox" do |v|
    v.name = "unifi"
  end
  config.vm.provision "shell", inline: <<-SHELL
    apt-get update
    apt-get install -y ca-certificates apt-transport-https
    # add the ubiquiti package index to apt, and add the GPG key
    echo 'deb https://www.ui.com/downloads/unifi/debian stable ubiquiti' | tee /etc/apt/sources.list.d/100-ubnt-unifi.list
    apt-key adv --keyserver keyserver.ubuntu.com --recv 06E85760C0A52C50
    # Ignore release codename changes so major unifi version bumps work automatically
    echo 'Acquire::AllowReleaseInfoChange::Codename "true";' | tee /etc/apt/apt.conf.d/99releaseinfochange
    # add the mongodb package index and GPG key
    echo "deb https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-3.4.list
    apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
    apt-get update
    # Ignore 'have you got a backup?' prompt from unifi installer
    echo "unifi unifi/has_backup boolean true" | debconf-set-selections
    DEBIAN_FRONTEND=noninteractive apt-get upgrade -y
    # Actually install unifi controller (and Java 8, which it requires)
    DEBIAN_FRONTEND=noninteractive apt-get install -y openjdk-8-jre-headless unifi
  SHELL
  config.vm.network "public_network", bridge: "en0: Ethernet"
  config.vm.synced_folder "backup/", "/var/lib/unifi/backup"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment