I’m trying to figure out the correct way to turn on the cups service via SALT so I can print through a usb cable. I know I can enable cups in a dom0 terminal via qvm-service [VMNAME] cups --enable. But I want to learn how to do this with SALT, so I can set it in a .sls file and configure any new Qubes installs super easily.
I have previously enabled /srv/user_salt and have used it to configure various qubes in the past. So my basic SALT set up works.
From online reading (GitHub - QubesOS/qubes-mgmt-salt-dom0-qvm) I added the following code snipped to my sys-usb.sls file.
{% if grains['id'] == 'dom0' %}
sys-usb-setup:
qvm.vm:
### Some code removed for this post that isn't relevant to cups ###
- features:
- enable:
- service.cups
{% endif %}
Then in a dom0 terminal I run sudo qubesctl --targets sys-usb state.sls sys-usb saltenv=user. When I look at the qubesctl output, it doesn’t throw any errors. It seems to confirm that cups is now in the output.
Because my sys-usb is a disposable qube, I used the SALT code from above and applied it to the appvm that is the disposable template for sys-usb, and for the template to the appvm.
I then turn off the template, and the appvm that is the disposable template for sys-usb. Then I restart sys-usb so all the changes can propagate through the chain.
But when I check /var/run/qubes-service/ there isn’t a file named cups there. To make that file appear, I seem to have to run qvm-service sys-usb cups --enable from a terminal in dom0.
I ran qvm-service sys-usb cups --enable to get my printer working initially. Later, when I started this SALT journey, I ran qvm-service sys-usb cups --disable because I thought it would give me a blank slate. But maybe if qvm-service and SALT disagree, qvm-service always wins?
I suspect I could use file.manage to make the cups file appear in /var/run/qubes-service/, using SALT, but that feels like a hacky way to do this, when in the documentation there is a way in SALT to set services.
As an aside, do I need to enable cups in the template, the appvm that services as the disposable template, and the disposable? Since the cups file lives in /var, I thought maybe turning cups on in the template would be enough. But on the other hand, the need for a file to be placed in /var kind of implies that qubes OS has some extra requirements around services, which could imply that cups enabled in appvm and disposable might be enough (or even in just the disposable)? My end goal is to have the disposable automatically have cups running whenever I turn it on, with the minimum number of other qubes having to have cups on to enable it in the disposable.
So yeah, I’m curious what might be causing my SALT thing to fail. I’m also open to reading links if people know a specific page which might go over my woes.