EvoBSD/roles/evobackup/tasks/main.yml

78 lines
1.9 KiB
YAML

# yamllint disable rule:line-length
---
# Info : old zzz_evobackup used sh, and since "sh" match "bash", we keep "sh" for regex commands
- name: "Copy zzz_evobackup script"
ansible.builtin.copy:
src: zzz_evobackup
dest: /usr/share/scripts/zzz_evobackup
owner: root
group: wheel
mode: "0755"
force: false
tags:
- evobackup
- name: "Copy update-evobackup-canary script"
ansible.builtin.copy:
src: 000-update-evobackup-canary
dest: /usr/share/scripts/000-update-evobackup-canary
owner: root
group: wheel
mode: "0755"
force: true
tags:
- evobackup
- name: "Fetch daily.local content"
ansible.builtin.command: 'grep "sh /usr/share/scripts/zzz_evobackup" /etc/daily.local'
check_mode: false
register: daily_local_content
failed_when: false
changed_when: false
tags:
- evobackup
- name: "Add evobackup cron (disabled)"
ansible.builtin.lineinfile:
path: /etc/daily.local
line: '#bash /usr/share/scripts/zzz_evobackup'
owner: root
mode: "0600"
create: true
when:
- not (daily_local_content.stdout | regex_search('sh /usr/share/scripts/zzz_evobackup'))
tags:
- evobackup
- name: "Add evobackup cron - next_part"
ansible.builtin.lineinfile:
path: /etc/daily.local
line: 'next_part "EvoBackup output:"'
insertbefore: 'sh /usr/share/scripts/zzz_evobackup'
owner: root
mode: "0600"
create: true
tags:
- evobackup
- name: "Add canary cron"
ansible.builtin.lineinfile:
path: /etc/daily.local
line: 'sh /usr/share/scripts/000-update-evobackup-canary'
insertafter: 'next_part "EvoBackup output:"'
owner: root
mode: "0600"
create: true
tags:
- evobackup
- name: "Delete legacy evobackup root crontab"
ansible.builtin.lineinfile:
path: /var/cron/tabs/root
regexp: '/usr/share/scripts/zzz_evobackup'
validate: /usr/bin/crontab %s
state: absent
tags:
- evobackup