From c8f718b23f0eee52f50c5fea114abd0df2ff487b Mon Sep 17 00:00:00 2001 From: Olli Graf Date: Tue, 28 Jun 2022 14:05:07 +0200 Subject: [PATCH] Einige neue roles. --- bin/borg-prune | 33 +++++++++++++++++++++++ hosts | 6 +++-- installpkg.yml | 6 +++++ mountbackup.yml | 7 +++++ mounttank.yml | 7 +++++ rebootpis.yml | 7 +++++ roles/installpkg/tasks/main.yml | 36 ++++++++++++++++++++++++++ roles/mountbackup/tasks/.main.yml.swp | Bin 0 -> 12288 bytes roles/mountbackup/tasks/main.yml | 19 ++++++++++++++ roles/mounttank/tasks/main.yml | 5 ++++ roles/rebootpi/tasks/main.yml | 4 +++ roles/umounttank/tasks/main.yml | 5 ++++ umounttank.yml | 7 +++++ 13 files changed, 140 insertions(+), 2 deletions(-) create mode 100755 bin/borg-prune create mode 100644 installpkg.yml create mode 100644 mountbackup.yml create mode 100644 mounttank.yml create mode 100644 rebootpis.yml create mode 100644 roles/installpkg/tasks/main.yml create mode 100644 roles/mountbackup/tasks/.main.yml.swp create mode 100644 roles/mountbackup/tasks/main.yml create mode 100644 roles/mounttank/tasks/main.yml create mode 100644 roles/rebootpi/tasks/main.yml create mode 100644 roles/umounttank/tasks/main.yml create mode 100644 umounttank.yml 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 0000000000000000000000000000000000000000..2e5a57bb09f59fc3bc339ceb93b5cb6504033461 GIT binary patch literal 12288 zcmeI&O^Vb&6bJBXS0d_&bAhLBXYw%vW1AbyLU5y7sU#IT)0Il7ydVwYcmq!%xO687 z9>A60#ifot$0SG_<0uX=z1Rwwb2tWV=5V(W_x|VPMn@XKX!vFtg-~Zot zl=>q1B>5nDBY7_ABu^#RB|l`%SIK9|N69c{NC%YsU2yUlo);I7sp%IhTHao*W((Y3DfY z>O5Va5RdZ)&5MG5^~9Qm43(ym6X^x9pN!fkr^8Jg{cSeUX1(Dml`ZHp7PYOD$=jcP zR)r|+nW#36o-B`h(`fvje@1zhW${N!hJvkYT5JBewPPpim~@;=nu!;NjH{_{q%$l{ g;@)JF!LDw-skry6*m+)I>ys*Pq{P}{=v&9?CpyNipa1{> literal 0 HcmV?d00001 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 +