Skip to content

Commit 7dc68b5

Browse files
committed
Add documentation.
1 parent 5ae1624 commit 7dc68b5

File tree

6 files changed

+183
-61
lines changed

6 files changed

+183
-61
lines changed

webpages/ConfigAccess-preview.png

10.6 KB
Loading

webpages/PoolAccess-preview.png

6.92 KB
Loading

webpages/_layouts/vm-operator.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@
6868
<li><p class="part-entry"><a href="admin-gui.html">For Admins</a></p></li>
6969
<li><p class="part-entry"><a href="user-gui.html">For Users</a></p></li>
7070
</ul>
71+
<p class="part-list-title">Advanced</p>
72+
<ul style="margin-bottom: 0;" class="no-bullets">
73+
<li><p class="part-entry"><a href="auto-login.html">Auto Login</a></p></li>
74+
<li><p class="part-entry"><a href="pools.html">Pools</a></p></li>
75+
</ul>
7176
<p class="part-list-title"><a href="upgrading.html">Upgrading</a></p>
7277
<p class="part-list-title"><a href="https://vm-operator.jdrupes.org/javadoc/index.html">Javadoc</a></p>
7378

webpages/auto-login.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
title: "VM-Operator: Auto login — Login users automatically on the guest"
3+
layout: vm-operator
4+
---
5+
6+
# Auto Login
7+
8+
*Since 4.0.0*
9+
10+
When a user logs in on the web GUI, he has already authenticated with the
11+
VM-Operator. Depending on the environment, it may be tedious to log in again
12+
on the guest. The VM-Operator therefore supports automatic login on the guest
13+
operating system which can streamline the user experience by eliminating
14+
the need for multiple logins. This requires, however, some support from
15+
the guest OS.
16+
17+
## Prepare the VM
18+
19+
Automatic login requires an agent in the guest OS. Similar to QEMU's
20+
standard guest agent, the VM-Operator agent communicates with the host
21+
through a tty device (`/dev/virtio-ports/org.jdrupes.vmop_agent.0`). On a modern
22+
Linux system, the device is detected by `udev` which triggers the start
23+
of a systemd service.
24+
25+
Sample configuration files can be found
26+
[here](https://github.com/mnlipp/VM-Operator/tree/main/dev-example/vmop-agent).
27+
Copy
28+
29+
* `99-vmop-agent.rules` to `/usr/local/lib/udev/rules.d/99-vmop-agent.rules`,
30+
* `vmop-agent` to `/usr/local/libexec/vmop-agent` and
31+
* `vmop-agent.service` to `/usr/local/lib/systemd/system/vmop-agent.service`.
32+
33+
Note that some of the target directories do not exist by default and have to
34+
be created first. Don't forget to run `restorecon` on systems with SELinux.
35+
36+
Enable everything:
37+
38+
```console
39+
# systemctl daemon-reload
40+
# systemctl enable vmop-agent
41+
# udevadm control --reload-rules
42+
# udevadm trigger
43+
```
44+
45+
## The VM operator agent
46+
47+
Communication with the VM-Operator agent follows the pattern established
48+
by protocols such as SMTP and FTP. The agent must handle the commands
49+
"`login <username>`" and "`logout`". In response to these commands, the agent
50+
sends back lines that start with a three digit number. The first digit
51+
determines the type of message: "1" for informational, "2" for success
52+
"4" and "5" for errors. The second digit provides information about the
53+
category that the response relates to. The third digit is specific to
54+
the command.
55+
56+
While this describes the general pattern, the only response code that
57+
the runner evaluates are:
58+
59+
| Code | Meaning |
60+
| ---- | ------- |
61+
| 220 | Sent by the agent on startup |
62+
| 201 | Login command executed successfully |
63+
| 202 | Logout command executed successfully |
64+
65+
The sample script is written for the gnome desktop environment. It assumes
66+
that gdm is running as a service by default. On receiving the login command,
67+
it stops gdm and starts a gnome-session for the given user. On receiving the
68+
logout command, it terminates the session and starts gdm again.
69+
70+
No attempt has been made to make the script configurable. There are too
71+
many possible options. The script should therefore be considered as a
72+
starting point that you can adapt to your needs.
73+
74+
The sample script also creates new user accounts if a user does not exist
75+
yet. The idea behind this is further explained in the
76+
[section about pools](pools.html#vm-pools).
77+
78+
## Enable auto login for a VM
79+
80+
To enable auto login for a VM, specify the user to be logged in in the VM's
81+
definition with "`spec.vm.display.loggedInUser: user-name`". If everything has been
82+
set up correctly, you should be able to open the console and observe the
83+
change from gdm's login screen to the user's desktop when updating the
84+
VM's spec.

webpages/pools.md

Lines changed: 93 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -7,67 +7,100 @@ layout: vm-operator
77

88
*Since 4.0.0*
99

10-
## Prepare the VM
10+
Not all VMs are replacements for carefully maintained individual PCs.
11+
In many workplaces, a standard configuration can be used where
12+
user-specific data is kept in each user's home directory on a shared
13+
file system. In such cases, an alternative to providing individual
14+
PCs is to offer a pool of VMs and allocate them from the pool to users
15+
as needed.
16+
17+
## Pool definitions
18+
19+
The VM-operator supports this use case with a CRD for pools.
20+
21+
```yaml
22+
apiVersion: "vmoperator.jdrupes.org/v1"
23+
kind: VmPool
24+
metadata:
25+
namespace: vmop-dev
26+
name: test-vms
27+
spec:
28+
retention: "PT4h"
29+
loginOnAssignment: true
30+
permissions:
31+
- user: admin
32+
may:
33+
- accessConsole
34+
- start
35+
- role: user
36+
may:
37+
- accessConsole
38+
- start
39+
```
40+
41+
The `retention` specifies how long the assignment of a VM from the pool to
42+
a user is retained after the user closes the console. This allows a user
43+
to interrupt his work for this period of time without risking that
44+
another user takes over the VM. The time is specified as
45+
[ISO 8601 duration](https://en.wikipedia.org/wiki/ISO_8601#Durations).
46+
47+
Setting `loginOnAssignment` to `true` triggers automatic login of the
48+
user (as described in [section auto login](auto-login.html)) when
49+
the VM is assigned. The `permissions` property defines what a user can
50+
do with a VM assigned to him.
51+
52+
VMs become members of one (or more) pools by adding the pool name to
53+
property `spec.pools` (an array of strings), e.g.:
54+
55+
```yaml
56+
apiVersion: "vmoperator.jdrupes.org/v1"
57+
kind: VirtualMachine
58+
59+
spec:
60+
pools:
61+
- test-vms
62+
```
63+
64+
## Accessing a VM from the pool
65+
66+
Users can access a VM from a pool using the widget described in
67+
[user view](user-gui.html). The widget must be configured to
68+
provide access to a pool instead of to a specific VM.
69+
70+
![VM Access configuration](ConfigAccess-preview.png){: width="500"}
71+
72+
Assignment happens when the "start" icon is pushed. If the assigned VM
73+
is not running, it will also be started. The assigned VM's name is
74+
shown in the widget above the action icons.
75+
76+
![VM Access via pool](PoolAccess-preview.png)
77+
78+
Apart from showing the assigned VM, the widget behaves in the same way
79+
as it does when configured to access a specific VM.
80+
81+
## Requirements on the guest
82+
83+
Some provisions must be made on the guest to ensure that VMs from
84+
pools work as expected.
1185

1286
### Shared file system
1387

1488
Mount a shared file system as home file system on all VMs in the pool.
15-
If you want to use the sample script for logging in a user, the filesystem
16-
must support POSIX file access control lists (ACLs).
17-
18-
### Restrict access
19-
20-
The VMs should only be accessible via a desktop started by the VM-Operator.
21-
22-
* Disable the display manager.
23-
24-
```console
25-
# systemctl disable gdm
26-
# systemctl stop gdm
27-
```
28-
29-
* Disable `getty` on tty1.
30-
31-
```console
32-
# systemctl mask getty@tty1
33-
# systemctl stop getty@tty1
34-
```
35-
36-
You can, of course, disable `getty` completely. If you do this, make sure
37-
that you can still access your master VM through `ssh`, else you have
38-
locked yourself out.
39-
40-
Strictly speaking, it is not necessary to disable these services, because
41-
the sample script includes a `Conflicts=` directive in the systemd service
42-
that starts the desktop for the user. However, this is mainly intended for
43-
development purposes and not for production.
44-
45-
The following should actually be configured for any VM.
46-
47-
* Prevent suspend/hibernate, because it will lock the VM.
48-
49-
```console
50-
# systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
51-
```
52-
53-
### Install the VM-Operator agent
54-
55-
The VM-Operator agent runs as a systemd service. Sample configuration
56-
files can be found
57-
[here](https://github.com/mnlipp/VM-Operator/tree/main/dev-example/vmop-agent).
58-
Copy
59-
60-
* `99-vmop-agent.rules` to `/usr/local/lib/udev/rules.d/99-vmop-agent.rules`,
61-
* `vmop-agent` to `/usr/local/libexec/vmop-agent` and
62-
* `vmop-agent.service` to `/usr/local/lib/systemd/system/vmop-agent.service`.
63-
64-
Note that some of the target directories do not exist by default and have to
65-
be created first. Don't forget to run `restorecon` on systems with SELinux.
66-
67-
Enable everything:
68-
69-
```console
70-
# udevadm control --reload-rules
71-
# systemctl enable vmop-agent
72-
# udevadm trigger
73-
```
89+
When using the
90+
[sample agent](https://github.com/mnlipp/VM-Operator/tree/main/dev-example/vmop-agent),
91+
the filesystem must support POSIX file access control lists (ACLs).
92+
93+
### User management
94+
95+
All VMs in the pool must map a given user name to the same user
96+
id. This is typically accomplished by using a central user management,
97+
such as LDAP. The drawback of such a solution is that it is rather
98+
complicated to configure.
99+
100+
As an alternative, the sample auto login agent provides a very simple
101+
approach that uses the shared home directory for managing the user ids.
102+
Simplified, the script searches for a home directory with the given user
103+
name and derives the user id from it. It then checks if the user id is
104+
known by the guest operating system. If not, the user is added.
105+
106+
Details can be found in the comments of the sample script.

webpages/user-gui.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The idea of the user view is to provide an intuitive widget that
1515
allows the users to access their own VMs and to optionally start
1616
and stop them.
1717

18-
![VM-Viewer](VmAccess-preview.png)
18+
![VM Access](VmAccess-preview.png)
1919

2020
The configuration options resulting from this seemingly simple
2121
requirement are unexpectedly complex.

0 commit comments

Comments
 (0)