~xenrox/ansible

ref: 85bb5f61932c4851d513bb56486460511c316db6 ansible/roles/borg/tasks/main.yml -rw-r--r-- 2.7 KiB
85bb5f61Thorben Günther vaultwarden: Config update 2 months ago
                                                                                
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
108
109
110
111
112
113
114
115
116
117
118
119
---
- name: Install
  community.general.pacman:
    name: borg
    state: present

- name: Create SSH key directory
  ansible.builtin.file:
    path: /root/.ssh
    state: directory
    owner: root
    group: root
    mode: 0700

- name: Install SSH key
  ansible.builtin.copy:
    src: /home/xenrox/decrypted/ssh/{{ inventory_hostname }}.priv
    dest: /root/.ssh/id_rsa
    owner: root
    group: root
    mode: 0600

- name: Create secrets path
  ansible.builtin.file:
    path: /etc/.secrets
    state: directory
    owner: root
    group: root
    mode: 0700

- name: Install borg passphrase
  ansible.builtin.copy:
    src: /home/xenrox/decrypted/borg/{{ inventory_hostname }}.pass
    dest: /etc/.secrets/borg.pass
    owner: root
    group: root
    mode: 0600

- name: Create borg key path
  ansible.builtin.file:
    path: /root/.config/borg/keys
    state: directory
    owner: root
    group: root
    mode: 0700

- name: Install borg key
  ansible.builtin.copy:
    src: /home/xenrox/decrypted/borg/{{ inventory_hostname }}.key
    dest: /root/.config/borg/keys/borg.key
    owner: root
    group: root
    mode: 0600

- name: Install backup service
  ansible.builtin.copy:
    src: "{{ item }}"
    dest: "/etc/systemd/system/{{ item }}"
    owner: root
    group: root
    mode: 0644
  with_items:
    - borg-backup.service
    - borg-backup.timer

- name: Start and enable borg timer
  ansible.builtin.systemd:
    name: borg-backup.timer
    enabled: true
    state: started
    daemon_reload: true

- name: Get installed packages
  ansible.builtin.package_facts:
    manager: pacman

- name: Install borg backup script
  ansible.builtin.template:
    src: borg-backup.sh.j2
    dest: /usr/local/bin/borg-backup.sh
    owner: root
    group: root
    mode: 0755

- name: Install mailcow backup script
  ansible.builtin.copy:
    src: backup-mailcow.sh
    dest: /usr/local/bin/backup-mailcow.sh
    owner: root
    group: root
    mode: 0755
  when: inventory_hostname == "xenrox.net"

- name: Install postgresql backup script
  ansible.builtin.copy:
    src: backup-postgresql.sh
    dest: /usr/local/bin/backup-postgresql.sh
    owner: root
    group: root
    mode: 0755
  when: "'postgresql' in ansible_facts.packages"

- name: Install sqlite backup script
  ansible.builtin.template:
    src: backup-sqlite.sh.j2
    dest: /usr/local/bin/backup-sqlite.sh
    owner: root
    group: root
    mode: 0755
  when: "'sqlite' in ansible_facts.packages"

- name: Install docker backup script
  ansible.builtin.template:
    src: backup-docker.sh.j2
    dest: /usr/local/bin/backup-docker.sh
    owner: root
    group: root
    mode: 0755
  when: docker_services is defined and docker_services is iterable