From fc16b6d9138a8b38b2162154025287c39dbd31e1 Mon Sep 17 00:00:00 2001 From: vincent Date: Sun, 14 Apr 2019 11:45:18 +0200 Subject: [PATCH] configure RsyncD --- defaults/main.yml | 5 +++++ handlers/main.yml | 4 ++++ tasks/main.yml | 15 +++++++++++++++ templates/rsyncd.conf.j2 | 14 ++++++++++++++ 4 files changed, 38 insertions(+) create mode 100644 templates/rsyncd.conf.j2 diff --git a/defaults/main.yml b/defaults/main.yml index e69de29..3415430 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -0,0 +1,5 @@ +rsynclocations: + - name: backup nas + location: /mnt/backup + readonly: "no" +rsynchostalloawed: none \ No newline at end of file diff --git a/handlers/main.yml b/handlers/main.yml index e69de29..4ccb144 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -0,0 +1,4 @@ + +- name: restart rsync + service: name=rsyncd state=restarted + become: yes \ No newline at end of file diff --git a/tasks/main.yml b/tasks/main.yml index e69de29..fd9f424 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -0,0 +1,15 @@ + + + +- name: rsyncd_conf + action: template src=rsyncd.conf.j2 dest=/etc/rsyncd.conf + notify: restart rsync + become: yes + + +- name: enable_rsyncd + service: + name: rsyncd # required. Name of the service. + enabled: yes # not required. Whether the service should start on boot. B(At least one of state and enabled are required.) + state: started # not required. choices: reloaded;restarted;started;stopped. C(started)/C(stopped) are idempotent actions that will not run commands unless necessary. C(restarted) will always bounce the service. C(reloaded) will always reload. B(At least one of state and enabled are required.) Note that reloaded will start the service if it is not already started, even if your chosen init system wouldn't normally. + become: yes diff --git a/templates/rsyncd.conf.j2 b/templates/rsyncd.conf.j2 new file mode 100644 index 0000000..4196776 --- /dev/null +++ b/templates/rsyncd.conf.j2 @@ -0,0 +1,14 @@ +uid = root +gid = root +use chroot = no +max connections = 4 +syslog facility = local5 +pid file = /run/rsyncd.pid +hosts allow = {{ rsynchostalloawed }} + +{% for item in rsynclocations %} +[{{ item.name }}] +path = {{ item.location }} +comment = {{ item.name }} +read only = {{ item.readonly }} +{% endfor %} \ No newline at end of file