diff --git a/bin/borg-prune b/bin/borg-prune new file mode 100755 index 0000000..ecf4862 --- /dev/null +++ b/bin/borg-prune @@ -0,0 +1,33 @@ +#!/bin/bash +######################################################################### +# Copyright (C) 2020 Akito # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +######################################################################### +# https://borgbackup.readthedocs.io/en/stable/deployment/automated-local.html +# 0.2.0 +PURPOSE="SYSTEM" +TARGET_HOST="" +LOCATION="/tank/borg/" +BORG_REPO="${HOSTNAME}" +ARC_NAME="${HOSTNAME}+${USER}:$(date +"%Y%m%dT%H%M%S")" +BORG_COMMENT="Automated \"${PURPOSE}\" backup to repository \"${BORG_REPO}\" at \"${TARGET_HOST}${LOCATION}\" issued $(date +"%Y-%m-%dT%H:%M:%S")." +BORG_OPTS="--keep-within 31d" +LOGFILE_LOCATION="/tmp" +LOGFILE="borg-${PURPOSE}_$(date +"%Y%m%dT%H%M%S").log" +export BORG_RELOCATED_REPO_ACCESS_IS_OK=yes +export BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK=yes +borg prune ${BORG_OPTS} ${LOCATION}/${BORG_REPO} + +sync diff --git a/hosts b/hosts index 55aaaf1..8cff295 100644 --- a/hosts +++ b/hosts @@ -31,6 +31,7 @@ pi4: brandine: martin: lenny: + snake: pis: hosts: @@ -92,11 +93,12 @@ frinks: ansible_ssh_private_key_file: ~/.ssh/id_rsa servers: hosts: -# ollital.de: +# ollital.nrw: + h2951071.stratoserver.net: # vasmani.de: ollital.net: ashkente.de: - 85.214.129.239: +# 85.214.129.239: mail.olli-cloud.de: git.olli-cloud.de: mumble.olli-cloud.de: diff --git a/installpkg.yml b/installpkg.yml new file mode 100644 index 0000000..10d9733 --- /dev/null +++ b/installpkg.yml @@ -0,0 +1,6 @@ +--- +- hosts: "{{ target }}" + gather_facts: false + remote_user: pi + roles: + - installpkg diff --git a/mountbackup.yml b/mountbackup.yml new file mode 100644 index 0000000..0f43c54 --- /dev/null +++ b/mountbackup.yml @@ -0,0 +1,7 @@ +--- +- hosts: "{{ target }}" + gather_facts: false + remote_user: pi + roles: + - mountbackup + diff --git a/mounttank.yml b/mounttank.yml new file mode 100644 index 0000000..989c9b1 --- /dev/null +++ b/mounttank.yml @@ -0,0 +1,7 @@ +--- +- hosts: "{{ target }}" + gather_facts: false + remote_user: pi + roles: + - mounttank + diff --git a/rebootpis.yml b/rebootpis.yml new file mode 100644 index 0000000..24ff2c1 --- /dev/null +++ b/rebootpis.yml @@ -0,0 +1,7 @@ +--- +- hosts: "{{ target }}" + gather_facts: false + remote_user: pi + roles: + - rebootpi + diff --git a/roles/installpkg/tasks/main.yml b/roles/installpkg/tasks/main.yml new file mode 100644 index 0000000..b00d718 --- /dev/null +++ b/roles/installpkg/tasks/main.yml @@ -0,0 +1,36 @@ +- name: PI Update + become: true + apt: + update_cache: yes + upgrade: dist +- name: Pakete installieren + become: true + apt: + name: + - neofetch + - htop + - cowsay + - docker.io + - git + - locate +# - yum + - dnsutils + - nfs-kernel-server + - vim + - lsof + - ripgrep + + update_cache: yes + cache_valid_time: 86400 +# autoremove: yes +- name: Permission für Docker + become: true + file: path=/var/run/docker.sock mode=0660 +# mode: 660 +- name: adding user pi to docker group + become: true + user: + name: pi + groups: docker,video + + diff --git a/roles/mountbackup/tasks/.main.yml.swp b/roles/mountbackup/tasks/.main.yml.swp new file mode 100644 index 0000000..2e5a57b Binary files /dev/null and b/roles/mountbackup/tasks/.main.yml.swp differ diff --git a/roles/mountbackup/tasks/main.yml b/roles/mountbackup/tasks/main.yml new file mode 100644 index 0000000..025b8e4 --- /dev/null +++ b/roles/mountbackup/tasks/main.yml @@ -0,0 +1,19 @@ +- name: create mountpoint + become: true + file: + path: /backup + state: directory +- name: Insert a line at the end of a file. + become: true + lineinfile: + line: 192.168.178.36:/mnt/md1/backup /backup nfs defaults,user,rw 1000 1000 + path: /etc/fstab +- name: mount /backup + become: true + mount: + path: /backup + src: 192.168.178.36:/mnt/md1/backup + fstype: nfs + state: mounted + + diff --git a/roles/mounttank/tasks/main.yml b/roles/mounttank/tasks/main.yml new file mode 100644 index 0000000..7850e8a --- /dev/null +++ b/roles/mounttank/tasks/main.yml @@ -0,0 +1,5 @@ +- name: Mount /tank + ansible.posix.mount: + become: true + path: /tank + state: mounted diff --git a/roles/rebootpi/tasks/main.yml b/roles/rebootpi/tasks/main.yml new file mode 100644 index 0000000..fabf9c2 --- /dev/null +++ b/roles/rebootpi/tasks/main.yml @@ -0,0 +1,4 @@ +- name: Neustart + become: true + reboot: + diff --git a/roles/umounttank/tasks/main.yml b/roles/umounttank/tasks/main.yml new file mode 100644 index 0000000..34d7eb6 --- /dev/null +++ b/roles/umounttank/tasks/main.yml @@ -0,0 +1,5 @@ +- name: Unmount /tank + become: true + ansible.posix.mount: + path: /tank + state: unmounted diff --git a/umounttank.yml b/umounttank.yml new file mode 100644 index 0000000..7044a3f --- /dev/null +++ b/umounttank.yml @@ -0,0 +1,7 @@ +--- +- hosts: "{{ target }}" + gather_facts: false + remote_user: pi + roles: + - umounttank +