---

- name: Ensure archives directory exists.
  become_user: ubuntu
  become: True
  file:
    path: archives
    state: directory

- name: Create archives
  command: tar -cjf archives/{{ item.name }} {{ item.path }}
  with_items: "{{ archives }}"
  changed_when: False    # Archives will always be created and thus idempotency will fail.

- name: Upload archives
  synchronize:
    mode: pull
    src: archives/
    dest: data/{{ sp_hostname }}/

---

- name: Ensure archives directory exists.
  become_user: ubuntu
  become: True
  file:
    path: archives
    state: directory

- name: Create archives
  command: tar -cjf archives/{{ item.name }} {{ item.path }}
  with_items: "{{ archives }}"
  changed_when: False    # Archives will always be created and thus idempotency will fail.

- name: Upload archives
  synchronize:
    mode: pull
    src: archives/
    dest: data/{{ sp_hostname }}/
  changed_when: False    # Archives will always be synced and thus idempotency will fail.

Fix idemptency of the syncing task
Fix idemptency of the syncing task

Sync with the host will always happen and thus the state will always be
'changed'. To solve this, the 'changed_when: False' has been added.
