initial commit
This commit is contained in:
parent
c83f62046d
commit
b2eb6ce7aa
32
README.md
32
README.md
|
@ -1,4 +1,30 @@
|
||||||
unifi-controller-rhel
|
# unifi-controller-rhel
|
||||||
=====================
|
|
||||||
|
|
||||||
Anisble playbook for installing UniFi Controller for Ubiquiti Access Points on RHEL 6
|
## About
|
||||||
|
|
||||||
|
Anisble playbook for installing UniFi Controller software for Ubiquiti
|
||||||
|
Access Points on RHEL 6
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
You need the EPEL Repository from Fedora Project enabled to be able to
|
||||||
|
install the requirements (MongoDB etc).
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
You must download the ZIP of the UniFi Controller software from the Ubiquiti
|
||||||
|
website and save it to the same folder as the playbook as "UniFi.zip"
|
||||||
|
|
||||||
|
Optionally, update the playbook variable 'ntp_server' to point to your
|
||||||
|
preferred NTP server for the AP's to use.
|
||||||
|
|
||||||
|
The playbook will run against the "unifi_controllers" group in your Ansible
|
||||||
|
inventory:
|
||||||
|
|
||||||
|
ansible-playbook unifi.play
|
||||||
|
|
||||||
|
## Support
|
||||||
|
|
||||||
|
There is none. Tested on CentOS 6 x86_64. Not tested on animals.
|
||||||
|
|
||||||
|
Your results may vary. Discontinue use and see a doctor if rash occurs.
|
||||||
|
|
1
config.properties
Normal file
1
config.properties
Normal file
|
@ -0,0 +1 @@
|
||||||
|
config.ntp_server={{ ntp_server }}
|
69
unifi.init
Executable file
69
unifi.init
Executable file
|
@ -0,0 +1,69 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# chkconfig: 2345 95 20
|
||||||
|
# description: UniFi system
|
||||||
|
# processname: unifi
|
||||||
|
|
||||||
|
NAME="unifi"
|
||||||
|
DESC="Ubiquiti UniFi Controller"
|
||||||
|
|
||||||
|
BASEDIR="{{unifi_prefix}}/UniFi"
|
||||||
|
MAINCLASS="com.ubnt.ace.Launcher"
|
||||||
|
|
||||||
|
PIDFILE="/var/run/${NAME}/${NAME}.pid"
|
||||||
|
PATH=/bin:/usr/bin:/sbin:/usr/sbin
|
||||||
|
|
||||||
|
JAVA_HOME=/usr/lib/jvm/java-6-openjdk
|
||||||
|
# JSVC - for running java apps as services
|
||||||
|
JSVC=`which jsvc`
|
||||||
|
#JSVC_OPTS="-debug"
|
||||||
|
JSVC_OPTS="${JSVC_OPTS}\
|
||||||
|
-home ${JAVA_HOME} \
|
||||||
|
-cp /usr/share/java/commons-daemon.jar:${BASEDIR}/lib/ace.jar \
|
||||||
|
-pidfile ${PIDFILE} \
|
||||||
|
-procname ${NAME} \
|
||||||
|
-outfile SYSLOG \
|
||||||
|
-errfile SYSLOG \
|
||||||
|
-Djava.awt.headless=true -Xmx1024M"
|
||||||
|
|
||||||
|
# Source function library.
|
||||||
|
. /etc/init.d/functions
|
||||||
|
|
||||||
|
[ -d /var/run/${NAME} ] || mkdir -p /var/run/${NAME}
|
||||||
|
cd ${BASEDIR}
|
||||||
|
|
||||||
|
ctrl_start() {
|
||||||
|
${JSVC} ${JSVC_OPTS} ${MAINCLASS} start
|
||||||
|
}
|
||||||
|
|
||||||
|
ctrl_stop() {
|
||||||
|
${JSVC} ${JSVC_OPTS} ${MAINCLASS} stop
|
||||||
|
}
|
||||||
|
|
||||||
|
ctrl_restart() {
|
||||||
|
ctrl_stop
|
||||||
|
sleep 3
|
||||||
|
ctrl_start
|
||||||
|
}
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
start)
|
||||||
|
echo -n "starting UniFi system ..."
|
||||||
|
ctrl_start
|
||||||
|
echo " service started"
|
||||||
|
;;
|
||||||
|
stop)
|
||||||
|
echo -n "stopping UniFi system ..."
|
||||||
|
ctrl_stop
|
||||||
|
echo " service stopped"
|
||||||
|
;;
|
||||||
|
restart)
|
||||||
|
echo -n "restarting UniFi system ..."
|
||||||
|
ctrl_restart
|
||||||
|
echo "service restarted"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "usage: service unifi {start|stop|restart}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
exit 0
|
54
unifi.play
Normal file
54
unifi.play
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
- hosts: unifi_controllers
|
||||||
|
vars:
|
||||||
|
- unifi_zip_file: UniFi.zip
|
||||||
|
- unifi_zip_dest: /usr/local/src/UniFi.zip
|
||||||
|
- unifi_prefix: /opt
|
||||||
|
- unifi_uid: unifi
|
||||||
|
- unifi_gid: unifi
|
||||||
|
- ntp_server: pool.ntp.org
|
||||||
|
sudo: yes
|
||||||
|
tasks:
|
||||||
|
|
||||||
|
- name: check os is ok
|
||||||
|
when: ansible_os_family != "RedHat"
|
||||||
|
fail: "msg={{ansible_os_family}} is not supported by this playbook"
|
||||||
|
|
||||||
|
- name: install java and mongodb
|
||||||
|
when: ansible_os_family == "RedHat"
|
||||||
|
yum: name={{ item }} state=present
|
||||||
|
with_items:
|
||||||
|
- java-1.7.0-openjdk
|
||||||
|
- jakarta-commons-daemon-jsvc
|
||||||
|
- mongodb-server
|
||||||
|
|
||||||
|
- name: ensure mongod is running
|
||||||
|
service: name=mongod enabled=yes state=started
|
||||||
|
|
||||||
|
- name: setup unifi group
|
||||||
|
group: name={{ unifi_gid }} system=yes state=present
|
||||||
|
|
||||||
|
- name: setup unifi user
|
||||||
|
user: name={{ unifi_uid }} home={{ unifi_prefix }}/UniFi createhome=no shell=/sbin/nologin system=yes state=present
|
||||||
|
|
||||||
|
- name: copy unifi zipball to host
|
||||||
|
copy: src={{ unifi_zip_file }} dest={{ unifi_zip_dest }}
|
||||||
|
|
||||||
|
- name: extract unifi
|
||||||
|
command: /usr/bin/unzip -f -o {{ unifi_zip_dest }} -d {{ unifi_prefix }}
|
||||||
|
|
||||||
|
- name: fix permissions
|
||||||
|
command: /bin/chown -R {{ unifi_uid }}:{{ unifi_gid }} {{ unifi_prefix }}/UniFi
|
||||||
|
|
||||||
|
- name: symlink mongod binary to where unifi path
|
||||||
|
file: src=/usr/bin/mongod dest={{ unifi_prefix }}/UniFi/bin/mongod state=link
|
||||||
|
|
||||||
|
- name: install custom config.properties
|
||||||
|
template: src=config.properties dest={{ unifi_prefix }}/UniFi/data/config.properties owner={{ unifi_uid }} group={{ unifi_gid }}
|
||||||
|
|
||||||
|
- name: install init script
|
||||||
|
copy: src=unifi.init dest=/etc/init.d/unifi owner=root group=root mode=755
|
||||||
|
|
||||||
|
- name: start unifi service
|
||||||
|
service: name=unifi enabled=yes state=started
|
Loading…
Reference in New Issue
Block a user