fix: better output for cacher tag assignment

This commit is contained in:
Ben Grande 2023-12-20 11:43:54 +01:00
parent 71d22c54b6
commit a78b90e8bd
2 changed files with 18 additions and 8 deletions

View File

@ -0,0 +1,15 @@
#!/bin/sh
# SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. <ben.grande.b@gmail.com>
#
# SPDX-License-Identifier: AGPL-3.0-or-later
set -eu
exclude="$(qvm-ls --no-spinner --raw-list --tags whonix-updatevm \
| sed "s/^./--exclude &/" | tr "\n" " ")"
wanted="$(qvm-ls --no-spinner --raw-data --fields=NAME,CLASS --all ${exclude} \
| awk -v class="TemplateVM" -F "|" '$2 ~ class {print $1}')"
echo "${wanted}"

View File

@ -4,14 +4,9 @@ SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. <ben.grande.b@gmail.com>
SPDX-License-Identifier: AGPL-3.0-or-later
#}
{% set avoid = salt['cmd.shell']('qvm-ls --no-spinner --raw-list --tags whonix-updatevm') -%}
{% set exclude = salt['cmd.shell']('for qube in ' ~ avoid ~ '; do exclude="$exclude --exclude $qube"; done; echo "$exclude"') -%}
{% set wanted = salt['cmd.shell']('qvm-ls --no-spinner --raw-data --fields=NAME,CLASS --all ' ~ exclude ~ ' | awk -F "|" "/|TemplateVM|/{print $1}"') -%}
{% for tpl in wanted -%}
"{{ tpl }}-cacher-tag":
{% set templates = salt['cmd.script']('salt://' ~ slsdotpath ~ '/files/admin/tag.sh') -%}
{% for tpl in templates.stdout.split("\n") -%}
"{{ slsdotpath }}-tag-for-{{ tpl }}":
qvm.tags:
- name: {{ tpl }}
- add: