In my salted setup I am trying to use (on dom0) unless analogous to what is shown for file.file_exists in the salt documentation:
# Ensure presence of dedicated named dispVM - not currently achievable using the qvm.vm state 20240108
Ensure presence of dedicated named dispVM:
cmd.run:
- name: qvm-create --class DispVM --template={{ dflt_dvm_tmplt }} --label red named-{{ dflt_dvm_tmplt }}
- unless:
- fun: qvm.exists
name: named-{{ dflt_dvm_tmplt }}
This, however, produces an error, that culminates in
In this particular example, you could use the command qvm.present directly instead of cmd.run. It will automatically detect the qube’s presence and not create it twice if it’s already there.
Edit: as for the unless requisite, it only accepts commands that you can use on the command line as arguments, such as qvm-ls. Correction: it also accepts modules, see unman’s answer below.
I was unable to get that construct to accept any --class DispVM equivalent that I require to create the named dispVM using the cmd.run call above - how would that work? I’m more than happy to (re)integrate the generation of the named dispVM back into the general solution…