Is there a way to automatically set the default disposable template for a new AppVM at the moment of its creation?
Specifically, I want to set whonix-workstation-18-dvm as the default disposable template for all new App qubes based on the whonix-workstation-18 template.
Currently, I have to set the default disposable template manually for every AppVM at the time of creation, because by default it is always set to “none”.
Setting it in global configuration is not an option because that will set it for everything else.
Using salt? then I’ll have to create every app qube of whonix workstation using salt. Right?
Using script? How?
#!/usr/bin/env bash
(
set -o errexit
set -o errtrace
CMD="qvm-create"
while [ $# -gt 0 ]
do
if [ "$1" == "--template" ] || [ "$1" == "-t" ]
then
CMD="$CMD $1"
shift
if [ "$1" == "whonix-workstation-18" ]
then
echo 'WOOF! whonix!!!'
CMD="$CMD --prop default_dispvm=whonix-workstation-18-dvm"
fi
fi
CMD="$CMD $1"
shift
done
# Test it plenty, once confident - replace echo with just `$CMD`
echo "$CMD"
)
Just give it the same arguments as you would to qvm-create
If I understand correctly, I’d have to use this script every time I want to create a new App qube (instead of the usual method). If that’s the case, Salt seems like a much better option.
Well yes, since it’s essentially a proxy between you and qvm-create. Depends on your preference between qvm-create and salt.
I assume seamless alternative would be either a daemon that listens for qube creation event or a hook script that runs on such an event. Unfortunately I don’t know how to do either.
You probably should ask for something like that in mailing list or matrix chat
This specific thing should happen automatically thanks to GitHub - QubesOS/qubes-core-admin-addon-whonix. It should default to (template-name)-dvm which is whonix-workstation-18-dvm here. But, you can also customize it by setting whonix-default-dispvm qvm-feature on the template to a name of disposable template to be used for app qubes based on such template.
For all of this to work, the template needs to have whonix-ws qvm-feature enabled, but again, it should be there by default.
So, if it doesn’t work, can you show what qvm-features prints for the whonix workstation template and the new app qube?
When I create a new App qube based on this template, the resulting App qube automatically has whonix-workstation-18-dvm set as its default disposable template.
However, I then created a clone of the original template named whonix-workstation-18-web. Checking its features shows:
This looks correct.
I think I know what happened. There is a check if default_dispvm is none, with a comment user must have changed it manually - in which case the above default does not apply. But that may also happen if the global default dispvm is set to none - is it? Is it better if you change the global default to something else?
@arraybolt3 should it maybe check for vm.property_is_default("default_dispvm") instead?
This sounds plausible, but why then do AppVMs made from the first template have their default_dispvm set properly? Do they inherit it from the template they’re built from? If so, that would mean marcos-morar’s original template has the property set. But then why would it not be set on the cloned template, wouldn’t it inherit it from that template? There might be a deeper issue here.
As long as it can differentiate between “property is defaulting to the global default” and “property was set by the user to a value that happens to be the same as the global default”, that sounds like it would work. I would guess it can do that.
There’s definitely a deeper issue here. I can reproduce this on my machine, even though the “Default disposable template” in Qubes OS Global Config is set to default-dvm. Will investigate and try to find a fix.
elif template is not None:
# If we have a template, use it for assuming a name.
default_dispvm = template.name + "-dvm"
default_dispvm (the variable, not the property) ends up set to whonix-workstation-18-web-dvm, which doesn’t exist, so it ends up logging an error and setting the default_dispvm to None. (The error is in my qubesd journal logs.)
The fix should be easy enough; make sure that the VM name built by template.name + "-dvm" actually exists, and if it doesn’t, continue to the next fallback (hardcoded whonix-workstation-18-dvm).
You can easily begin to create qubes, and configure them. And you can
do a lot with just basic state files. If you want a step by step guide
you could look here which starts with the basics
and gradually adds more detail. There are many simple example states.
In the shaker you will find somewhat
more complicated configurations, but the states are deliberately kept
simple, and should be understandable by relative beginners.
Once you have the basics you can build on them, and you will have a self
documented system. One advantage - you can move to a new or temporary
machine, download some states and build a partial copy of your original
qubes, ready to restore (some or all) data. Good to do this when travelling.
I never presume to speak for the Qubes team.
When I comment in the Forum I speak for myself.