---
- name: install REAR package
  become: yes
  package:
    name: rear
    # do not use "latest" here. This will update packages, whenever you
    # run playbooks.
    state: present
  notify: "create REAR ISO"

- name: create site.conf
  become: yes
  file:
    path: /etc/rear/site.conf
    state: touch
    mode: '0644'
    owner: root

- name: add unprotected private key
  become: yes
  # Do not create new ssh-keys for the recovery-system:
  lineinfile:
    path: /etc/rear/site.conf
    line: SSH_UNPROTECTED_PRIVATE_KEYS=yes
  notify: "create REAR ISO"

- name: OUTPUT ISO
  become: yes
  lineinfile:
    path: /etc/rear/site.conf
    line: OUTPUT=ISO
  notify: "create REAR ISO"

- name: Adjust Backup mode
  become: yes
  lineinfile:
    path: /etc/rear/site.conf
    regexp: '^BACKUP='
    line: BACKUP=REQUESTRESTORE
  notify: "create REAR ISO"

# TODO is there anything else in this file?
# might want a plain file/template instead
- name: add REAR cronjob
  become: yes
  lineinfile:
    path: /etc/cron.d/perfact-rear
    create: yes
    mode: '0644'
    owner: root
    line: 30 1 * * * root /usr/sbin/rear checklayout || /usr/sbin/rear mkrescue
