1
0
Fork 0
mirror of https://github.com/containers/ansible-podman-collections.git synced 2026-02-03 23:01:48 +00:00
ansible-podman-collections/playbooks/examples/podman_pkg_manage.yml
Sergey 991e461ea5
Rewrite podman and buildah connections (#962)
* Rewrite podman and buildah connections

---------

Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2025-09-11 20:35:09 +03:00

40 lines
1.3 KiB
YAML

---
- name: Install a small package in container with distro autodetect
hosts: all
gather_facts: false
vars:
ansible_connection: containers.podman.podman
tasks:
- name: Detect package manager
raw: >-
sh -lc 'if command -v apk >/dev/null 2>&1; then echo apk; exit 0; fi;
if command -v apt-get >/dev/null 2>&1; then echo apt; exit 0; fi;
if command -v dnf >/dev/null 2>&1; then echo dnf; exit 0; fi;
if command -v yum >/dev/null 2>&1; then echo yum; exit 0; fi;
echo none'
register: pkgmgr
changed_when: false
- name: Install procps or util-linux depending on distro
when: pkgmgr.stdout in ['apk','apt','dnf','yum']
block:
- name: APK install
when: pkgmgr.stdout == 'apk'
raw: "sh -lc 'apk add --no-cache procps'"
- name: APT install
when: pkgmgr.stdout == 'apt'
raw: "sh -lc 'apt-get update && apt-get install -y procps'"
- name: DNF install
when: pkgmgr.stdout == 'dnf'
raw: "sh -lc 'dnf -y install procps-ng'"
- name: YUM install
when: pkgmgr.stdout == 'yum'
raw: "sh -lc 'yum -y install procps-ng'"
- name: Verify tools exist
raw: "sh -lc 'ps --version || true'"