Skip to content

Instantly share code, notes, and snippets.

@mattkaar
Created May 30, 2017 03:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattkaar/5a383395aed21e346f7721db9a11ed2e to your computer and use it in GitHub Desktop.
Save mattkaar/5a383395aed21e346f7721db9a11ed2e to your computer and use it in GitHub Desktop.
# Installs Ubiquiti UniFi Controller on Raspian (Raspberry Pi 2/3)
# adapted from: https://loganmarchione.com/2016/11/ubiquiti-unifi-controller-setup-raspberry-pi-3/
---
- hosts: newpi
become: true
tasks:
- name: Add apt key for unifi repository
apt_key:
keyserver: keyserver.ubuntu.com
id: C0A52C50
- name: Add unifi repository
apt_repository:
repo: deb http://www.ubnt.com/downloads/unifi/debian stable ubiquiti
state: present
filename: unifi
- name: Update apt cache and install unifi and java packages
apt:
name: "{{ item }}"
state: latest
update_cache: yes
cache_valid_time: 3600
with_items:
- unifi
- oracle-java8-jdk
- name: Switch to Oracle Java 8
alternatives:
name: java
path: /usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/jre/bin/java
- name: Copy unifi.service to /etc/systemd/system
command: cp -p /lib/systemd/system/unifi.service /etc/systemd/system
- name: Add JAVA_HOME to unifi.service
lineinfile:
path: /etc/systemd/system/unifi.service
insertafter: '\[Service\]'
line: "Environment=JAVA_HOME=/usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt"
state: present
- name: Start unifi service and enable at boot
systemd:
name: unifi
state: restarted
daemon_reload: yes
enabled: yes
- name: Disable mongodb as unifi will run its own instance
systemd:
name: mongodb
state: stopped
enabled: no
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment