3.5 KiB
lang | layout | permalink | redirect_from | ref | title | ||
---|---|---|---|---|---|---|---|
en | doc | /doc/salt-troubleshooting/ |
|
1000000000000 | Salt troubleshooting |
For ease of Qubes Os managament and reproductible deployment, Salt allows to control states on dom0
and other vms from the dom0
.
Behind the scenes
Except for dom0
where the host is controlled locally.
Each vm (named minion-vm
for instance) is controlled by a disposable master vm based on disposable-mgmt-vm
, named disp-mgmt-minion-vm
and created only for the duration of qubesctl
execution.
The required files are copied from dom0
to disp-mgmt-minion-vm
via qubes.Filecopy
, then qubes.SaltLinuxVM
and expect two lines on stdin :
minion-vm
salt-command
Usually salt-command
is state.apply
with the provided arguments like test=True
.
Then, a fake ssh
command wrapper included in qubes-mgmt-salt-vm-connector
allow to run the command on the target (minion-vm
) via qubes.VMShell
or qubes.VMRootShell
.
On the management vm disp-mgmt-minion-vm
, salt firstly creates /var/cache/salt/master/thin/thin.tgz
and transfers it to the minion-vm
to ensure destination host has the required python files.
How to debug the ephemeral disposable management vm
First, the transfered content from dom0
to the disposable management vm needs to be retrieved. To do so, it is suggested to:
- Call from
dom0
,qubesctl
with requested command likequbesctl --show-output --targets minion-vm --skip-dom0 state.apply
, - Freeze the previous command with
Ctrl+Z
as soon as you seeminion-vm is starting
. - Get the console on the disposable management vm with
qvm-console-dispvm disp-mgmt-minion-vm
on the dom0 - Type
root
to log as root on the console - Edit in
disp-mgmt-minion-vm
,/etc/qubes-rpc/qubes.SaltLinuxVM
and add after the lineeval "dir=~$user/QubesIncoming/dom0/srv"
, the lineqvm-copy $dir
. - On the
dom0
resume the freezed process withfg
- Copy the content to another qubes vm (
side-vm
for instance)
Second, a debugable disposable management vm is setup. To do so, it is suggested to:
- Call from
dom0
,qubesctl
with requested command likequbesctl --show-output --targets minion-vm --skip-dom0 state.apply
, - Freeze the previous command with
Ctrl+Z
as soon as you seeminion-vm is starting
. - Copy the retrieved content from
side-vm
to the disposable management vmdisp-mgmt-minion-vm
(withqvm-copy
) - Get the console on the disposable management vm with
qvm-console-dispvm disp-mgmt-minion-vm
on the dom0 - Type
root
to log as root on the console. All following commands are done inside the console. - Move the copied content to emulate a content coming from
dom0
:cd /home/user/QubesIncoming; mv * dom0
.dom0
directory should contain a directorysrv
. - Emulate a call to
qubes.SaltLinuxVM
withbash /etc/qubes-rpc/qubes.SaltLinuxVM
- Emulate stdin. Type the destination vm on the first line (
minion-vm
), the salt command on the second line (state.apply
for instance) thenCtrl+D
. - A first execution is launched
- Get wrappers in the
PATH
withexport PATH="/usr/lib/qubes-vm/connector/ssh-wrapper:$PATH" (the line is available in
/etc/qubes-rpc/qubes.SaltLinuxVM`
Third, launch as many times as needed the following command to emulate a new call of master to the minion rm -r /var/cache/salt /var/tmp/.root*; salt-ssh -w minion-vm salt-command
in the console.