GNAI-007: Ansible Rolle zum Installieren von Podman hinzugefügt.

This commit is contained in:
2026-09-20 00:15:28 +02:00
parent de06eb6129
commit 2a2bd2326d
8 changed files with 227 additions and 22 deletions
+13
View File
@@ -138,3 +138,16 @@ inventory and supply the private deployment key outside the repository:
Run the final command a second time. The second recap must report `changed=0`
and `failed=0`; otherwise the role has not demonstrated convergence.
## Podman runtime
The shared host play also installs the Podman runtime from Debian 13. The role
requires systemd and cgroup v2, prepares `/etc/containers/systemd`, verifies the
overlay storage driver and exercises the installed Quadlet generator without
creating a workload.
The role explicitly keeps the Podman API socket and automatic image-update
timer disabled. It pulls no image and does not yet choose rootful or rootless
execution for the two environments. Apply and check it through the same
`playbooks/host.yml` commands shown above. The first run may install packages;
an immediate second run must report `changed=0`.
+1
View File
@@ -10,3 +10,4 @@
roles:
- role: host_baseline
- role: podman_runtime
+20
View File
@@ -0,0 +1,20 @@
# Podman runtime
The `podman_runtime` role installs and verifies the shared container runtime on
`ghostnet-ki`.
The initial scope is intentionally limited:
- install Podman from Debian 13 together with DNS and rootless-network helpers;
- require systemd and cgroup v2;
- create `/etc/containers/systemd` for future system Quadlets;
- keep the Podman API socket and automatic image-update timer disabled;
- verify Podman version, cgroup mode, the overlay storage driver and the
executable Quadlet generator; and
- run the Quadlet generator in dry-run mode without defining a workload.
The role does not pull images or create Production and Testing containers. It
also does not yet
choose between rootful system Quadlets and separate rootless service accounts.
That decision belongs to the environment design because it affects GPU access,
filesystem ownership and deployment privileges.
@@ -0,0 +1,15 @@
---
podman_runtime_packages:
- podman
- aardvark-dns
- passt
- slirp4netns
- uidmap
podman_runtime_minimum_major_version: 5
podman_runtime_quadlet_directory: /etc/containers/systemd
podman_runtime_generator_path: /usr/lib/systemd/system-generators/podman-system-generator
podman_runtime_disabled_units:
- podman.socket
- podman-auto-update.timer
+126
View File
@@ -0,0 +1,126 @@
---
- name: Verify the supported operating system and init system
ansible.builtin.assert:
that:
- ansible_facts["distribution"] == "Debian"
- ansible_facts["distribution_major_version"] == "13"
- ansible_facts["service_mgr"] == "systemd"
fail_msg: >-
The Podman runtime role currently supports only Debian 13 with systemd.
- name: Read the host cgroup filesystem type
ansible.builtin.command:
argv:
- /usr/bin/stat
- -fc
- "%T"
- /sys/fs/cgroup
check_mode: false
changed_when: false
register: podman_runtime_cgroup_filesystem
- name: Require cgroup v2 before installing Podman
ansible.builtin.assert:
that:
- podman_runtime_cgroup_filesystem.stdout == "cgroup2fs"
fail_msg: >-
Podman Quadlet requires cgroup v2, but /sys/fs/cgroup is not cgroup2fs.
- name: Install the Podman runtime and rootless networking prerequisites
ansible.builtin.apt:
name: "{{ podman_runtime_packages }}"
state: present
update_cache: true
cache_valid_time: 3600
install_recommends: false
- name: Create the system Quadlet directory
ansible.builtin.file:
path: "{{ podman_runtime_quadlet_directory }}"
state: directory
owner: root
group: root
mode: "0755"
- name: Keep the Podman API and automatic image updates disabled
ansible.builtin.systemd_service:
name: "{{ item }}"
enabled: false
state: stopped
loop: "{{ podman_runtime_disabled_units }}"
when: not ansible_check_mode
- name: Inspect the installed Quadlet generator
ansible.builtin.stat:
path: "{{ podman_runtime_generator_path }}"
follow: true
register: podman_runtime_generator
when: not ansible_check_mode
- name: Verify the installed Quadlet generator
ansible.builtin.assert:
that:
- podman_runtime_generator.stat.exists
- podman_runtime_generator.stat.isreg
- podman_runtime_generator.stat.executable
fail_msg: The Podman system generator is missing or not executable.
when: not ansible_check_mode
- name: Read Podman runtime information
ansible.builtin.command:
argv:
- /usr/bin/podman
- info
- --format=json
changed_when: false
register: podman_runtime_info_command
when: not ansible_check_mode
- name: Read the installed Podman version
ansible.builtin.command:
argv:
- /usr/bin/podman
- version
- --format=json
changed_when: false
register: podman_runtime_version_command
when: not ansible_check_mode
- name: Parse Podman runtime information
ansible.builtin.set_fact:
podman_runtime_info: "{{ podman_runtime_info_command.stdout | from_json }}"
podman_runtime_version: "{{ podman_runtime_version_command.stdout | from_json }}"
when: not ansible_check_mode
- name: Verify the Podman runtime
ansible.builtin.assert:
that:
- >-
podman_runtime_version["Client"]["Version"].split(".")[0] | int >=
podman_runtime_minimum_major_version | int
- podman_runtime_info["host"]["cgroupVersion"] == "v2"
- podman_runtime_info["store"]["graphDriverName"] == "overlay"
fail_msg: >-
Podman is installed, but its version, cgroup mode or storage driver does
not match the declared runtime baseline.
when: not ansible_check_mode
- name: Exercise the Quadlet generator without defining a workload
ansible.builtin.command:
argv:
- "{{ podman_runtime_generator_path }}"
- --dryrun
environment:
QUADLET_UNIT_DIRS: "{{ podman_runtime_quadlet_directory }}"
changed_when: false
when: not ansible_check_mode
- name: Report the verified Podman runtime
ansible.builtin.debug:
msg:
version: "{{ podman_runtime_version['Client']['Version'] }}"
cgroup_version: "{{ podman_runtime_info['host']['cgroupVersion'] }}"
storage_driver: "{{ podman_runtime_info['store']['graphDriverName'] }}"
quadlet_generator: "{{ podman_runtime_generator_path }}"
disabled_units: "{{ podman_runtime_disabled_units }}"
when: not ansible_check_mode