Changing from Ansbile Playbook to Galaxy Role

This commit is contained in:
Will Bradley 2016-06-14 13:24:23 -07:00
parent 394b5341b4
commit 391ea1663c
12 changed files with 111 additions and 75 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
files/*.zip

View File

@ -1,31 +1,48 @@
# unifi-controller-rhel
UniFi Controller for RedHat/Centos/etc
======================================
## About
Ansible Galaxy role for installing UniFi Controller software for Ubiquiti Access Points on RHEL 6.
Anisble playbook for installing UniFi Controller software for Ubiquiti
Access Points on RHEL 6
Forked from https://github.com/fukawi2/unifi-controller-rhel and modified to be an includable role via Galaxy instead of a playbook.
## Requirements
Requirements
------------
You need the [EPEL Repository](https://fedoraproject.org/wiki/EPEL) from
Fedora Project enabled to be able to install the requirements (MongoDB etc):
- You need the [EPEL Repository](https://fedoraproject.org/wiki/EPEL) from Fedora Project enabled to be able to install the requirements (MongoDB etc)
- Ubiquiti's license does not allow redistribution of the software ZIP, so you must manually download the ZIP of the UniFi Controller software from the [Ubiquiti website](https://www.ubnt.com/download/unifi/) and save it to `files/UniFi.unix.zip`. The most recent tested version is "UniFi v5.0.6 Zip for DIY Unix/Linux" from 2016-06-01.
## Usage
Role Variables
--------------
Ubiquiti's license does not allow redistribution of the software ZIP, so you
must manually 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"
- **unifi_controller_rhel.ntp_server** (optional) sets your preferred NTP server for the UniFi APs to use
Optionally, update the playbook variable 'ntp_server' to point to your
preferred NTP server for the AP's to use.
Dependencies
------------
The playbook will run against the "unifi_controllers" group in your Ansible
inventory:
n/a
ansible-playbook unifi.play
Example Playbook
----------------
## Support
- hosts: your_unifi_controllers
sudo: yes
roles:
- zyphlar.unifi_controller_rhel
License
-------
BSD
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.
Author Information
------------------
- [fukawi2](https://github.com/fukawi2) (Original)
- [zyphlar](https://github.com/zyphlar) (Ansible Galaxy version)

View File

@ -1 +0,0 @@
config.ntp_server={{ ntp_server }}

2
defaults/main.yml Normal file
View File

@ -0,0 +1,2 @@
---
# defaults file for unifi_controller_rhel

View File

2
handlers/main.yml Normal file
View File

@ -0,0 +1,2 @@
---
# handlers file for unifi_controller_rhel

15
meta/main.yml Normal file
View File

@ -0,0 +1,15 @@
---
galaxy_info:
author: zyphlar
description: UniFi Controller for RedHat/Centos/etc
company: Zyphon LLC
license: license (MIT)
min_ansible_version: 1.2
platforms:
- name: EL
versions:
- 6
galaxy_tags:
- networking
- monitoring
dependencies: []

44
tasks/main.yml Normal file
View File

@ -0,0 +1,44 @@
---
# tasks file for unifi_controller_rhel
- name: abort if os is not suitable
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.6.0-openjdk
- jakarta-commons-daemon-jsvc
- mongodb-server
- name: no need for the standard mongod service
service: name=mongod enabled=no state=stopped
- name: setup unifi group
group: name={{ unifi_controller_rhel.unifi_gid }} system=yes state=present
- name: setup unifi user
user: name={{ unifi_controller_rhel.unifi_uid }} home={{ unifi_controller_rhel.unifi_prefix }}/UniFi createhome=no shell=/sbin/nologin system=yes state=present
- name: copy unifi zipball to host
copy: src={{ unifi_controller_rhel.unifi_zip_file }} dest={{ unifi_controller_rhel.unifi_zip_dest }}
- name: extract unifi
command: /usr/bin/unzip -o {{ unifi_controller_rhel.unifi_zip_dest }} -d {{ unifi_controller_rhel.unifi_prefix }} creates=/opt/UniFi
- name: fix permissions
command: /bin/chown -R {{ unifi_controller_rhel.unifi_uid }}:{{ unifi_controller_rhel.unifi_gid }} {{ unifi_controller_rhel.unifi_prefix }}/UniFi
- name: symlink mongod binary to where unifi path
file: src=/usr/bin/mongod dest={{ unifi_controller_rhel.unifi_prefix }}/UniFi/bin/mongod state=link
- name: install custom config.properties
template: src=config.properties.j2 dest={{ unifi_controller_rhel.unifi_prefix }}/UniFi/data/config.properties owner={{ unifi_controller_rhel.unifi_uid }} group={{ unifi_controller_rhel.unifi_gid }}
- name: install init script
template: src=unifi.init.j2 dest=/etc/init.d/unifi owner=root group=root mode=755
- name: start unifi service
service: name=unifi enabled=yes state=started

View File

@ -0,0 +1 @@
config.ntp_server={{ unifi_controller_rhel.ntp_server }}

View File

@ -6,13 +6,13 @@
NAME="unifi"
DESC="Ubiquiti UniFi Controller"
BASEDIR="{{unifi_prefix}}/UniFi"
BASEDIR="{{ unifi_controller_rhel.unifi_prefix }}/UniFi"
MAINCLASS="com.ubnt.ace.Launcher"
PIDFILE="/var/run/${NAME}/${NAME}.pid"
PATH=/bin:/usr/bin:/sbin:/usr/sbin
JAVA_HOME="{{ java_home }}"
JAVA_HOME="{{ unifi_controller_rhel.java_home }}"
# JSVC - for running java apps as services
JSVC=`which jsvc`
#JSVC_OPTS="-debug"

View File

@ -1,55 +0,0 @@
---
- hosts: unifi_controllers
vars:
- unifi_zip_file: UniFi-2.4.6.zip
- unifi_zip_dest: /usr/local/src/UniFi-2.4.6.zip
- unifi_prefix: /opt
- unifi_uid: unifi
- unifi_gid: unifi
- ntp_server: pool.ntp.org
- java_home: /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64
sudo: yes
tasks:
- name: abort if os is not suitable
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.6.0-openjdk
- jakarta-commons-daemon-jsvc
- mongodb-server
- name: no need for the standard mongod service
service: name=mongod enabled=no state=stopped
- 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 -o {{ unifi_zip_dest }} -d {{ unifi_prefix }} creates=/opt/UniFi
- 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
template: 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

10
vars/main.yml Normal file
View File

@ -0,0 +1,10 @@
---
# vars file for unifi_controller_rhel
- unifi_controller_rhel.ntp_server: pool.ntp.org
- unifi_controller_rhel.unifi_zip_file: UniFi.unix.zip
- unifi_controller_rhel.unifi_zip_dest: /usr/local/src/UniFi-2.4.6.zip
- unifi_controller_rhel.unifi_prefix: /opt
- unifi_controller_rhel.unifi_uid: unifi
- unifi_controller_rhel.unifi_gid: unifi
- unifi_controller_rhel.java_home: /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64