- hosts: all become: yes become_method: sudo gather_facts: no tasks: - name: Creates directory file: path: "{{ RPATH }}/roxy-wi-configs-backup/configs" state: directory owner: "{{ ansible_user }}" when: not DELJOB - hosts: localhost become: yes become_method: sudo gather_facts: no tasks: - name: Creates backup jobs cron: name: "Roxy-WI Backup configs for server {{ SERVER }} {{ item }}" special_time: "{{ TIME }}" job: "rsync -arv {{ TYPE }} /var/lib/roxy-wi/configs/{{ item }}/{{ SERVER }}* {{ ansible_user }}@{{ HOST }}:{{ RPATH }}/roxy-wi-configs-backup/configs/{{ item }} -e 'ssh -i {{ KEY }} -o StrictHostKeyChecking=no' --log-file=/var/www/haproxy-wi/log/backup.log" when: not DELJOB with_items: - kp_config - hap_config - nginx_config - apache_config - name: Removes backup jobs cron: name: "Roxy-WI Backup configs for server {{ SERVER }} {{ item }}" state: absent when: DELJOB with_items: - kp_config - hap_config - nginx_config - apache_config