Skip to content

Commit 06f0aa6

Browse files
authored
test(guest): consolidate rootless Podman provisioning (#3125)
* fix(test-guest): support Nix stat on macOS Signed-off-by: Evan Lezar <elezar@nvidia.com> * test(guest): version Ubuntu test guest profiles Signed-off-by: Evan Lezar <elezar@nvidia.com> * test(guest): consolidate rootless Podman provisioning Signed-off-by: Evan Lezar <elezar@nvidia.com> --------- Signed-off-by: Evan Lezar <elezar@nvidia.com>
1 parent fd9fc0a commit 06f0aa6

12 files changed

Lines changed: 239 additions & 85 deletions

File tree

‎nix/test-guest/README.md‎

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,20 @@ nix/test-guest/
3333
├── cache-lib.sh
3434
├── cache-seal.sh
3535
├── distros/
36-
│ ├── ubuntu.nix
36+
│ ├── ubuntu-24-04.nix
37+
│ ├── ubuntu-26-04.nix
3738
│ ├── centos.nix
3839
│ ├── fedora.nix
3940
│ └── rocky.nix
4041
└── configuration/
4142
├── docker.yml
42-
├── podman.yml
43+
├── podman-rootless.yml
44+
├── tasks/
45+
│ ├── podman-common.yml
46+
│ └── podman-rootless/
47+
│ ├── fedora.yml
48+
│ ├── shared.yml
49+
│ └── ubuntu.yml
4350
└── selinux.yml
4451
```
4552

@@ -56,22 +63,26 @@ The root [`flake.nix`](../../flake.nix) exposes this directory as the `test-gues
5663

5764
## Supported configurations
5865

59-
| Distro | Docker | Podman | SELinux | Package format |
66+
| Distro | Docker | Rootless Podman | SELinux | Package format |
6067
| --- | --- | --- | --- | --- |
61-
| Ubuntu 24.04 | Yes | Yes | No | `.deb` |
62-
| CentOS Stream 10 | No | Yes | Yes | `.rpm` |
68+
| Ubuntu 24.04 | Yes | No | No | `.deb` |
69+
| Ubuntu 26.04 | Yes | Yes | No | `.deb` |
70+
| CentOS Stream 10 | No | No | Yes | `.rpm` |
6371
| Fedora 44 | No | Yes | Yes | `.rpm` |
64-
| Rocky Linux 9 | Yes | Yes | Yes | `.rpm` |
72+
| Rocky Linux 9 | Yes | No | Yes | `.rpm` |
6573

6674
The `snapd` configuration is available for Ubuntu and prepares snapd for
6775
local Snap lifecycle experiments. It does not install Docker, because the Snap
6876
gateway reproduction uses the Docker **Snap** and its `docker:docker-daemon`
6977
interface rather than the host-package Docker configuration.
7078

71-
The Ubuntu 24.04 Podman configuration is available for runtime and packaging
72-
checks, but its Podman 4 release does not provide the `pasta` rootless network
73-
helper required by OpenShell sandbox callbacks. OpenShell Podman E2E runs use
74-
the Fedora guest, which provides Podman 5 and `pasta`.
79+
`podman-rootless` configures the explicit rootless Podman guest setup used by
80+
OpenShell tests. It supports Fedora and Ubuntu 26.04 or later. Ubuntu adds the
81+
AppArmor rule that permits `pasta` to receive Podman stop signals. Fedora
82+
installs the subordinate-ID utilities and rootless storage and network helpers.
83+
Both configurations verify rootless mode and the `pasta` network helper
84+
required by OpenShell sandbox callbacks. Ubuntu 24.04 ships Podman 4, which
85+
does not provide that helper.
7586

7687
List the available distros and configurations:
7788

@@ -84,30 +95,30 @@ nix run .#test-guest -- --list
8495
Boot a base Ubuntu VM:
8596

8697
```shell
87-
nix run .#test-guest -- --distro ubuntu
98+
nix run .#test-guest -- --distro ubuntu-24-04
8899
```
89100

90101
Apply the Docker configuration before opening the SSH session:
91102

92103
```shell
93-
nix run .#test-guest -- --distro ubuntu --with docker
104+
nix run .#test-guest -- --distro ubuntu-24-04 --with docker
94105
```
95106

96107
Other combinations use the same interface:
97108

98109
```shell
99110
nix run .#test-guest -- --distro rocky --with docker
100-
nix run .#test-guest -- --distro centos --with podman
101-
nix run .#test-guest -- --distro fedora --with podman
111+
nix run .#test-guest -- --distro ubuntu-26-04 --with podman-rootless
112+
nix run .#test-guest -- --distro fedora --with podman-rootless
102113
```
103114

104115
Configurations are repeatable:
105116

106117
```shell
107118
nix run .#test-guest -- \
108-
--distro ubuntu \
119+
--distro ubuntu-24-04 \
109120
--with docker \
110-
--with podman
121+
--with podman-rootless
111122
```
112123

113124
Ensure SELinux is enforcing on CentOS, Fedora, or Rocky:
@@ -138,7 +149,7 @@ The `test-guest-cache` app ensures a prepared disk exists for one exact distro,
138149

139150
```shell
140151
nix run .#test-guest-cache -- \
141-
--distro ubuntu \
152+
--distro ubuntu-24-04 \
142153
--with docker
143154
```
144155

@@ -147,7 +158,7 @@ backing cache:
147158

148159
```shell
149160
nix run .#test-guest-cache -- \
150-
--distro ubuntu \
161+
--distro ubuntu-24-04 \
151162
--with docker \
152163
--repository ghcr.io/nvidia/openshell/test-guest-cache \
153164
--digest sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
@@ -157,7 +168,7 @@ The command never publishes implicitly. Add `--push` after authenticating ORAS t
157168

158169
```shell
159170
nix run .#test-guest-cache -- \
160-
--distro ubuntu \
171+
--distro ubuntu-24-04 \
161172
--with docker \
162173
--repository ghcr.io/nvidia/openshell/test-guest-cache \
163174
--push
@@ -184,8 +195,8 @@ The default cache directory is `${XDG_CACHE_HOME:-$HOME/.cache}/openshell/test-g
184195
Cache command options:
185196

186197
```text
187-
--distro NAME Base distro: ubuntu, centos, fedora, or rocky
188-
--with NAME Apply docker, podman, or selinux; repeatable
198+
--distro NAME Base distro: ubuntu-24-04, ubuntu-26-04, centos, fedora, or rocky
199+
--with NAME Apply docker, podman-rootless, selinux, or snapd; repeatable
189200
--repository REF OCI repository without a tag
190201
--digest DIGEST Trusted OCI manifest digest required for pulls
191202
--cache-dir PATH Override the local prepared-disk cache directory
@@ -209,7 +220,7 @@ Install the package in an Ubuntu VM and run a command:
209220

210221
```shell
211222
nix run .#test-guest -- \
212-
--distro ubuntu \
223+
--distro ubuntu-24-04 \
213224
--with docker \
214225
--install artifacts/openshell_0.0.0-local_arm64.deb \
215226
-- openshell --version
@@ -226,7 +237,7 @@ guest file preserves the source's ordinary permission bits:
226237

227238
```shell
228239
nix run .#test-guest -- \
229-
--distro ubuntu \
240+
--distro ubuntu-24-04 \
230241
--copy ./openshell:/usr/local/bin/openshell \
231242
-- openshell --version
232243
```
@@ -241,7 +252,7 @@ gateway. On each failure it prints snapd and gateway journals.
241252

242253
```shell
243254
nix run .#test-guest -- \
244-
--distro ubuntu \
255+
--distro ubuntu-24-04 \
245256
--with snapd \
246257
--keep \
247258
--copy ./openshell_*.snap:/tmp/openshell.snap \
@@ -259,8 +270,8 @@ The destination must be an absolute guest path. Copied files are installed with
259270
## Runner options
260271

261272
```text
262-
--distro NAME Base distro: ubuntu, centos, fedora, or rocky
263-
--with NAME Apply docker, podman, or selinux; repeatable
273+
--distro NAME Base distro: ubuntu-24-04, ubuntu-26-04, centos, fedora, or rocky
274+
--with NAME Apply docker, podman-rootless, selinux, or snapd; repeatable
264275
--install PATH Install a .deb or .rpm package; repeatable
265276
--copy SRC:DEST Copy a regular file into the guest, preserving its host mode;
266277
repeatable

‎nix/test-guest/cache.sh‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ Usage:
1212
nix run .#test-guest-cache -- --distro DISTRO [OPTIONS]
1313
1414
Options:
15-
--distro NAME Base distro: ubuntu, centos, fedora, or rocky
16-
--with NAME Apply a configuration; repeatable (docker, podman, selinux)
15+
--distro NAME Base distro: ubuntu-24-04, ubuntu-26-04, centos, fedora, or rocky
16+
--with NAME Apply a configuration; repeatable (docker, podman-rootless, selinux, snapd)
1717
--repository REF OCI repository without a tag
1818
--digest DIGEST Trusted OCI manifest digest required for pulls
1919
--cache-dir PATH Override the local prepared-disk cache directory
@@ -380,7 +380,7 @@ build_local() {
380380
for configuration in "${configurations[@]}"; do
381381
case "${configuration}" in
382382
docker) validation+='; docker info >/dev/null' ;;
383-
podman) validation+='; podman info >/dev/null' ;;
383+
podman-rootless) validation+='; podman info >/dev/null' ;;
384384
selinux) validation+='; test "$(getenforce)" = Enforcing' ;;
385385
esac
386386
done
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
# PROTOTYPE: Configure rootless Podman in a disposable test guest.
6+
7+
- name: Configure rootless Podman
8+
hosts: test_vm
9+
become: true
10+
gather_facts: true
11+
12+
tasks:
13+
- name: Validate rootless Podman support
14+
ansible.builtin.assert:
15+
that:
16+
- >-
17+
ansible_facts.distribution == "Fedora" or
18+
(ansible_facts.distribution == "Ubuntu" and
19+
ansible_facts.distribution_version is version("26.04", ">="))
20+
fail_msg: >-
21+
Rootless Podman requires Fedora or Ubuntu 26.04 or newer, not
22+
{{ ansible_facts.distribution }} {{ ansible_facts.distribution_version }}.
23+
24+
- name: Install common Podman prerequisites
25+
ansible.builtin.import_tasks: tasks/podman-common.yml
26+
27+
- name: Configure rootless Podman on Ubuntu
28+
ansible.builtin.import_tasks: tasks/podman-rootless/ubuntu.yml
29+
when: ansible_facts.distribution == "Ubuntu"
30+
31+
- name: Configure rootless Podman on Fedora
32+
ansible.builtin.import_tasks: tasks/podman-rootless/fedora.yml
33+
when: ansible_facts.distribution == "Fedora"
34+
35+
- name: Configure shared rootless Podman settings
36+
ansible.builtin.import_tasks: tasks/podman-rootless/shared.yml

‎nix/test-guest/configuration/podman.yml‎

Lines changed: 0 additions & 42 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
- name: Refresh Ubuntu package metadata
6+
ansible.builtin.apt:
7+
update_cache: true
8+
when: ansible_facts.distribution == "Ubuntu"
9+
10+
- name: Install Podman
11+
ansible.builtin.package:
12+
name: podman
13+
state: present
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
- name: Install Fedora rootless Podman prerequisites
6+
ansible.builtin.dnf:
7+
name:
8+
- fuse-overlayfs
9+
- passt
10+
- shadow-utils
11+
- shadow-utils-subid
12+
state: present
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
- name: Verify test user subordinate ID mappings
6+
ansible.builtin.command:
7+
argv:
8+
- awk
9+
- "-F:"
10+
- >-
11+
$1 == "openshell" && $2 ~ /^[0-9]+$/ &&
12+
$3 ~ /^[1-9][0-9]*$/ && $3 >= 65536 { found = 1 }
13+
END { exit !found }
14+
- "{{ item }}"
15+
loop:
16+
- /etc/subuid
17+
- /etc/subgid
18+
changed_when: false
19+
20+
- name: Enable the rootless Podman API socket
21+
ansible.builtin.systemd_service:
22+
name: podman.socket
23+
scope: user
24+
enabled: true
25+
state: started
26+
become: false
27+
28+
- name: Verify rootless Podman
29+
ansible.builtin.command:
30+
cmd: podman info
31+
become: false
32+
changed_when: false
33+
34+
- name: Verify rootless Podman mode
35+
ansible.builtin.command:
36+
argv:
37+
- podman
38+
- info
39+
- --format
40+
- "{% raw %}{{.Host.Security.Rootless}}{% endraw %}"
41+
become: false
42+
changed_when: false
43+
register: podman_rootless
44+
failed_when: podman_rootless.stdout != "true"
45+
46+
- name: Verify rootless Podman uses pasta
47+
ansible.builtin.command:
48+
argv:
49+
- podman
50+
- info
51+
- --format
52+
- "{% raw %}{{.Host.RootlessNetworkCmd}}{% endraw %}"
53+
become: false
54+
changed_when: false
55+
register: podman_rootless_network
56+
failed_when: podman_rootless_network.stdout != "pasta"
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
- name: Install Ubuntu rootless Podman prerequisites
6+
ansible.builtin.apt:
7+
name:
8+
- apparmor
9+
- fuse-overlayfs
10+
- passt
11+
- uidmap
12+
state: present
13+
14+
- name: Allow pasta to receive Podman stop signals
15+
ansible.builtin.lineinfile:
16+
path: /etc/apparmor.d/usr.bin.pasta
17+
insertafter: "^ include <abstractions/pasta>$"
18+
line: " signal (receive) peer=podman,"
19+
state: present
20+
register: pasta_apparmor_profile
21+
22+
- name: Reload pasta AppArmor profile
23+
ansible.builtin.command:
24+
argv:
25+
- apparmor_parser
26+
- --replace
27+
- /etc/apparmor.d/usr.bin.pasta
28+
when: pasta_apparmor_profile.changed
29+
changed_when: pasta_apparmor_profile.changed

0 commit comments

Comments
 (0)