aboutsummaryrefslogtreecommitdiff
path: root/ansible
diff options
context:
space:
mode:
Diffstat (limited to 'ansible')
-rw-r--r--ansible/borg.yml10
-rw-r--r--ansible/inventory18
-rw-r--r--ansible/roles/borg-client/defaults/main.yml1
-rw-r--r--ansible/roles/borg-client/handlers/main.yml10
-rw-r--r--ansible/roles/borg-client/tasks/borg-client.yml115
-rw-r--r--ansible/roles/borg-client/tasks/main.yml3
-rw-r--r--ansible/roles/borg-client/templates/bin/create-backup26
-rw-r--r--ansible/roles/borg-client/templates/bin/create-backup-send-email16
-rw-r--r--ansible/roles/borg-server/defaults/main.yml2
-rw-r--r--ansible/roles/borg-server/tasks/borg-server.yml30
-rw-r--r--ansible/roles/borg-server/tasks/main.yml26
11 files changed, 0 insertions, 257 deletions
diff --git a/ansible/borg.yml b/ansible/borg.yml
deleted file mode 100644
index 57ae3de..0000000
--- a/ansible/borg.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-# Add clients first so that their public key is available.
-- hosts:
- - borg_clients
- roles:
- - borg-client
-
-- hosts:
- - borg_servers
- roles:
- - borg-server
diff --git a/ansible/inventory b/ansible/inventory
index cfeeca4..81f00bf 100644
--- a/ansible/inventory
+++ b/ansible/inventory
@@ -119,24 +119,6 @@ all:
ansible_connection: lxc_ssh
ansible_ssh_extra_args: sz-test
- # Borg
- borg_servers:
- hosts:
- malabaricus:
- vars:
- borg_server__clients_ansible_group: borg_nas
- borg_nas:
- hosts:
- birgitte:
- conflatorio:
- arius:
- vars:
- borg_client__server: malabaricus.trygvis.io
-
- borg_clients:
- children:
- borg_nas:
-
wireguard_wg-net1:
hosts:
akili:
diff --git a/ansible/roles/borg-client/defaults/main.yml b/ansible/roles/borg-client/defaults/main.yml
deleted file mode 100644
index b450b4d..0000000
--- a/ansible/roles/borg-client/defaults/main.yml
+++ /dev/null
@@ -1 +0,0 @@
-ssh_key: /etc/borg/id_ed25519
diff --git a/ansible/roles/borg-client/handlers/main.yml b/ansible/roles/borg-client/handlers/main.yml
deleted file mode 100644
index 2b4b222..0000000
--- a/ansible/roles/borg-client/handlers/main.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-- name: systemctl daemon-reload
- become: yes
- systemd:
- daemon_reload: true
-
-- name: service start create-backup.timer
- become: yes
- service:
- name: create-backup.timer
- state: restarted
diff --git a/ansible/roles/borg-client/tasks/borg-client.yml b/ansible/roles/borg-client/tasks/borg-client.yml
deleted file mode 100644
index 92aba57..0000000
--- a/ansible/roles/borg-client/tasks/borg-client.yml
+++ /dev/null
@@ -1,115 +0,0 @@
----
-- name: packages
- tags: packages
- apt:
- name: "{{ items }}"
- install_recommends: no
- vars:
- items:
- - borgbackup
-
-- name: mkdir /etc/borg
- file:
- path: /etc/borg
- state: directory
- mode: u=rwx,go=
-
-- name: Generate SSH keys
- command: ssh-keygen -t ed25519 -N "" -f "{{ ssh_key }}" -C "for borg @ {{ ansible_hostname }}"
- args:
- creates: "{{ ssh_key }}"
- register: ssh_key_generated
-
-- when: ssh_key_generated.changed
- fetch:
- src: "{{ ssh_key }}.pub"
- dest: "files"
-
-- name: /etc/borg/env
- copy:
- dest: /etc/borg/env
- mode: u=r,go=
- content: |
- BORG_REPO="borg@{{ borg_client__server }}:{{ ansible_hostname }}"
- BORG_RSH="ssh -i {{ ssh_key}}"
-
-# "
-
-- name: /etc/borg/excludes
- when: borg_client__state == "absent"
- file:
- path: /etc/borg/excludes
- state: absent
-
-- name: /etc/borg/excludes
- when: borg_client__state == "present"
- copy:
- dest: /etc/borg/excludes
- content: |
- /proc
- /dev
- /sys
- /run
-
-- name: /etc/borg/patterns
- copy:
- dest: /etc/borg/patterns
- content: |
- P sh
- R /
- {% for item in borg_client__patterns %}
- {{ item }}
- {% endfor %}
-
-- name: /usr/local/bin/create-backup
- template:
- dest: "/usr/local/bin/{{ item }}"
- src: "bin/{{ item }}"
- mode: u=rwx,go=rx
- owner: root
- group: root
- with_items:
- - create-backup
- - create-backup-send-email
-
-- name: /etc/systemd/system/create-backup.service
- copy:
- dest: /etc/systemd/system/create-backup.service
- content: |
- [Unit]
- Description=Create backup
- # After=network-online.target
- # Wants=network-online.target
-
- [Service]
- Type=oneshot
- WorkingDirectory=/
- ExecStart=-/usr/local/bin/create-backup
- ExecStartPost=-/usr/local/bin/create-backup-send-email root@trygvis.io
- SuccessExitStatus=0 1
- notify:
- - systemctl daemon-reload
-
-- name: /etc/systemd/system/create-backup.timer
- copy:
- dest: /etc/systemd/system/create-backup.timer
- content: |
- [Unit]
- Description=Create backup timer
-
- [Timer]
- OnCalendar=05:24
-
- [Install]
- WantedBy=timers.target
- notify:
- - systemctl daemon-reload
- - service start create-backup.timer
-
-# TODO: remove
-- file:
- path: /etc/systemd/system/create-backup-send-email.service
- state: absent
- register: create_backup_send_email_service
- notify:
- - systemctl daemon-reload
diff --git a/ansible/roles/borg-client/tasks/main.yml b/ansible/roles/borg-client/tasks/main.yml
deleted file mode 100644
index 1afab33..0000000
--- a/ansible/roles/borg-client/tasks/main.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-- become: yes
- tags: borg-client
- import_tasks: borg-client.yml
diff --git a/ansible/roles/borg-client/templates/bin/create-backup b/ansible/roles/borg-client/templates/bin/create-backup
deleted file mode 100644
index 8d842ef..0000000
--- a/ansible/roles/borg-client/templates/bin/create-backup
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/bin/bash
-
-set -euo pipefail
-
-cd /
-
-. /etc/borg/env
-export BORG_REPO
-export BORG_RSH
-
-cmd=()
-cmd+=(borg create)
-cmd+=(--stats)
-#cmd+=(--progress)
-#cmd+=(--json)
-cmd+=(--exclude-from=/etc/borg/excludes)
-cmd+=(--patterns-from=/etc/borg/patterns)
-cmd+=(::'{hostname}-{now:%Y-%m-%dT%H:%M:%S}')
-
-echo BORG_RSH=$BORG_RSH
-echo BORG_REPO=$BORG_REPO
-
-set -x
-time "${cmd[@]}"
-
-borg info --last 1
diff --git a/ansible/roles/borg-client/templates/bin/create-backup-send-email b/ansible/roles/borg-client/templates/bin/create-backup-send-email
deleted file mode 100644
index 7665571..0000000
--- a/ansible/roles/borg-client/templates/bin/create-backup-send-email
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/bash
-
-set -euo pipefail
-
-cd /
-
-/usr/sbin/sendmail -t <<ERRMAIL
-To: $1
-From: systemd <root@$HOSTNAME>
-Subject: Backup @ $HOSTNAME
-Content-Transfer-Encoding: 8bit
-Content-Type: text/plain; charset=UTF-8
-
-$(systemctl status --full 2>&1)
-$(journalctl --since today --unit create-backup 2>&1)
-ERRMAIL
diff --git a/ansible/roles/borg-server/defaults/main.yml b/ansible/roles/borg-server/defaults/main.yml
deleted file mode 100644
index 8d25395..0000000
--- a/ansible/roles/borg-server/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
-borg_server__home: /borg
-borg_server__shell: /bin/bash
diff --git a/ansible/roles/borg-server/tasks/borg-server.yml b/ansible/roles/borg-server/tasks/borg-server.yml
deleted file mode 100644
index 253aa4a..0000000
--- a/ansible/roles/borg-server/tasks/borg-server.yml
+++ /dev/null
@@ -1,30 +0,0 @@
-- debug: var=groups[borg_server__clients_ansible_group]
-
-- become: yes
- become_user: borg
- vars:
- clients: "{{ groups[borg_server__clients_ansible_group] }}"
- block:
- - name: mkdir repos
- file:
- path: "{{ borg_server__home }}/repos"
- state: directory
- mode: u=rwx,go=
-
- - name: mkdir repos/{{ item.key }}
- with_items: "{{ clients }}"
- command: borg init "{{ item }}" -e none
- args:
- creates: "{{ borg_server__home }}/repos/{{ item }}"
- chdir: "{{ borg_server__home }}/repos"
-
- - name: authorized_keys
- with_items: "{{ clients }}"
- vars:
- client: "{{hostvars[ansible_hostname]['borg_' + item]}}"
- authorized_key:
- user: borg
- state: "{{ client.state }}"
- key: "{{ lookup('file', item + '/etc/borg/id_ed25519.pub') }}"
- path: "{{ borg_server__home }}/.ssh/authorized_keys"
- key_options: "command=\"cd {{ borg_server__home }}/repos; borg serve --append-only --restrict-to-path {{ borg_server__home }}/repos/{{ item }}\",no-port-forwarding,no-X11-forwarding,no-pty,no-agent-forwarding,no-user-rc"
diff --git a/ansible/roles/borg-server/tasks/main.yml b/ansible/roles/borg-server/tasks/main.yml
deleted file mode 100644
index c975803..0000000
--- a/ansible/roles/borg-server/tasks/main.yml
+++ /dev/null
@@ -1,26 +0,0 @@
-- name: packages
- tags: borg-server
- become: yes
- apt:
- name: "{{ items }}"
- install_recommends: no
- vars:
- items:
- - borgbackup
-
-- name: Create unix group
- become: yes
- group:
- name: borg
- system: yes
-
-- name: Create unix user
- become: yes
- user:
- name: borg
- system: yes
- group: borg
- shell: "{{ borg_server__shell }}"
- home: "{{ borg_server__home }}"
-
-- import_tasks: borg-server.yml