rsync_backup: Initial version of role
This commit is contained in:
parent
46c41d2d77
commit
3efe44b50b
3 changed files with 206 additions and 0 deletions
52
roles/rsync_backup/tasks/main.yml
Normal file
52
roles/rsync_backup/tasks/main.yml
Normal 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"
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue