feat: helper to show mgmt property information

For: https://github.com/ben-grande/qusal/issues/69
This commit is contained in:
Ben Grande 2024-06-24 11:14:31 +02:00
parent 620fa10a69
commit e9801c8535
No known key found for this signature in database
GPG Key ID: 00C64E14F51F9E56
5 changed files with 76 additions and 3 deletions

View File

@ -29,8 +29,12 @@ invalid.
### Software version ### Software version
<!-- <!--
You must specify as much information as possible in this category. You must specify as much information as possible in this category. The
You can also specify the base commit of the project. commands shown below are the minimum.
Share the base commit of the project:
$ git rev-parse HEAD
Share information about the Salt management qube structure:
https://github.com/ben-grande/qusal/blob/main/docs/TROUBLESHOOT.md#get-salt-management-information
--> -->
@ -57,7 +61,7 @@ settings manually, this should also be mentioned.
### Expected behavior ### Expected behavior
<!-- <!--
What where you expecting to have happened? Why where you expecting that? What where you expecting to have happened? Why were you expecting that?
--> -->

View File

@ -7,6 +7,7 @@ Qusal troubleshooting guidelines.
* [Detect if your issue was already opened](#detect-if-your-issue-was-already-opened) * [Detect if your issue was already opened](#detect-if-your-issue-was-already-opened)
* [Qrexec client shows Request refused](#qrexec-client-shows-request-refused) * [Qrexec client shows Request refused](#qrexec-client-shows-request-refused)
* [Salt wrapper qubesctl command fails](#salt-wrapper-qubesctl-command-fails) * [Salt wrapper qubesctl command fails](#salt-wrapper-qubesctl-command-fails)
* [Get Salt management information](#get-salt-management-information)
## Detect if your issue was already opened ## Detect if your issue was already opened
@ -69,3 +70,16 @@ Ending the Salt call with `-l debug` argument gives the most detailed output
``` ```
sudo qubesctl state.apply pkg.uptodate -l debug sudo qubesctl state.apply pkg.uptodate -l debug
``` ```
## Get Salt management information
Depending on the operating system of the `management_dispvm`, Salt can fail.
Let's gather some information about it.
Get information about the global `management_dispvm` and the same property of
a specific qube. In this example we use `tpl-qubes-builder`, substitute for
the qube being managed:
```sh
sudo qubesctl state.apply dom0.helpers
qvm-mgmt tpl-qubes-builder
```

46
salt/dom0/files/bin/qvm-mgmt Executable file
View File

@ -0,0 +1,46 @@
#!/bin/sh
## SPDX-FileCopyrightText: 2024 Benjamin Grande M. S. <ben.grande.b@gmail.com>
##
## SPDX-License-Identifier: AGPL-3.0-or-later
set -eu
usage(){
echo "Usage: ${0##*/} QUBE" >&2
exit "${1:-1}"
}
get_qube_feat(){
qube="${1}"
qvm-features "${qube}" \
| grep -e os-distribution -e os-version -e template-release \
-e template-release -e template-name
}
case "${1-}" in
-h|--?help) usage 0;;
-*|"") usage 1;;
*) wanted_qube="${1}";;
esac
mgmt="$(qubes-prefs management_dispvm)"
echo "Global management_dispvm qube: ${mgmt}"
tpl_mgmt="$(qvm-prefs "${mgmt}" template)"
echo "Global management_dispvm template: ${tpl_mgmt}"
echo "Global management_dispvm template features:"
get_qube_feat "${tpl_mgmt}"
if ! qvm-check -q -- "${wanted_qube}"; then
echo "error: qube '${wanted_qube}' does not exist" >&2
exit 1
fi
echo "Wanted qube: ${wanted_qube}"
wanted_mgmt="$(qvm-prefs "${wanted_qube}" management_dispvm)"
echo "Global management_dispvm qube: ${wanted_mgmt}"
if test "${wanted_mgmt}" = "${mgmt}"; then
exit
fi
wanted_tpl_mgmt="$(qvm-prefs "${wanted_mgmt}" template)"
echo "Global management_dispvm template: ${wanted_tpl_mgmt}"
echo "Global management_dispvm template features:"
get_qube_feat "${wanted_tpl_mgmt}"

0
salt/dom0/files/bin/qvm-port-forward Normal file → Executable file
View File

View File

@ -35,4 +35,13 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- group: root - group: root
- makedirs: True - makedirs: True
"{{ slsdotpath }}-mgmt-debug-helper":
file.managed:
- name: /usr/local/bin/qvm-mgmt
- source: salt://{{ slsdotpath }}/files/bin/qvm-mgmt
- mode: "0755"
- user: root
- group: root
- makedirs: True
{% endif -%} {% endif -%}