I recently moved into a new house (yay!) and had to get my network up and running again. I have been running a full Unifi setup for almost a year now and have been very happy with it. Originally I was running the Unifi controller in a container with the rest of my containerized set up. This was fine, until I moved and needed to have access to the controller, and the network, but didn’t have the entirety of my server infrastructure up and running. Enter the Pi!

First off I want to give a shout-out to Rudy over at lazyadmin.nl. I pretty much used his tutorial for running the Unifi controller on a Pi as a jumping off point for the Ansible role.

I have a Raspberry Pi already attached to my network that runs the PiHole service. This little thing does little to no work at all, so I figured it would make sense to also put the Unifi controller on it as well. I decided to write an Ansible role for it, since the PiHole itself, and DNS entries for my network, are also already in a role.

At some point I’ll get it set up for using Ansible Galaxy, but since it’s only one file, and I’m lazy and still moving (hence having very little time) here is the main.yml:

---
  - name: Install needed software
    package:
      pkg: "{{ item }}"
      state: installed
      update_cache: true
    with_items:
      - apt-transport-https
      - curl
      - openjdk-8-jre-headless
      - procps
      - libcap2-bin

  - name: Add the new keys from the key server
    apt_key:
      keyserver: keyserver.ubuntu.com
      id: 06E85760C0A52C50

  - name: Add the ubnt repo
    apt_repository:
      repo: deb http://www.ubnt.com/downloads/unifi/debian stable ubiquiti
      state: present

  - name: Install the unifi software
    package:
      pkg: unifi
      state: installed
      update_cache: true

  - name: Stop and disable the MongoDB service
    systemd:
      name: mongodb
      state: stopped
      enabled: no

After this role completes you will need to reboot the Pi (or kill the Mongo service since it doesn’t actually stop even when you stop the service). Once the Pi comes back up, you are good to go!