CT-102 Keycloak: Migration nach Podman und Ansible abgeschlossen und gehärtet.
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
# Shared control-node dependency pin for all host-scoped Ansible projects.
|
||||
# ansible-core 2.21 supports Python 3.12 through 3.14 on the control node.
|
||||
ansible-core==2.21.4
|
||||
@@ -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
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user