Files

127 lines
3.9 KiB
YAML

---
- 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