xoxys.unifi/tasks/install.yml

87 lines
2.1 KiB
YAML
Raw Normal View History

2018-07-08 16:50:35 +00:00
---
- 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 }}"
2018-07-08 20:31:07 +00:00
- name: Setup directories
2018-07-08 16:50:35 +00:00
file:
2018-07-08 20:31:07 +00:00
path: "{{ item }}"
2018-07-08 16:50:35 +00:00
state: directory
owner: "{{ unifi_user }}"
group: "{{ unifi_group }}"
2018-07-08 20:36:54 +00:00
recurse: True
2018-07-08 20:31:07 +00:00
with_items:
- "{{ unifi_base_dir }}"
- "{{ unifi_base_dir }}/{{ unifi_version }}"
2018-07-08 21:35:10 +00:00
- /etc/ansible/facts.d
2018-07-08 16:50:35 +00:00
become: True
2018-07-08 20:36:54 +00:00
- block:
- name: Download unifi version '{{ unifi_version }}'
get_url:
url: "https://dl.ubnt.com/unifi/{{ unifi_version }}/UniFi.unix.zip"
dest: /tmp/UniFi.unix.zip
force: true
2018-07-08 20:36:54 +00:00
- name: Setup unifi version '{{ unifi_version }}'
unarchive:
src: /tmp/UniFi.unix.zip
2018-07-08 20:36:54 +00:00
dest: "{{ unifi_base_dir }}/{{ unifi_version }}"
remote_src: yes
2018-07-08 20:31:07 +00:00
- name: Cleanup
file:
path: /tmp/UniFi.unix.zip
state: absent
2018-07-08 20:36:54 +00:00
become: True
become_user: "{{ unifi_user }}"
2018-07-08 21:35:10 +00:00
when: ansible_local.unifi.version is is version_compare(unifi_version, ">")
- name: Create symlink for latest version
file:
src: "{{ unifi_base_dir }}/{{ unifi_version }}"
dest: "{{ unifi_base_dir }}/latest"
state: link
notify: __unifi_restart
become: True
become_user: "{{ unifi_user }}"
2018-07-08 21:02:55 +00:00
- block:
- name: Create systemd unit files
template:
src: "etc/systemd/system/unifi.service.j2"
dest: "/etc/systemd/system/unifi.service"
mode: 0644
notify:
- __unifi_restart
- name: Ensure service is up and running
systemd:
state: started
daemon_reload: yes
enabled: yes
name: unifi
2018-07-08 21:35:10 +00:00
- name: Set current version to custom fact
template:
src: etc/ansible/fact.d/unifi.json.j2
dest: /etc/ansible/fact.d/unifi.json
when: ansible_local.unifi.version is is version_compare(unifi_version, ">")
2018-07-08 21:02:55 +00:00
become: True