fix idempotency with custom fact
This commit is contained in:
parent
f139720a70
commit
a6ec36a870
@ -29,6 +29,7 @@
|
|||||||
with_items:
|
with_items:
|
||||||
- "{{ unifi_base_dir }}"
|
- "{{ unifi_base_dir }}"
|
||||||
- "{{ unifi_base_dir }}/{{ unifi_version }}"
|
- "{{ unifi_base_dir }}/{{ unifi_version }}"
|
||||||
|
- /etc/ansible/facts.d
|
||||||
become: True
|
become: True
|
||||||
|
|
||||||
- block:
|
- block:
|
||||||
@ -44,17 +45,20 @@
|
|||||||
dest: "{{ unifi_base_dir }}/{{ unifi_version }}"
|
dest: "{{ unifi_base_dir }}/{{ unifi_version }}"
|
||||||
remote_src: yes
|
remote_src: yes
|
||||||
|
|
||||||
- name: Create symlink for latest version
|
- 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:
|
file:
|
||||||
src: "{{ unifi_base_dir }}/{{ unifi_version }}"
|
src: "{{ unifi_base_dir }}/{{ unifi_version }}"
|
||||||
dest: "{{ unifi_base_dir }}/latest"
|
dest: "{{ unifi_base_dir }}/latest"
|
||||||
state: link
|
state: link
|
||||||
notify: __unifi_restart
|
notify: __unifi_restart
|
||||||
|
|
||||||
- name: Cleanup
|
|
||||||
file:
|
|
||||||
path: /tmp/UniFi.unix.zip
|
|
||||||
state: absent
|
|
||||||
become: True
|
become: True
|
||||||
become_user: "{{ unifi_user }}"
|
become_user: "{{ unifi_user }}"
|
||||||
|
|
||||||
@ -73,4 +77,10 @@
|
|||||||
daemon_reload: yes
|
daemon_reload: yes
|
||||||
enabled: yes
|
enabled: yes
|
||||||
name: unifi
|
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
|
become: True
|
||||||
|
4
templates/etc/ansible/fact.d/unifi.json.j2
Normal file
4
templates/etc/ansible/fact.d/unifi.json.j2
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"comment" : "{{ ansible_managed }}"
|
||||||
|
"version" : "{{ unifi_version }}"
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user