Add backupclient
This commit is contained in:
2
roles/backupclient/defaults/main.yml
Normal file
2
roles/backupclient/defaults/main.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
backup_borg: True
|
||||
26
roles/backupclient/tasks/borg.yml
Normal file
26
roles/backupclient/tasks/borg.yml
Normal file
@@ -0,0 +1,26 @@
|
||||
---
|
||||
- name: install borg
|
||||
apt: name="borgbackup" state=present
|
||||
|
||||
- name: create backup user
|
||||
user:
|
||||
name: borg_backup
|
||||
comment: "BackupUser für BORG Backup"
|
||||
group: root
|
||||
generate_ssh_key: yes
|
||||
ssh_key_bits: 4096
|
||||
ssh_key_file: .ssh/id_rsa
|
||||
|
||||
- name: fetch pubickey
|
||||
shell: "cat /home/borg_backup/.ssh/id_rsa.pub"
|
||||
register: id_rsa_pub
|
||||
|
||||
- name: Add authorized key to borg backup servers
|
||||
authorized_key:
|
||||
user: "root"
|
||||
key: "{{id_rsa_pub.stdout}}"
|
||||
key_options: 'command="borg serve --restrict-to-path /srv/rep1"'
|
||||
delegate_to: "{{item}}"
|
||||
with_items: "{{groups['backup']}}"
|
||||
when: id_rsa_pub.stdout is defined
|
||||
|
||||
4
roles/backupclient/tasks/main.yml
Normal file
4
roles/backupclient/tasks/main.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
---
|
||||
- include: borg.yml
|
||||
when: backup_borg
|
||||
tags: ['backup', 'borg']
|
||||
Reference in New Issue
Block a user