---
#
# This role sets up rsyncd on a server 
#

- name: install rnecessary packages
  yum: state=present name={{item}}
  with_items:
  - rsync
  - xinetd
  - libsemanage-python
  tags:
  - packages

- name: rsyncd.conf file
  copy: src={{ item }} dest=/etc/rsyncd.conf mode=644
  with_first_found:
    - "{{ rsyncd_conf }}"
    - rsyncd.conf.{{ ansible_fqdn }}
    - rsyncd.conf.{{ host_group }}
    - rsyncd.conf.{{ rsync_group }}
    - rsyncd.conf.default
  notify:
  - restart xinetd
  tags:
  - config

- name: xinetd rsync file
  copy: src={{ item }} dest=/etc/xinetd.d/rsync mode=644
  with_first_found:
    - "{{ rsync }}"
    - rsync.{{ ansible_fqdn }}
    - rsync.{{ host_group }}
    - rsync.{{ rsync_group }}
    - rsync.default
  notify:
  - restart xinetd
  tags:
  - config

- name: make sure xinetd is started
  service: name=xinetd state=started
  tags:
  - services

- name: set sebooleans so rsync can read dirs
  action: seboolean name=rsync_export_all_ro
                    state=true
                    persistent=true

