---

- name: (apt-gateway.yml) Install gateway related packages
  apt:
    name: "{{ apt_gateway_host_pkgs }}"
    state: "{{ apt_install_state }}"


- name: (apt-gateway.yml) Check if file '/etc/logrotate.d/speedtest' exists
  stat:
    path: /etc/logrotate.d/speedtest
  register: logrotate_speedtest_exists


- name: (apt-gateway.yml) Ensure file /etc/logrotate.d/speedtest exists
  copy:
    src: "{{ role_path + '/files/etc/logrotate.d/speedtest' }}"
    dest: /etc/logrotate.d/speedtest
    owner: root
    group: root
    mode: 0644
  when:  
    - logrotate_speedtest_exists.stat.exists == False


- name: (apt-gateway.yml) Set crontab entry for nightly speedtests
  cron:
    name: 'Speedtest'
    minute: 13
    hour: 0-8
    job: '/root/bin/admin-stuff/speedtest.sh'
