# Mirror scripts that use rsync - name: Create rsync log output directory file: path: /var/log/rsync-mirrors state: directory owner: root group: root mode: '0755' - name: Create common function dir file: path: /usr/share/mirror-update state: directory owner: root group: root mode: '0755' - name: Copy in common functions copy: src: 'functions.sh' dest: '/usr/share/mirror-update' owner: root group: root mode: '0644' - name: Set update script names set_fact: rsync_update_scripts: - centos - epel - fedora - opensuse - yum-puppetlabs - name: Copy keytab files in place shell: 'echo "{{ lookup("vars", "mirror_update_keytab_" + item) }}" | base64 -d > /etc/{{ item }}.keytab' args: creates: '/etc/{{ item }}.keytab' loop: '{{ rsync_update_scripts }}' no_log: True - name: Ensure keytab permissions file: path: '/etc/{{ item }}.keytab' owner: root group: root mode: '0400' loop: '{{ rsync_update_scripts }}' - name: Copy rsync mirror scripts in place copy: src: '{{ item }}-mirror-update' dest: '/usr/local/bin/{{ item }}-mirror-update' mode: '0755' loop: '{{ rsync_update_scripts }}' - name: Set cron flag to enable reporting stats cron: name: UNDER_CRON env: yes job: '1' - name: Install update cron jobs cron: name: '{{ item }} mirror sync' state: present job: 'flock -n /var/run/{{ item }}-mirror.lock {{ item }}-mirror-update mirror.{{ item }} >> /var/log/rsync-mirrors/{{ item }}.log 2>&1' hour: '*/2' minute: '{{ 45 | random(seed=item) }}' loop: '{{ rsync_update_scripts }}' - name: Install logrotate rules include_role: name: logrotate vars: logrotate_file_name: '/var/log/rsync-mirrors/{{ item }}.log' logrotate_frequency: 'weekly' loop: '{{ rsync_update_scripts }}'