- name: Remove old ssl certs
  file:
    path: "{{ item }}"
    state: absent
  with_items:
    - /etc/nginx/ssl/cert.pem
    - /etc/nginx/ssl/privkey.pem
    - /etc/ssl/certs/dhparam.pem

- name: Remove old hosts file
  file:
    path: /root/hosts.txt
    state: absent

- name: Remove install.php
  file:
    path: "{{ keitaro_root }}/install.php"
    state: absent

- name: Remove all cron tasks of nginx user
  shell: "crontab -r -u {{ nginx_user }} || true"

- name: Remove old mariadb logrotate config
  file:
    path: /etc/logrotate.d/mariadb
    state: absent

- name: Remove old nginx files
  shell: "rm -f /etc/nginx/conf.d/keitaro-*.inc /etc/nginx/conf.d/*.inc /etc/nginx/conf.d/keitaro/*.local.inc"

- name: Remove old backup nginx host files
  shell: "rm -f /etc/nginx/conf.d/*.conf.20*"

- name: Remove old roadrunner files
  file:
    path: /etc/keitaro/roadrunner.yml
    state: absent

- name: Remove old ssl certs
  file:
    path: "{{ item }}"
    state: absent
  with_items:
    - /etc/nginx/ssl/cert.pem
    - /etc/nginx/ssl/privkey.pem
    - /etc/ssl/certs/dhparam.pem

- name: Remove old hosts file
  file:
    path: /root/hosts.txt
    state: absent

- name: Remove install.php
  file:
    path: "{{ keitaro_root }}/install.php"
    state: absent

- name: Remove all cron tasks of nginx user
  shell: "crontab -r -u {{ nginx_user }} || true"

- name: Remove old root cron.php task
  shell: 'sed -i /cron.php/d /var/spool/cron/root'

- name: Remove old mariadb logrotate config
  file:
    path: /etc/logrotate.d/mariadb
    state: absent

- name: Remove old nginx files
  shell: "rm -f /etc/nginx/conf.d/keitaro-*.inc /etc/nginx/conf.d/*.inc /etc/nginx/conf.d/keitaro/*.local.inc"

- name: Remove old backup nginx host files
  shell: "rm -f /etc/nginx/conf.d/*.conf.20*"

- name: Remove old roadrunner files
  file:
    path: /etc/keitaro/roadrunner.yml
    state: absent

Remove old root cron.php task on upgrade
Remove old root cron.php task on upgrade
