31 lines
811 B
YAML
31 lines
811 B
YAML
---
|
||
|
||
- name: Create SSH key
|
||
community.crypto.openssh_keypair:
|
||
path: ~/.ssh/id_rsa
|
||
|
||
- name: Get SSH pub key
|
||
ansible.builtin.command:
|
||
cmd: cat ~/.ssh/id_rsa.pub
|
||
changed_when: true
|
||
register: ssh_keys
|
||
|
||
- name: Put backup script
|
||
ansible.builtin.template:
|
||
src: borgbackup.sh.j2
|
||
dest: /usr/local/bin/borgbackup.sh
|
||
owner: root
|
||
group: root
|
||
mode: '0750'
|
||
|
||
- name: Cron the backup script
|
||
ansible.builtin.cron:
|
||
name: "borg backup script"
|
||
hour: "{{ borg_backup_hour }}"
|
||
minute: "{{ borg_backup_minute }}"
|
||
job: /usr/local/bin/borgbackup.sh
|
||
|
||
- name: Warns about borg init
|
||
ansible.builtin.debug:
|
||
msg: "Borg has been installed. Don’t forget to init with: \nborg init --encryption=repokey-blake2 backup@{{ hostvars[groups['borg_server'][0]]['ansible_fqdn'] }}:home"
|