initial commit

This commit is contained in:
Robert Kaussow 2018-07-08 18:50:35 +02:00
parent a8741f79ca
commit 23e87afc4c
4 changed files with 79 additions and 0 deletions

15
defaults/main.yml Normal file
View File

@ -0,0 +1,15 @@
---
unifi_version: 5.6.39
unifi_openjdk_version: 1.7.0
unifi_group: ubnt
unifi_user: ubnt
unifi_lvm_enabled: False
# unifi_lvm_pvs:
# - /dev/sda
# unifi_lvm_vg: vg_unifi
# unifi_lvm_lv: lv_unifi
# unifi_lvm_size: 10G
# unifi_lvm_fstype: ext4
unifi_base_dir: /opt/unifi

34
tasks/install.yml Normal file
View File

@ -0,0 +1,34 @@
---
- block:
- name: Install requirements
package:
name: "{{ item }}"
state: present
with_items:
- "java-{{ unifi_openjdk_version }}-openjdk"
- unzip
- wget
- name: Create group '{{ unifi_group }}'
group:
name: "{{ unifi_group }}"
state: present
- name: Create user '{{ unifi_user }}'
user:
name: "{{ unifi_user }}"
group: "{{ unifi_group }}"
- name: Setup working dir at '{{ unifi_base_dir }}'
file:
path: "{{ unifi_base_dir }}"
state: directory
owner: "{{ unifi_user }}"
group: "{{ unifi_group }}"
become: True
- name: Setup unifi version '{{ unifi_version }}'
unarchive:
src: "https://dl.ubnt.com/unifi/{{ unifi_version }}/UniFi.unix.zip"
dest: "{{ unifi_base_dir }}/{{ unifi_version }}"
remote_src: yes

4
tasks/main.yml Normal file
View File

@ -0,0 +1,4 @@
---
- include_tasks: prepare_storage.yml
when: unifi_lvm_enabled
- include-tasks: install.yml

26
tasks/prepare_storage.yml Normal file
View File

@ -0,0 +1,26 @@
---
- block:
- name: Create volume group '{{ unifi_lvm_vg }}'
lvg:
vg: "{{ unifi_lvm_vg }}"
pvs: "{{ unifi_lvm_pvs|join(',') }}"
- name: Create logical volume '{{ unifi_lvm_lv }}'
lvol:
vg: "{{ unifi_lvm_vg }}"
lv: "{{ unifi_lvm_lv }}"
size: "{{ unifi_lvm_size }}"
- name: Create filesystem for '/dev/mapper/{{ unifi_lvm_vg }}-{{ unifi_lvm_lv }}'
filesystem:
fstype: "{{ unifi_lvm_fstype }}"
dev: "/dev/mapper/{{ unifi_lvm_vg }}-{{ unifi_lvm_lv }}"
resizefs: True
- name: Mount volume to '{{ unifi_storage_dbpath }}'
mount:
path: "{{ unifi_storage_dbpath }}"
src: "/dev/mapper/{{ unifi_lvm_vg }}-{{ unifi_lvm_lv }}"
fstype: "{{ unifi_lvm_fstype }}"
state: mounted
become: True