2018-07-08 16:50:35 +00:00
|
|
|
---
|
2018-07-10 21:01:22 +00:00
|
|
|
- name: Setup directories
|
|
|
|
file:
|
|
|
|
path: "{{ item }}"
|
|
|
|
state: directory
|
|
|
|
owner: "{{ unifi_user }}"
|
|
|
|
group: "{{ unifi_group }}"
|
2021-02-06 13:40:58 +00:00
|
|
|
mode: 0750
|
2019-02-03 22:26:35 +00:00
|
|
|
loop:
|
2018-07-10 21:01:22 +00:00
|
|
|
- "{{ unifi_base_dir }}"
|
|
|
|
- "{{ unifi_base_dir }}/{{ unifi_version }}"
|
2018-07-10 21:11:32 +00:00
|
|
|
- "{{ unifi_tmp_dir }}"
|
2018-07-10 21:01:22 +00:00
|
|
|
become: True
|
2018-08-18 14:22:31 +00:00
|
|
|
become_user: root
|
2018-07-10 21:01:22 +00:00
|
|
|
|
2018-07-08 20:36:54 +00:00
|
|
|
- block:
|
2019-01-09 21:11:03 +00: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 20:34:55 +00:00
|
|
|
force: yes
|
2018-07-08 20:48:29 +00:00
|
|
|
|
2019-01-09 21:11:03 +00: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 20:31:07 +00:00
|
|
|
|
2019-01-09 21:11:03 +00:00
|
|
|
- name: Cleanup
|
|
|
|
file:
|
|
|
|
path: /tmp/UniFi.unix.zip
|
2019-08-04 20:58:26 +00:00
|
|
|
state: absent
|
2019-08-04 20:31:25 +00:00
|
|
|
when: unifi_version is version(unifi_current_version, ">") or unifi_current_version is version('0.0.0', "=")
|
2018-07-08 20:36:54 +00:00
|
|
|
become: True
|
|
|
|
become_user: "{{ unifi_user }}"
|
2018-07-08 21:35:10 +00:00
|
|
|
|
2018-07-11 22:31:16 +00:00
|
|
|
- block:
|
2019-01-09 21:11:03 +00: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-11 22:31:16 +00:00
|
|
|
|
2019-01-09 21:11:03 +00:00
|
|
|
- name: Stop service while restore process
|
|
|
|
systemd:
|
|
|
|
state: stopped
|
|
|
|
enabled: yes
|
|
|
|
name: unifi
|
|
|
|
become: True
|
|
|
|
become_user: root
|
2018-07-12 21:02:27 +00:00
|
|
|
|
2019-01-09 21:11:03 +00: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 21:02:27 +00:00
|
|
|
|
2019-01-09 21:11:03 +00:00
|
|
|
- name: Start service after restore process
|
|
|
|
systemd:
|
|
|
|
state: started
|
|
|
|
enabled: yes
|
|
|
|
name: unifi
|
|
|
|
become: True
|
|
|
|
become_user: root
|
2018-07-11 22:31:16 +00:00
|
|
|
when:
|
2018-07-11 23:27:26 +00:00
|
|
|
- unifi_version is version(unifi_current_version, ">")
|
2018-07-11 22:31:16 +00:00
|
|
|
- unifi_restore_after_upgrade
|
2018-07-11 21:08:25 +00:00
|
|
|
|
2018-07-08 21:35:10 +00: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 21:02:55 +00:00
|
|
|
|
2019-10-28 19:12:54 +00: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 21:02:55 +00:00
|
|
|
become: True
|
2018-09-16 20:34:16 +00:00
|
|
|
become_user: root
|