--- - name: Ensure folder "tmp" exists on this role file: path: "{{ role_path }}/tmp" state: directory delegate_to: localhost become: no - name: Fetch the file from the primary to manager node fetch: src: "{{ item }}" dest: "{{ role_path }}/tmp/" flat: yes when: ansible_default_ipv4.address == GLOBAL_PRIMARY_IP loop: "{{ files_to_synchronize }}" - name: Copy the file from manager node to secondary copy: src: "{{ role_path }}/tmp/{{ item | basename }}" dest: "{{ item }}" when: ansible_default_ipv4.address in GLOBAL_NODE_IPS_LIST loop: "{{ files_to_synchronize }}" - name: Remove folder "tmp" file: path: "{{ role_path }}/tmp/" state: absent delegate_to: localhost become: no