Robert Kaussow
baad567860
All checks were successful
continuous-integration/drone/push Build is passing
88 lines
2.3 KiB
YAML
88 lines
2.3 KiB
YAML
---
|
|
- name: Setup directories
|
|
file:
|
|
path: "{{ item }}"
|
|
state: directory
|
|
owner: "{{ unifi_user }}"
|
|
group: "{{ unifi_group }}"
|
|
loop:
|
|
- "{{ unifi_base_dir }}"
|
|
- "{{ unifi_base_dir }}/{{ unifi_version }}"
|
|
- "{{ unifi_tmp_dir }}"
|
|
become: True
|
|
become_user: root
|
|
|
|
- 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: yes
|
|
|
|
- name: Setup unifi version '{{ unifi_version }}'
|
|
unarchive:
|
|
src: /tmp/UniFi.unix.zip
|
|
dest: "{{ unifi_base_dir }}/{{ unifi_version }}"
|
|
remote_src: yes
|
|
|
|
- name: Cleanup
|
|
file:
|
|
path: /tmp/UniFi.unix.zip
|
|
state: absent
|
|
when: unifi_version is version(unifi_current_version, ">") or unifi_current_version is version('0.0.0', "=")
|
|
become: True
|
|
become_user: "{{ unifi_user }}"
|
|
|
|
- block:
|
|
- name: Remove data folder from new version
|
|
file:
|
|
path: "{{ unifi_base_dir }}/{{ unifi_version }}//UniFi/data"
|
|
state: absent
|
|
become: True
|
|
become_user: "{{ unifi_user }}"
|
|
|
|
- name: Stop service while restore process
|
|
systemd:
|
|
state: stopped
|
|
enabled: yes
|
|
name: unifi
|
|
become: True
|
|
become_user: root
|
|
|
|
- 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 }}"
|
|
|
|
- name: Start service after restore process
|
|
systemd:
|
|
state: started
|
|
enabled: yes
|
|
name: unifi
|
|
become: True
|
|
become_user: root
|
|
when:
|
|
- unifi_version is version(unifi_current_version, ">")
|
|
- unifi_restore_after_upgrade
|
|
|
|
- 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 }}"
|
|
|
|
- name: Create systemd unit files
|
|
template:
|
|
src: "etc/systemd/system/unifi.service.j2"
|
|
dest: "/etc/systemd/system/unifi.service"
|
|
mode: 0644
|
|
notify: __unifi_restart
|
|
become: True
|
|
become_user: root
|