2016-06-14 20:24:23 +00:00
|
|
|
---
|
|
|
|
# tasks file for unifi_controller_rhel
|
|
|
|
|
|
|
|
- name: abort if os is not suitable
|
|
|
|
when: ansible_os_family != "RedHat"
|
2016-06-14 23:17:13 +00:00
|
|
|
fail: msg="{{ansible_os_family}} is not supported by this playbook"
|
|
|
|
|
|
|
|
- name: create mongo repository
|
|
|
|
template: src=mongodb-org-3.2.repo.j2 dest=/etc/yum.repos.d/mongodb-org-3.2.repo owner=root group=root
|
2016-06-14 20:24:23 +00:00
|
|
|
|
|
|
|
- name: install java and mongodb
|
|
|
|
when: ansible_os_family == "RedHat"
|
|
|
|
yum: name={{ item }} state=present
|
|
|
|
with_items:
|
2016-06-15 00:19:20 +00:00
|
|
|
- java-1.7.0-openjdk
|
2016-06-14 23:17:13 +00:00
|
|
|
- mongodb-org
|
2016-06-14 20:24:23 +00:00
|
|
|
|
|
|
|
- name: no need for the standard mongod service
|
|
|
|
service: name=mongod enabled=no state=stopped
|
|
|
|
|
|
|
|
- name: setup unifi group
|
2016-06-14 23:17:13 +00:00
|
|
|
group: name={{ unifi_controller_rhel_unifi_gid }} system=yes state=present
|
2016-06-14 20:24:23 +00:00
|
|
|
|
|
|
|
- name: setup unifi user
|
2016-06-14 23:17:13 +00:00
|
|
|
user: name={{ unifi_controller_rhel_unifi_uid }} home={{ unifi_controller_rhel_unifi_prefix }}/UniFi createhome=no shell=/sbin/nologin system=yes state=present
|
2016-06-14 20:24:23 +00:00
|
|
|
|
|
|
|
- name: copy unifi zipball to host
|
2016-06-14 23:17:13 +00:00
|
|
|
copy: src={{ unifi_controller_rhel_unifi_zip_file }} dest={{ unifi_controller_rhel_unifi_zip_dest }} force=no
|
2016-06-14 20:24:23 +00:00
|
|
|
|
|
|
|
- name: extract unifi
|
2016-06-14 23:17:13 +00:00
|
|
|
command: /usr/bin/unzip -o {{ unifi_controller_rhel_unifi_zip_dest }} -d {{ unifi_controller_rhel_unifi_prefix }} creates={{ unifi_controller_rhel_unifi_prefix }}/UniFi
|
|
|
|
|
|
|
|
- name: create unifi data directory
|
|
|
|
file: dest={{ unifi_controller_rhel_unifi_prefix }}/UniFi/data state=directory
|
2016-06-14 20:24:23 +00:00
|
|
|
|
|
|
|
- name: fix permissions
|
2016-06-14 23:17:13 +00:00
|
|
|
command: /bin/chown -R {{ unifi_controller_rhel_unifi_uid }}:{{ unifi_controller_rhel_unifi_gid }} {{ unifi_controller_rhel_unifi_prefix }}/UniFi
|
2016-06-14 20:24:23 +00:00
|
|
|
|
|
|
|
- name: symlink mongod binary to where unifi path
|
2016-06-14 23:17:13 +00:00
|
|
|
file: src=/usr/bin/mongod dest={{ unifi_controller_rhel_unifi_prefix }}/UniFi/bin/mongod state=link
|
2016-06-14 20:24:23 +00:00
|
|
|
|
|
|
|
- name: install custom config.properties
|
2016-06-14 23:17:13 +00:00
|
|
|
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 }}
|
2016-06-14 20:24:23 +00:00
|
|
|
|
|
|
|
- name: install init script
|
2016-06-14 23:17:13 +00:00
|
|
|
template: src=unifi.init.j2 dest=/etc/init.d/UniFi owner=root group=root mode=755
|
2016-06-14 20:24:23 +00:00
|
|
|
|
2016-06-15 01:37:15 +00:00
|
|
|
- name: copy ssl cert
|
|
|
|
when: not (unifi_controller_rhel_ssl_cert is none)
|
|
|
|
copy: src={{ unifi_controller_rhel_ssl_cert }} dest=/root/cert.crt force=no
|
|
|
|
|
|
|
|
- name: copy ssl key
|
|
|
|
when: not (unifi_controller_rhel_ssl_key is none)
|
|
|
|
copy: src={{ unifi_controller_rhel_ssl_key }} dest=/root/key.crt force=no
|
|
|
|
|
|
|
|
- name: copy ssl bundle
|
|
|
|
when: not (unifi_controller_rhel_ssl_bundle is none)
|
|
|
|
copy: src={{ unifi_controller_rhel_ssl_bundle }} dest=/root/bundle.crt force=no
|
|
|
|
|
|
|
|
- name: convert ssl cert to pkcs12 format
|
|
|
|
when: not (unifi_controller_rhel_ssl_cert is none or unifi_controller_rhel_ssl_key is none or unifi_controller_rhel_ssl_bundle is none)
|
2016-06-16 00:45:53 +00:00
|
|
|
shell: openssl pkcs12 -export -in /root/cert.crt -inkey /root/key.crt -out /root/unifi.p12 -name unifi -CAfile /root/bundle.crt -caname root -password pass:aircontrolenterprise
|
2016-06-15 01:37:15 +00:00
|
|
|
|
|
|
|
- name: convert ssl cert to keystore
|
|
|
|
when: not (unifi_controller_rhel_ssl_cert is none or unifi_controller_rhel_ssl_key is none or unifi_controller_rhel_ssl_bundle is none)
|
2016-06-16 00:45:53 +00:00
|
|
|
shell: keytool -importkeystore -deststorepass aircontrolenterprise -destkeypass aircontrolenterprise -destkeystore {{ unifi_controller_rhel_unifi_prefix }}/UniFi/data/keystore -srckeystore /root/unifi.p12 -srcstoretype PKCS12 -srcstorepass aircontrolenterprise -alias unifi -noprompt
|
2016-06-15 01:37:15 +00:00
|
|
|
|
2016-06-14 20:24:23 +00:00
|
|
|
- name: start unifi service
|
2016-06-14 23:17:13 +00:00
|
|
|
service: name=UniFi enabled=yes state=started
|