Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create salt-troubleshooting.md #1428

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions user/troubleshooting/salt-troubleshooting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
lang: en
layout: doc
permalink: /doc/salt-troubleshooting/
redirect_from:
- /doc/salt/
- /en/doc/salt/
ref: 1000000000000
title: Salt troubleshooting
---

For ease of Qubes Os managament and reproductible deployment, [Salt](/doc/salt/) allows to control states on `dom0` and other vms from the `dom0`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/Os/OS/
s/vms/qubes/

allows to control states on dom0 and other vms from the dom0.

allows applying a state to all qubes, including dom0.


Behind the scenes
-----------------

Except for `dom0` where the host is controlled locally.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be stated after the next paragraph to give some context of what is being excepted.

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/vm/qube/

controlled by a disposable master vm

There is no master, see the Qubes Salt documentation.

based on disposable-mgmt-vm

There is no such qube, please don't mention.

created only for the duration of qubesctl execution.

created only for the duration of the Salt execution.

I believe this is better than specifying the tool name, focusing on the method being used, Salt.


The required files are copied from `dom0` to `disp-mgmt-minion-vm` via `qubes.Filecopy`, then `qubes.SaltLinuxVM` and expect two lines on stdin :
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove space after stdin. Also please use the non-abbreviated version standard output, although it is pretty well know that the two related.

```
minion-vm
salt-command
```

Usually `salt-command` is `state.apply` with the provided arguments like `test=True`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The is no salt-command, it is not an executable or an argument to salt-call. What you meant is the Salt execution module is state.apply.


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`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mention that the connector is from package.

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/vm/qube/ ; s/salt/Salt/ ; s/python/Python/

firstly creates /var/cache/salt/master/thin/thin.tgz

creates the standalone package /var/cache/salt/master/thin/thin.tgz


How to debug the ephemeral disposable management vm
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/vm/qube/

---------------------------------------------------

First, the transfered content from `dom0` to the disposable management vm needs to be retrieved. To do so, it is suggested to:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/vm/qube/

1. Call from `dom0`, `qubesctl` with requested command like `qubesctl --show-output --targets minion-vm --skip-dom0 state.apply`,
2. Freeze the previous command with `Ctrl+Z` as soon as you see `minion-vm is starting`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minion-vm is starting.

minion-vm is starting.

3. Get the console on the disposable management vm with `qvm-console-dispvm disp-mgmt-minion-vm` on the dom0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/vm/qube/ ; s/on the dom0/from dom0/

4. Type `root` to log as root on the console
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/log/login/

5. Edit in `disp-mgmt-minion-vm`, `/etc/qubes-rpc/qubes.SaltLinuxVM` and add after the line `eval "dir=~$user/QubesIncoming/dom0/srv"`, the line `qvm-copy $dir`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and add after the line eval "dir=~$user/QubesIncoming/dom0/srv", the line qvm-copy $dir.

and after the line eval "dir=~$user/QubesIncoming/dom0/srv", add the line qvm-copy $dir.

Keep the verb near its action.

6. On the `dom0` resume the freezed process with `fg`
7. Copy the content to another qubes vm (`side-vm` for instance)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/vm/qube/


Second, a debugable disposable management vm is setup. To do so, it is suggested to:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/vm/qube/

1. Call from `dom0`, `qubesctl` with requested command like `qubesctl --show-output --targets minion-vm --skip-dom0 state.apply`,
2. Freeze the previous command with `Ctrl+Z` as soon as you see `minion-vm is starting`.
3. Copy the retrieved content from `side-vm` to the disposable management vm `disp-mgmt-minion-vm` (with `qvm-copy`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/vm/qube/

4. Get the console on the disposable management vm with `qvm-console-dispvm disp-mgmt-minion-vm` on the dom0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/vm/qube/

5. Type `root` to log as root on the console. All following commands are done inside the console.
6. Move the copied content to emulate a content coming from `dom0`: `cd /home/user/QubesIncoming; mv * dom0`. `dom0` directory should contain a directory `srv`.
7. Emulate a call to `qubes.SaltLinuxVM` with `bash /etc/qubes-rpc/qubes.SaltLinuxVM`
8. Emulate stdin. Type the destination vm on the first line (`minion-vm`), the salt command on the second line (`state.apply` for instance) then `Ctrl+D`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the salt command

the salt module

9. A first execution is launched
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/A first/The first/

10. Get wrappers in the `PATH` with `export PATH="/usr/lib/qubes-vm/connector/ssh-wrapper:$PATH" (the line is available in `/etc/qubes-rpc/qubes.SaltLinuxVM`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing the ending apostrpohe

`export PATH="/usr/lib/qubes-vm/connector/ssh-wrapper:$PATH"

export PATH="/usr/lib/qubes-vm/connector/ssh-wrapper:$PATH"


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.