1
0
Fork 0
mirror of https://github.com/containers/ansible-podman-collections.git synced 2026-02-04 07:11:49 +00:00

Rewrite podman and buildah connections (#962)

* Rewrite podman and buildah connections

---------

Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
This commit is contained in:
Sergey 2025-09-11 20:35:09 +03:00 committed by GitHub
parent 237bc385b9
commit 991e461ea5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
38 changed files with 2966 additions and 344 deletions

View file

@ -0,0 +1,40 @@
---
- 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'"