- name: install rsync
  apt:
    name: rsync
    state: present
    update_cache: yes

- name: start rsync
  systemd:
    name: rsync
    state: started

- name: copy rsync configs
  copy:
    src: "{{ role_path }}/templates/{{ item.src }}"
    dest: /etc/{{ item.dest }}
    owner: root
    group: root
    mode: "0644"
  loop:
    - { src: "rsyncd.conf", dest: "rsyncd.conf" } 
    - { src: "rsyncd-filter.conf", dest: "rsyncd-filter.conf" } 

- name: restart and enable rsync
  systemd:
    name: rsync
    state: restarted
    enabled: true