Add backupclient

This commit is contained in:
root (arriane)
2017-10-31 09:11:30 +01:00
parent e4eb74ad69
commit e086fa9c04
11 changed files with 77 additions and 3 deletions

View File

@@ -1,3 +1,7 @@
--- ---
common_aliases: common_aliases:
- "root: bofh@fet.at" - "root: bofh@fet.at"
common_hostname: False
common_apt: False
common_rsyslog: False
common_resolvconf: False

7
group_vars/backup Normal file
View File

@@ -0,0 +1,7 @@
backup:
repositories:
- path: "/srv/rep1"
name: "Repository1"
- path: "/srv/rep2"
name: "Repository2"

1
host_vars/backup01 Normal file
View File

@@ -0,0 +1 @@
inventory_hostname_short: backup01

View File

@@ -1,2 +1,5 @@
[backup] [backup]
10.0.3.113 10.0.3.113
[backupclient]
10.0.3.161

View File

@@ -1,3 +1,21 @@
--- ---
- name: install borg - name: install borg
apt: name="borgbackup" state=present apt: name="borgbackup" state=present
- name: create repositories
file:
path: "{{item.path}}"
state: directory
with_items: "{{backup.repositories}}"
- name: init borg repositories
command: "borg init {{item.path}} --encryption=none"
args:
creates: "{{item.path}}/README"
with_items: "{{backup.repositories}}"
- name: create READMES
template:
src=borg_README.j2
dest="{{item.path}}/README"
with_items: "{{backup.repositories}}"

View File

@@ -0,0 +1,2 @@
This is a generate FET borg repository.
Name: {{item.name}}

View File

@@ -0,0 +1,2 @@
---
backup_borg: True

View 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

View File

@@ -0,0 +1,4 @@
---
- include: borg.yml
when: backup_borg
tags: ['backup', 'borg']

View File

@@ -1 +1 @@
10.0.3.113 10.0.3.161

View File

@@ -5,3 +5,10 @@
roles: roles:
- common - common
- backup - backup
- hosts: backupclient
user: root
become: False
roles:
- common
- backupclient