diff --git a/tasks/install.yml b/tasks/install.yml index 7bfdd61..4548ea0 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -29,6 +29,7 @@ with_items: - "{{ unifi_base_dir }}" - "{{ unifi_base_dir }}/{{ unifi_version }}" + - /etc/ansible/facts.d become: True - block: @@ -44,19 +45,22 @@ dest: "{{ unifi_base_dir }}/{{ unifi_version }}" remote_src: yes - - name: Create symlink for latest version - file: - src: "{{ unifi_base_dir }}/{{ unifi_version }}" - dest: "{{ unifi_base_dir }}/latest" - state: link - notify: __unifi_restart - - name: Cleanup file: path: /tmp/UniFi.unix.zip state: absent become: True become_user: "{{ unifi_user }}" + 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 }}" - block: - name: Create systemd unit files @@ -73,4 +77,10 @@ daemon_reload: yes enabled: yes name: unifi + + - 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, ">") become: True diff --git a/templates/etc/ansible/fact.d/unifi.json.j2 b/templates/etc/ansible/fact.d/unifi.json.j2 new file mode 100644 index 0000000..2b0dcc9 --- /dev/null +++ b/templates/etc/ansible/fact.d/unifi.json.j2 @@ -0,0 +1,4 @@ +{ + "comment" : "{{ ansible_managed }}" + "version" : "{{ unifi_version }}" +}