diff --git a/tasks/centos.yml b/tasks/centos.yml new file mode 100644 index 0000000000000000000000000000000000000000..7cb8f208d52718f1b002c044f5b1084712b80ccc --- /dev/null +++ b/tasks/centos.yml @@ -0,0 +1,32 @@ +--- +# tasks file for rsync-server +- name: rsyncd | install rsync + yum: + pkg: rsync + state: present + +- name: rsyncd | create log directory + file: + path: /var/log/rsyncd + state: directory + +- name: create share path + file: + path: "{{ item.path }}" + state: directory + owner: nobody + mode: 0775 + with_items: + - "{{ rsync_server_shares }}" + +- name: rsyncd | configure shares + template: + dest: /etc/rsyncd.conf + src: etc-rsyncd-conf.j2 +# No need to reload, file is re-read on each client connection. + +- name: rsyncd | start and enable service + service: + name: rsyncd + enabled: true + state: started diff --git a/tasks/main.yml b/tasks/main.yml index a5fd1dc93d44154f93f172b4c573f4bf0bb31f2d..58fc87dd243ebaec70a029311c3033937f629404 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,52 +1,6 @@ --- -# tasks file for rsync-server -- name: rsyncd | install rsync - apt: - pkg: - - rsync - - net-tools - state: present - update-cache: true - when: ansible_distribution == 'Ubuntu' - -- name: rsyncd | install rsync - yum: - pkg: - - rsync - - net-tools - state: present +- include_tasks: centos.yml when: ansible_distribution == 'CentOS' -- name: rsyncd | create log directory - file: - path: /var/log/rsyncd - state: directory - -- name: create share path - file: - path: "{{ item.path }}" - state: directory - owner: nobody - mode: 0775 - with_items: - - "{{ rsync_server_shares }}" - -- name: rsyncd | configure shares - template: - dest: /etc/rsyncd.conf - src: etc-rsyncd-conf.j2 -# No need to reload, file is re-read on each client connection. - -- name: rsyncd | start and enable service - service: - name: rsync - enabled: true - state: started +- include_tasks: ubuntu.yml when: ansible_distribution == 'Ubuntu' - -- name: rsyncd | start and enable service - service: - name: rsyncd - enabled: true - state: started - when: ansible_distribution == 'CentOS' diff --git a/tasks/ubuntu.yml b/tasks/ubuntu.yml new file mode 100644 index 0000000000000000000000000000000000000000..873ac60f7af1f894a6226688630e384dc8e8d02b --- /dev/null +++ b/tasks/ubuntu.yml @@ -0,0 +1,35 @@ +--- +# tasks file for rsync-server +- name: rsync | install rsync + apt: + pkg: + - rsync + - net-tools + state: present + update-cache: true + +- name: rsync | create log directory + file: + path: /var/log/rsyncd + state: directory + +- name: create share path + file: + path: "{{ item.path }}" + state: directory + owner: nobody + mode: 0775 + with_items: + - "{{ rsync_server_shares }}" + +- name: rsync | configure shares + template: + dest: /etc/rsyncd.conf + src: etc-rsyncd-conf.j2 +# No need to reload, file is re-read on each client connection. + +- name: rsync | start and enable service + service: + name: rsync + enabled: true + state: started diff --git a/templates/etc-rsyncd-conf.j2 b/templates/etc-rsyncd-conf.j2 index ad6868d5640a97afff3aad356f5a7b909a48c497..434f3ea5dff604446f2e4b80b96fb33956f700c0 100644 --- a/templates/etc-rsyncd-conf.j2 +++ b/templates/etc-rsyncd-conf.j2 @@ -33,13 +33,13 @@ dont compress = {{ rsync_server_exclude_compress }} munge symlinks = {{ rsync_server_symlinks }} list = {{ rsync_server_list }} read only = {{ rsync_server_readonly }} -timeout = {{ rsync_server_timeout | default('0') }} +timeout = {{ rsync_server_timeout | default('0') }} max connections = {{ rsync_server_max_connections | default('0') }} {% for share in rsync_server_shares %} [{{ share.name }}] -path = {{ share.path }} +path = /{{ share.path }} hosts allow = {{ share.hosts_allow | default('*') }} {% if share.options is defined %} {% if share.options.includes is defined %}