xoxys.unifi/tasks/install.yml

88 lines
2.3 KiB
YAML
Raw Normal View History

2018-07-08 18:50:35 +02:00
---
2018-07-10 23:01:22 +02:00
- name: Setup directories
file:
path: "{{ item }}"
state: directory
owner: "{{ unifi_user }}"
group: "{{ unifi_group }}"
2019-02-03 23:26:35 +01:00
loop:
2018-07-10 23:01:22 +02:00
- "{{ unifi_base_dir }}"
- "{{ unifi_base_dir }}/{{ unifi_version }}"
2018-07-10 23:11:32 +02:00
- "{{ unifi_tmp_dir }}"
2018-07-10 23:01:22 +02:00
become: True
2018-08-18 16:22:31 +02:00
become_user: root
2018-07-10 23:01:22 +02:00
2018-07-08 22:36:54 +02:00
- block:
2019-01-09 22:11:03 +01:00
- name: Download unifi version '{{ unifi_version }}'
get_url:
url: "https://dl.ubnt.com/unifi/{{ unifi_version }}/UniFi.unix.zip"
dest: /tmp/UniFi.unix.zip
2019-08-04 22:34:55 +02:00
force: yes
2019-01-09 22:11:03 +01:00
- name: Setup unifi version '{{ unifi_version }}'
unarchive:
src: /tmp/UniFi.unix.zip
dest: "{{ unifi_base_dir }}/{{ unifi_version }}"
remote_src: yes
2018-07-08 22:31:07 +02:00
2019-01-09 22:11:03 +01:00
- name: Cleanup
file:
path: /tmp/UniFi.unix.zip
2019-08-04 22:58:26 +02:00
state: absent
2019-08-04 22:31:25 +02:00
when: unifi_version is version(unifi_current_version, ">") or unifi_current_version is version('0.0.0', "=")
2018-07-08 22:36:54 +02:00
become: True
become_user: "{{ unifi_user }}"
2018-07-08 23:35:10 +02:00
2018-07-12 00:31:16 +02:00
- block:
2019-01-09 22:11:03 +01:00
- name: Remove data folder from new version
file:
path: "{{ unifi_base_dir }}/{{ unifi_version }}//UniFi/data"
state: absent
become: True
become_user: "{{ unifi_user }}"
2018-07-12 00:31:16 +02:00
2019-01-09 22:11:03 +01:00
- name: Stop service while restore process
systemd:
state: stopped
enabled: yes
name: unifi
become: True
become_user: root
2018-07-12 23:02:27 +02:00
2019-01-09 22:11:03 +01:00
- name: Copy data folder from previews version
synchronize:
src: "{{ unifi_base_dir }}/{{ unifi_current_version }}/UniFi/data"
dest: "{{ unifi_base_dir }}/{{ unifi_version }}/UniFi"
become: True
become_user: "{{ unifi_user }}"
delegate_to: "{{ inventory_hostname }}"
2018-07-12 23:02:27 +02:00
2019-01-09 22:11:03 +01:00
- name: Start service after restore process
systemd:
state: started
enabled: yes
name: unifi
become: True
become_user: root
2018-07-12 00:31:16 +02:00
when:
2018-07-12 01:27:26 +02:00
- unifi_version is version(unifi_current_version, ">")
2018-07-12 00:31:16 +02:00
- unifi_restore_after_upgrade
2018-07-11 23:08:25 +02:00
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
2019-10-28 20:12:54 +01:00
- name: Create systemd unit files
template:
src: "etc/systemd/system/unifi.service.j2"
dest: "/etc/systemd/system/unifi.service"
mode: 0644
notify: __unifi_restart
2018-07-08 23:02:55 +02:00
become: True
2018-09-16 22:34:16 +02:00
become_user: root