fix idempotency with custom fact

This commit is contained in:
Robert Kaussow 2018-07-08 23:35:10 +02:00
parent f139720a70
commit a6ec36a870
2 changed files with 21 additions and 7 deletions

View File

@ -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

View File

@ -0,0 +1,4 @@
{
"comment" : "{{ ansible_managed }}"
"version" : "{{ unifi_version }}"
}