This playbook installs rsync and deploys a minimal daemon configuration.
- name: Configure rsync host
hosts: rsync
become: true
tasks:
- name: Install rsync
ansible.builtin.package:
name: rsync
state: present
- name: Create rsync backup directory
ansible.builtin.file:
path: /srv/rsync/backup
state: directory
mode: "0750"
- name: Deploy rsync daemon config
ansible.builtin.copy:
dest: /etc/rsyncd.conf
mode: "0644"
content: |
uid = nobody
gid = nogroup
use chroot = yes
max connections = 4
[backup]
path = /srv/rsync/backup
read only = false
hosts allow = 10.0.0.0/24
- name: Enable and start rsync service where available
ansible.builtin.service:
name: rsync
state: started
enabled: true
failed_when: false
- name: Validate rsync version
ansible.builtin.command: rsync --version
register: rsync_version
changed_when: false
- name: Show rsync version
ansible.builtin.debug:
var: rsync_version.stdout_lines
--delete behavior with --dry-run first.