xoxys.unifi/tasks/install.yml

54 lines
1.5 KiB
YAML
Raw Normal View History

2018-07-08 18:50:35 +02:00
---
2018-07-08 22:36:54 +02: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 22:36:54 +02:00
- name: Setup unifi version '{{ unifi_version }}'
unarchive:
src: /tmp/UniFi.unix.zip
2018-07-08 22:36:54 +02:00
dest: "{{ unifi_base_dir }}/{{ unifi_version }}"
remote_src: yes
2018-07-08 22:31:07 +02:00
- name: Cleanup
file:
path: /tmp/UniFi.unix.zip
state: absent
2018-07-08 22:36:54 +02:00
become: True
become_user: "{{ unifi_user }}"
2018-07-09 00:53:57 +02:00
when: unifi_current_version is version_compare(unifi_version, ">") or unifi_current_version is version_compare('0.0.0', "=")
2018-07-08 23:35:10 +02:00
- 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 23:02:55 +02: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 23:35:10 +02:00
- name: Set current version to custom fact
template:
2018-07-09 01:01:20 +02:00
src: etc/ansible/facts.d/unifi.json.j2
dest: /etc/ansible/facts.d/unifi.json
2018-07-09 00:53:57 +02:00
when: unifi_current_version is version_compare(unifi_version, ">") or unifi_current_version is version_compare('0.0.0', "=")
2018-07-08 23:02:55 +02:00
become: True