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,19 +45,22 @@
|
|||||||
dest: "{{ unifi_base_dir }}/{{ unifi_version }}"
|
dest: "{{ unifi_base_dir }}/{{ unifi_version }}"
|
||||||
remote_src: yes
|
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
|
- name: Cleanup
|
||||||
file:
|
file:
|
||||||
path: /tmp/UniFi.unix.zip
|
path: /tmp/UniFi.unix.zip
|
||||||
state: absent
|
state: absent
|
||||||
become: True
|
become: True
|
||||||
become_user: "{{ unifi_user }}"
|
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:
|
- block:
|
||||||
- name: Create systemd unit files
|
- name: Create systemd unit files
|
||||||
@ -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