From 026e32f9d058c3a3a068f210d68a726a78837cc3 Mon Sep 17 00:00:00 2001 From: mg Date: Thu, 25 Feb 2021 09:48:01 +0000 Subject: [PATCH] Scripte umgezogen --- .../tasks/main.yml | 24 ------------------ .../templates/hddtemps.sh | 2 -- .../templates/systemtemps.sh | 2 -- roles/mgrote.proxmox/README.md | 25 ------------------- roles/mgrote.proxmox/defaults/main.yml | 1 - roles/mgrote.proxmox/handlers/main.yml | 0 roles/mgrote.proxmox/meta/main.yml | 1 - roles/mgrote.proxmox/tasks/main.yml | 7 ------ roles/mgrote.proxmox/templates/start_pools.sh | 8 ------ roles/mgrote.zfs_packages/tasks/main.yml | 8 ++++++ .../templates/zfs-free.sh | 0 11 files changed, 8 insertions(+), 70 deletions(-) delete mode 100644 roles/mgrote.apt_install_packages/templates/hddtemps.sh delete mode 100644 roles/mgrote.apt_install_packages/templates/systemtemps.sh delete mode 100644 roles/mgrote.proxmox/README.md delete mode 100644 roles/mgrote.proxmox/defaults/main.yml delete mode 100644 roles/mgrote.proxmox/handlers/main.yml delete mode 100644 roles/mgrote.proxmox/meta/main.yml delete mode 100644 roles/mgrote.proxmox/tasks/main.yml delete mode 100644 roles/mgrote.proxmox/templates/start_pools.sh rename roles/{mgrote.apt_install_packages => mgrote.zfs_packages}/templates/zfs-free.sh (100%) diff --git a/roles/mgrote.apt_install_packages/tasks/main.yml b/roles/mgrote.apt_install_packages/tasks/main.yml index f2a133e1..44577000 100644 --- a/roles/mgrote.apt_install_packages/tasks/main.yml +++ b/roles/mgrote.apt_install_packages/tasks/main.yml @@ -30,27 +30,3 @@ name: "{{ programs_only_physical }}" state: present when: ansible_virtualization_role != 'guest' - - - name: copy hddtemps.sh - become: yes - ansible.builtin.template: - src: "hddtemps.sh" - dest: "/usr/local/bin/hddtemps.sh" - mode: a+x - when: ansible_virtualization_role != 'guest' - - - name: copy systemtemps.sh - become: yes - ansible.builtin.template: - src: "systemtemps.sh" - dest: "/usr/local/bin/systemtemps.sh" - mode: a+x - when: ansible_virtualization_role != 'guest' - - - name: copy zfs-free.sh - become: yes - ansible.builtin.template: - mode: 0555 - src: zfs-free.sh - dest: /usr/local/bin/zfs-free.sh - when: "'proxmox' in group_names" diff --git a/roles/mgrote.apt_install_packages/templates/hddtemps.sh b/roles/mgrote.apt_install_packages/templates/hddtemps.sh deleted file mode 100644 index 5be79d9b..00000000 --- a/roles/mgrote.apt_install_packages/templates/hddtemps.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -watch --interval 10 --differences --color --no-title "sudo hddtemp /dev/disk/by-id/ata-* | grep -v "part" | sed -r 's#(/dev/disk/by-id/ata-)([^:]+).*: ([0-9]{1,3}°C)#\3\t\2#g' | sort -n -r" diff --git a/roles/mgrote.apt_install_packages/templates/systemtemps.sh b/roles/mgrote.apt_install_packages/templates/systemtemps.sh deleted file mode 100644 index 73e65352..00000000 --- a/roles/mgrote.apt_install_packages/templates/systemtemps.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -watch --interval 10 --differences --color --no-title "sudo ipmitool sensor | cut --delimiter '|' -f 1-3 | grep -i "degrees" | sort -k2 -r | tr --delete \"|\" | tr --squeeze-repeats \" \" | sed -r 's/(degrees C)/°C/g;s/([[:alnum:]]+[[:space:]][[:alpha:]]+ )([[:digit:]]+\.[[:digit:]]+ )(°C)/\2\3\t\1/g;s/(.000)//g;s/( Temp)//g'" diff --git a/roles/mgrote.proxmox/README.md b/roles/mgrote.proxmox/README.md deleted file mode 100644 index 4e10eff7..00000000 --- a/roles/mgrote.proxmox/README.md +++ /dev/null @@ -1,25 +0,0 @@ -## mgrote.proxmox - -### Beschreibung -Installiert ein Script um komplette Poools zu starten/stoppen. - -### Funktioniert auf -- [x] ProxMox 6.1 - -### Variablen + Defaults -see [defaults](./defaults/main.yml) - -### Erklärung start_pools.sh -#### Argumente -`$1, $2, $n` = gleich Parameter in der Schreibreihenfolge nach dem Aufruf, also -`./pools.sh Test start` -`Test = $1` -`start = $2` -möglich: Poolnamen(case-sensitiv) & start/stop/shutdown - -#### RegEx -`sudo pvesh get /pools/$1 |` gibt alle VM/ct-Daten als JSON(?)-Objekt mit Formatierung aus -`sed -r 's#(,)#\n#g;s#\│##g;s#─##g;s#┴##g;s#└##g;s#┘##g;s#╞##g;s#╪##g;s#═##g;s#╡##g;s#\{##g;s#\}##g;s#\"*\"##g;s#\[##g;s#\]##g;s#id\:## g' |` erstellt Zeilenumbrüche, entfernt Formatierung, formatiert Text für grep -`grep -E 'qemu/[[:digit:]]{3}' |` sucht alle Zeilen aus die den Typ und die VMID enthalten -`sed -r 's#(qemu\/)([0-9]{3})#\2#g' | ` entfernt den Typ von der VMID -`sudo xargs -i --verbose qm "$2" {}` übergibt VMIDs an das PVE-Kommando mit xargs diff --git a/roles/mgrote.proxmox/defaults/main.yml b/roles/mgrote.proxmox/defaults/main.yml deleted file mode 100644 index ed97d539..00000000 --- a/roles/mgrote.proxmox/defaults/main.yml +++ /dev/null @@ -1 +0,0 @@ ---- diff --git a/roles/mgrote.proxmox/handlers/main.yml b/roles/mgrote.proxmox/handlers/main.yml deleted file mode 100644 index e69de29b..00000000 diff --git a/roles/mgrote.proxmox/meta/main.yml b/roles/mgrote.proxmox/meta/main.yml deleted file mode 100644 index ed97d539..00000000 --- a/roles/mgrote.proxmox/meta/main.yml +++ /dev/null @@ -1 +0,0 @@ ---- diff --git a/roles/mgrote.proxmox/tasks/main.yml b/roles/mgrote.proxmox/tasks/main.yml deleted file mode 100644 index 08d55bfa..00000000 --- a/roles/mgrote.proxmox/tasks/main.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- - - name: copy start_pools.sh - become: yes - ansible.builtin.template: - src: "start_pools.sh" - dest: "/usr/local/bin/start_pools.sh" - mode: a+x diff --git a/roles/mgrote.proxmox/templates/start_pools.sh b/roles/mgrote.proxmox/templates/start_pools.sh deleted file mode 100644 index 7d4c26ad..00000000 --- a/roles/mgrote.proxmox/templates/start_pools.sh +++ /dev/null @@ -1,8 +0,0 @@ -#! /bin/bash -{% raw %} -# starte/stoppe Container -sudo pvesh get /pools/$1 | sed -r 's#(,)#\n#g;s#\│##g;s#─##g;s#┴##g;s#└##g;s#┘##g;s#╞##g;s#╪##g;s#═##g;s#╡##g;s#\{##g;s#\}##g;s#\"*\"##g;s#\[##g;s#\]##g;s#id\:##g' | grep -E 'lxc/[[:digit:]]{3}' | sed -r 's#(lxc\/)([0-9]{3})#\2#g' | sudo xargs -i sh -c "pct "$2" {} || true" - -# starte/stoppe VMs -sudo pvesh get /pools/$1 | sed -r 's#(,)#\n#g;s#\│##g;s#─##g;s#┴##g;s#└##g;s#┘##g;s#╞##g;s#╪##g;s#═##g;s#╡##g;s#\{##g;s#\}##g;s#\"*\"##g;s#\[##g;s#\]##g;s#id\:##g' | grep -E 'qemu/[[:digit:]]{3}' | sed -r 's#(qemu\/)([0-9]{3})#\2#g' | sudo xargs -i sh -c "qm "$2" {} || true" -{% endraw %} diff --git a/roles/mgrote.zfs_packages/tasks/main.yml b/roles/mgrote.zfs_packages/tasks/main.yml index cd1f585b..1a60cb9c 100644 --- a/roles/mgrote.zfs_packages/tasks/main.yml +++ b/roles/mgrote.zfs_packages/tasks/main.yml @@ -7,3 +7,11 @@ - zfs-initramfs - zfs-zed state: present + + - name: copy zfs-free.sh + become: yes + ansible.builtin.template: + mode: 0555 + src: zfs-free.sh + dest: /usr/local/bin/zfs-free.sh + when: "'proxmox' in group_names" diff --git a/roles/mgrote.apt_install_packages/templates/zfs-free.sh b/roles/mgrote.zfs_packages/templates/zfs-free.sh similarity index 100% rename from roles/mgrote.apt_install_packages/templates/zfs-free.sh rename to roles/mgrote.zfs_packages/templates/zfs-free.sh