rsync_backup: Initial version of role

This commit is contained in:
Timo Makinen 2024-12-17 22:32:25 +00:00
parent 46c41d2d77
commit 3efe44b50b
3 changed files with 206 additions and 0 deletions

View file

@ -0,0 +1,52 @@
---
- name: Copy backup script
ansible.builtin.copy:
dest: /usr/local/sbin/backup-daily
src: backup-daily.sh
mode: "0755"
owner: root
group: "{{ ansible_wheel }}"
- name: Create config directory
ansible.builtin.file:
path: /etc/rsync-backup
state: directory
mode: "0755"
owner: root
group: "{{ ansible_wheel }}"
- name: Create logdir
ansible.builtin.file:
path: /var/log/rsync-backup
state: directory
mode: "0700"
owner: root
group: "{{ ansible_wheel }}"
- name: Create ssh keys
ansible.builtin.command:
argv:
- ssh-keygen
- -t
- ed25519
- -C
- "root@{{ inventory_hostname }}"
- -N
- ""
- -f
- /etc/rsync-backup/id_ed25519
creates: /etc/rsync-backup/id_ed25519
- name: Fetch ssh public key
ansible.builtin.fetch:
src: /etc/rsync-backup/id_ed25519.pub
dest: ../files/ssh/rsync-backup.pub
flat: true
- name: Install cron job
ansible.builtin.cron:
name: daily rsync backup
job: /usr/local/sbin/backup-daily -a -p -r
hour: "00"
minute: "30"