Browse Source

Einige neue roles.

master 1.3
Olli Graf 3 years ago
parent
commit
c8f718b23f
  1. 33
      bin/borg-prune
  2. 6
      hosts
  3. 6
      installpkg.yml
  4. 7
      mountbackup.yml
  5. 7
      mounttank.yml
  6. 7
      rebootpis.yml
  7. 36
      roles/installpkg/tasks/main.yml
  8. BIN
      roles/mountbackup/tasks/.main.yml.swp
  9. 19
      roles/mountbackup/tasks/main.yml
  10. 5
      roles/mounttank/tasks/main.yml
  11. 4
      roles/rebootpi/tasks/main.yml
  12. 5
      roles/umounttank/tasks/main.yml
  13. 7
      umounttank.yml

33
bin/borg-prune

@ -0,0 +1,33 @@
#!/bin/bash
#########################################################################
# Copyright (C) 2020 Akito <the@akito.ooo> #
# #
# 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 <http://www.gnu.org/licenses/>. #
#########################################################################
# 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

6
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:

6
installpkg.yml

@ -0,0 +1,6 @@
---
- hosts: "{{ target }}"
gather_facts: false
remote_user: pi
roles:
- installpkg

7
mountbackup.yml

@ -0,0 +1,7 @@
---
- hosts: "{{ target }}"
gather_facts: false
remote_user: pi
roles:
- mountbackup

7
mounttank.yml

@ -0,0 +1,7 @@
---
- hosts: "{{ target }}"
gather_facts: false
remote_user: pi
roles:
- mounttank

7
rebootpis.yml

@ -0,0 +1,7 @@
---
- hosts: "{{ target }}"
gather_facts: false
remote_user: pi
roles:
- rebootpi

36
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

BIN
roles/mountbackup/tasks/.main.yml.swp

Binary file not shown.

19
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

5
roles/mounttank/tasks/main.yml

@ -0,0 +1,5 @@
- name: Mount /tank
ansible.posix.mount:
become: true
path: /tank
state: mounted

4
roles/rebootpi/tasks/main.yml

@ -0,0 +1,4 @@
- name: Neustart
become: true
reboot:

5
roles/umounttank/tasks/main.yml

@ -0,0 +1,5 @@
- name: Unmount /tank
become: true
ansible.posix.mount:
path: /tank
state: unmounted

7
umounttank.yml

@ -0,0 +1,7 @@
---
- hosts: "{{ target }}"
gather_facts: false
remote_user: pi
roles:
- umounttank
Loading…
Cancel
Save