Files
ansible/roles/borg_client/tasks/main.yml
2024-07-05 11:53:33 +02:00

31 lines
811 B
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
- 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. Dont forget to init with: \nborg init --encryption=repokey-blake2 backup@{{ hostvars[groups['borg_server'][0]]['ansible_fqdn'] }}:home"