blob: c77202cc73b3da4c4beb6f7746802c14f484b951 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
---
- name: Setup - Configure SSH keys for all hosts
hosts:
- borg-client
- borg-client-2
- borg-client-multi
vars:
borg_server_host: borg-server
pre_tasks:
# This would usually be set by the user globally on their ansible
# repository and can be a security risk to do automatically. We will
# however set the variable here in the pre_tasks since it is for testing.
- name: Set borg server openssh key variable
become: true
block:
- name: Start ssh
ansible.builtin.systemd:
name: sshd
state: started
become: true
delegate_to: "{{ borg_server_host }}"
- name: Fetch ssh_key
ansible.builtin.command: >-
ssh-keyscan -t rsa {{ borg_server_host }} | sed "s/^[^ ]* //"
register: borg_server_ssh_keyscan
changed_when: false
- name: Set ssh_key
ansible.builtin.set_fact:
borg_server_host_ssh_key: >-
{{ borg_server_ssh_keyscan.stdout
| split(" ")
| reject("search", borg_server_host)
| join(" ") }}
- name: Converge - Default borg-client
hosts: borg-client
roles:
- role: kliwniloc.borgbackup
vars:
borg_server_host: borg-server
borg_server_user_home: /opt/borg
borg_decryption_keys_yaml_path: "{{ playbook_dir }}/decryption_keys.yml"
borg_included_dirs:
- /etc
- /home
borg_excluded_dirs:
- /opt
- /var
- /reee reeee
- name: Converge - borg-client-2
hosts: borg-client-2
roles:
- role: kliwniloc.borgbackup
vars:
borg_server_host: borg-server
borg_server_user_home: /opt/borg
borg_decryption_keys_yaml_path: "{{ playbook_dir }}/decryption_keys.yml"
borg_backup_service_successful_exit_status:
- 1
- TEMPFAIL
borg_compression: lz4
borg_systemd_oncalendar: "*-*-* 03:00:00"
borg_included_dirs:
- /etc
- /home
borg_excluded_dirs:
- /opt
- /var
- /reee reeee
- name: Converge - Multi-instance backup (same host, different repos)
hosts: borg-client-multi
serial: 1
vars:
borg_server_host: borg-server
borg_server_user_home: /opt/borg
borg_decryption_keys_yaml_path: "{{ playbook_dir }}/decryption_keys.yml"
roles:
- role: kliwniloc.borgbackup
vars:
borg_repo_name: configs
borg_backup_argument: configs
borg_compression: zstd
borg_included_dirs:
- /etc
borg_excluded_dirs: []
borg_systemd_oncalendar: "*-*-* 02:00:00"
- role: kliwniloc.borgbackup
vars:
borg_repo_name: home-data
borg_backup_argument: home-data
borg_compression: lz4
borg_included_dirs:
- /home
borg_excluded_dirs:
- /home/*/.cache
borg_systemd_oncalendar: "*-*-* 04:00:00"
|