containers / ansible-podman-collections

Repository for Ansible content that can include playbooks, roles, modules, and plugins for use with the Podman tool
GNU General Public License v3.0
263 stars 142 forks source link

padman_load image is not idempotent (?) #845

Open DavidJaeck opened 2 weeks ago

DavidJaeck commented 2 weeks ago

Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)

/kind bug

Description

I am not sure if this is a bug, or if I am using the module incorrectly. I am loading an image with podman_load. The load is successful, however the changed when status and sdt error lines seem incorrect. If I import the image twice I would expect the status to be "changed": false and I would expect the error line to state blobs are skipped because they already exist. However there always appears to be a change since the module is never realizing the blobs are already existent and can be skipped.

Steps to reproduce the issue:

1. ansible-playbook testplaybook.yml with file content

Describe the results you received: I receive status "changed": true and stderror lines

    "stderr_lines": [
        "Getting image source signatures",
        "Copying blob sha256:d62a02444d39e0408f390b5531241920618333b50d589215edb5e90a4d24f457",
        "Copying blob sha256:869cfd058ffa32f9eec431858ea3b2ee81dfb2b54aee5d6fd9c8cb7ceb1d124f",
        "Copying blob sha256:ad8eea1b3abbc95376e6f000f607766823d67054f4b0c078c63af2787ee03b8e",
        "Copying config sha256:d25945831d6b8935b016caacc6f612ad4876ba124601b240e64953886cf264b4",
        "Writing manifest to image destination"
    ],

Describe the results you expected: I receive "changed": false and sdterror lines along the lines of

Getting image source signatures
Copying blob d62a02444d39 skipped: already exists  
Copying blob 869cfd058ffa skipped: already exists  
Copying blob ad8eea1b3abb skipped: already exists  
Copying config d25945831d done   | 
Writing manifest to image destination
Loaded image: docker.io/library/eclipse-mosquitto:2.0.18

Additional information you deem important (e.g. issue happens only occasionally):

Version of the containers.podman collection: Either git commit if installed from git: git show --summary Or version from ansible-galaxy if installed from galaxy: ansible-galaxy collection list | grep containers.podman

ansible-galaxy collection list | grep containers.podman
containers.podman             1.10.2

Output of ansible --version:

ansible --version
ansible [core 2.14.14]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/admin/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.9/site-packages/ansible
  ansible collection location = /home/admin/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.9.18 (main, Aug 23 2024, 00:00:00) [GCC 11.4.1 20231218 (Red Hat 11.4.1-3)] (/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True

Output of podman version:

podman version
Client:       Podman Engine
Version:      4.9.4-rhel
API Version:  4.9.4-rhel
Go Version:   go1.21.11 (Red Hat 1.21.11-1.el9_4)
Built:        Wed Sep  4 11:34:43 2024
OS/Arch:      linux/amd64

Output of podman info --debug:

podman info --debug
host:
  arch: amd64
  buildahVersion: 1.33.8
  cgroupControllers:
  - memory
  - pids
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: conmon-2.1.10-1.el9.x86_64
    path: /usr/bin/conmon
    version: 'conmon version 2.1.10, commit: 3ea3d7f99779af0fcd69ec16c211a7dc3b4efb60'
  cpuUtilization:
    idlePercent: 98.75
    systemPercent: 0.18
    userPercent: 1.07
  cpus: 6
  databaseBackend: sqlite
  distribution:
    distribution: rocky
    version: "9.4"
  eventLogger: journald
  freeLocks: 2048
  hostname: 027-003POS01
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 1001
      size: 1
    - container_id: 1
      host_id: 165536
      size: 65536
    uidmap:
    - container_id: 0
      host_id: 1001
      size: 1
    - container_id: 1
      host_id: 165536
      size: 65536
  kernel: 5.14.0-427.35.1.el9_4.x86_64
  linkmode: dynamic
  logDriver: journald
  memFree: 5166227456
  memTotal: 7922954240
  networkBackend: netavark
  networkBackendInfo:
    backend: netavark
    dns:
      package: aardvark-dns-1.10.0-3.el9_4.x86_64
      path: /usr/libexec/podman/aardvark-dns
      version: aardvark-dns 1.10.0
    package: netavark-1.10.3-1.el9.x86_64
    path: /usr/libexec/podman/netavark
    version: netavark 1.10.3
  ociRuntime:
    name: crun
    package: crun-1.14.3-1.el9.x86_64
    path: /usr/bin/crun
    version: |-
      crun version 1.14.3
      commit: 1961d211ba98f532ea52d2e80f4c20359f241a98
      rundir: /run/user/1001/crun
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +YAJL
  os: linux
  pasta:
    executable: ""
    package: ""
    version: ""
  remoteSocket:
    exists: false
    path: /run/user/1001/podman/podman.sock
  security:
    apparmorEnabled: false
    capabilities: CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT
    rootless: true
    seccompEnabled: true
    seccompProfilePath: /usr/share/containers/seccomp.json
    selinuxEnabled: true
  serviceIsRemote: false
  slirp4netns:
    executable: /usr/bin/slirp4netns
    package: slirp4netns-1.2.3-1.el9.x86_64
    version: |-
      slirp4netns version 1.2.3
      commit: c22fde291bb35b354e6ca44d13be181c76a0a432
      libslirp: 4.4.0
      SLIRP_CONFIG_VERSION_MAX: 3
      libseccomp: 2.5.2
  swapFree: 4294963200
  swapTotal: 4294963200
  uptime: 4h 31m 49.00s (Approximately 0.17 days)
  variant: ""
plugins:
  authorization: null
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  - ipvlan
  volume:
  - local
registries:
  search:
  - registry.access.redhat.com
  - registry.redhat.io
  - docker.io
store:
  configFile: /home/admin/.config/containers/storage.conf
  containerStore:
    number: 0
    paused: 0
    running: 0
    stopped: 0
  graphDriverName: overlay
  graphOptions: {}
  graphRoot: /home/admin/.local/share/containers/storage
  graphRootAllocated: 10464022528
  graphRootUsed: 20426752
  graphStatus:
    Backing Filesystem: extfs
    Native Overlay Diff: "true"
    Supports d_type: "true"
    Supports shifting: "false"
    Supports volatile: "true"
    Using metacopy: "false"
  imageCopyTmpDir: /var/tmp
  imageStore:
    number: 0
  runRoot: /run/user/1001/containers
  transientStore: false
  volumePath: /home/admin/.local/share/containers/storage/volumes
version:
  APIVersion: 4.9.4-rhel
  Built: 1725442483
  BuiltTime: Wed Sep  4 11:34:43 2024
  GitCommit: ""
  GoVersion: go1.21.11 (Red Hat 1.21.11-1.el9_4)
  Os: linux
  OsArch: linux/amd64
  Version: 4.9.4-rhel

Package info (e.g. output of rpm -q podman or apt list podman):

rpm -qi podman
Name        : podman
Epoch       : 4
Version     : 4.9.4
Release     : 10.el9_4
Architecture: x86_64
Install Date: Wed 18 Sep 2024 12:16:29 PM CEST
Group       : Unspecified
Size        : 55307073
License     : Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND ISC AND MIT AND MPL-2.0
Signature   : RSA/SHA256, Wed 04 Sep 2024 12:00:11 PM CEST, Key ID 702d426d350d275d
Source RPM  : podman-4.9.4-10.el9_4.src.rpm
Build Date  : Wed 04 Sep 2024 11:34:32 AM CEST
Build Host  : pb-6836cfe6-91cc-4ab9-9089-71a9452dfa06-b-x86-64
Packager    : Rocky Linux Build System (Peridot) <releng@rockylinux.org>
Vendor      : Rocky Enterprise Software Foundation
URL         : https://podman.io/
Summary     : Manage Pods, Containers and Container Images
Description :
podman (Pod Manager) is a fully featured container engine that is a simple
daemonless tool.  podman provides a Docker-CLI comparable command line that
eases the transition from other container engines and allows the management of
pods, containers and images.  Simply put: alias docker=podman.
Most podman commands can be run as a regular user, without requiring
additional privileges.

podman uses Buildah(1) internally to create container images.
Both tools share image (not container) storage, hence each can use or
manipulate images (but not containers) created by the other.

Manage Pods, Containers and Container Images
podman Simple management tool for pods, containers and images

Playbok you run with ansible (e.g. content of playbook.yaml):

- name: Testplaybook
  hosts: localhost
  tasks:
    - name: Load mosquitto image tar
      containers.podman.podman_load:
        input: eclipse-mosquitto-2.0.18.tar 

Command line and output of ansible run with high verbosity

Please NOTE: if you submit a bug about idempotency, run the playbook with --diff option, like:

ansible-playbook -i inventory --diff -vv playbook.yml

ansible-playbook main.yml --diff -vvv
ansible-playbook [core 2.14.14]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.9/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /bin/ansible-playbook
  python version = 3.9.18 (main, Aug 23 2024, 00:00:00) [GCC 11.4.1 20231218 (Red Hat 11.4.1-3)] (/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True
Using /etc/ansible/ansible.cfg as config file
host_list declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
script declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
auto declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Parsed /etc/ansible/hosts inventory source with ini plugin
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.

PLAYBOOK: main.yml ***********************************************************************************************************************************************************************************************************************************************************************************************************
1 plays in main.yml

PLAY [CHO System Configuration Playbook] *************************************************************************************************************************************************************************************************************************************************************************************

TASK [Gathering Facts] *******************************************************************************************************************************************************************************************************************************************************************************************************
task path: /home/admin/main.yml:1
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: root
<127.0.0.1> EXEC /bin/sh -c 'echo ~root && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp `"&& mkdir "` echo /root/.ansible/tmp/ansible-tmp-1726670253.6179328-74606-125924378221881 `" && echo ansible-tmp-1726670253.6179328-74606-125924378221881="` echo /root/.ansible/tmp/ansible-tmp-1726670253.6179328-74606-125924378221881 `" ) && sleep 0'
Using module file /usr/lib/python3.9/site-packages/ansible/modules/setup.py
<127.0.0.1> PUT /root/.ansible/tmp/ansible-local-7460292qbu_73/tmpxkal0hja TO /root/.ansible/tmp/ansible-tmp-1726670253.6179328-74606-125924378221881/AnsiballZ_setup.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1726670253.6179328-74606-125924378221881/ /root/.ansible/tmp/ansible-tmp-1726670253.6179328-74606-125924378221881/AnsiballZ_setup.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python3 /root/.ansible/tmp/ansible-tmp-1726670253.6179328-74606-125924378221881/AnsiballZ_setup.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1726670253.6179328-74606-125924378221881/ > /dev/null 2>&1 && sleep 0'
ok: [localhost]

TASK [Load latest mosquitto image tar that is importable] ********************************************************************************************************************************************************************************************************************************************************************
task path: /home/admin/main.yml:30
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: root
<127.0.0.1> EXEC /bin/sh -c 'echo ~root && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp `"&& mkdir "` echo /root/.ansible/tmp/ansible-tmp-1726670254.567338-74677-274970715915782 `" && echo ansible-tmp-1726670254.567338-74677-274970715915782="` echo /root/.ansible/tmp/ansible-tmp-1726670254.567338-74677-274970715915782 `" ) && sleep 0'
Using module file /usr/lib/python3.9/site-packages/ansible_collections/containers/podman/plugins/modules/podman_load.py
<127.0.0.1> PUT /root/.ansible/tmp/ansible-local-7460292qbu_73/tmpuxds2pt0 TO /root/.ansible/tmp/ansible-tmp-1726670254.567338-74677-274970715915782/AnsiballZ_podman_load.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1726670254.567338-74677-274970715915782/ /root/.ansible/tmp/ansible-tmp-1726670254.567338-74677-274970715915782/AnsiballZ_podman_load.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python3 /root/.ansible/tmp/ansible-tmp-1726670254.567338-74677-274970715915782/AnsiballZ_podman_load.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1726670254.567338-74677-274970715915782/ > /dev/null 2>&1 && sleep 0'
changed: [localhost] => {
    "changed": true,
    "image": {
        "Annotations": {},
        "Architecture": "amd64",
        "Author": "",
        "Comment": "",
        "Config": {
            "ArgsEscaped": true,
            "Cmd": [
                "/usr/sbin/mosquitto",
                "-c",
                "/mosquitto/config/mosquitto.conf"
            ],
            "Entrypoint": [
                "/docker-entrypoint.sh"
            ],
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "VERSION=2.0.18",
                "DOWNLOAD_SHA256=d665fe7d0032881b1371a47f34169ee4edab67903b2cd2b4c083822823f4448a",
                "GPG_KEYS=A0D6EEA1DCAE49A635A3B2F0779B22DFB3E717B7",
                "LWS_VERSION=4.2.1",
                "LWS_SHA256=842da21f73ccba2be59e680de10a8cce7928313048750eb6ad73b6fa50763c51"
            ],
            "ExposedPorts": {
                "1883/tcp": {}
            },
            "Labels": {
                "description": "Eclipse Mosquitto MQTT Broker",
                "maintainer": "Roger Light <roger@atchoo.org>"
            },
            "Volumes": {
                "/mosquitto/data": {},
                "/mosquitto/log": {}
            }
        },
        "Created": "2023-09-18T21:32:22Z",
        "Digest": "sha256:ff945f4c19584086d56b61379c0bad5b04b0c2f609c90f1209e845e0d7394475",
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/containers/storage/overlay/45f029c2c25f68e45ae4a5c94035e52a73c2de81c10ac5e45ab03ad4c1ce09e6/diff:/var/lib/containers/storage/overlay/d62a02444d39e0408f390b5531241920618333b50d589215edb5e90a4d24f457/diff",
                "UpperDir": "/var/lib/containers/storage/overlay/fc4e6de9cb8fad4e564a9a8654cbe640c57408a06b793a6f07fefdb1d7a0c833/diff",
                "WorkDir": "/var/lib/containers/storage/overlay/fc4e6de9cb8fad4e564a9a8654cbe640c57408a06b793a6f07fefdb1d7a0c833/work"
            },
            "Name": "overlay"
        },
        "History": [
            {
                "created": "2023-09-18T21:32:22Z",
                "created_by": "/bin/sh -c #(nop) ADD file:5dd525c57625a3a84d57d435b3c255f417ad1722250faaf006c66b9090207f66 in / "
            },
            {
                "created": "2023-09-18T21:32:22Z",
                "created_by": "/bin/sh -c #(nop)  CMD [\"/bin/sh\"]",
                "empty_layer": true
            },
            {
                "comment": "buildkit.dockerfile.v0",
                "created": "2023-09-18T21:32:22Z",
                "created_by": "LABEL maintainer=Roger Light <roger@atchoo.org> description=Eclipse Mosquitto MQTT Broker",
                "empty_layer": true
            },
            {
                "comment": "buildkit.dockerfile.v0",
                "created": "2023-09-18T21:32:22Z",
                "created_by": "ENV VERSION=2.0.18 DOWNLOAD_SHA256=d665fe7d0032881b1371a47f34169ee4edab67903b2cd2b4c083822823f4448a GPG_KEYS=A0D6EEA1DCAE49A635A3B2F0779B22DFB3E717B7 LWS_VERSION=4.2.1 LWS_SHA256=842da21f73ccba2be59e680de10a8cce7928313048750eb6ad73b6fa50763c51",
                "empty_layer": true
            },
            {
                "comment": "buildkit.dockerfile.v0",
                "created": "2023-09-18T21:32:22Z",
                "created_by": "RUN /bin/sh -c set -x &&     apk --no-cache add --virtual build-deps         build-base         cmake         cjson-dev         gnupg         libressl-dev         linux-headers         util-linux-dev &&     wget https://github.com/warmcat/libwebsockets/archive/v${LWS_VERSION}.tar.gz -O /tmp/lws.tar.gz &&     echo \"$LWS_SHA256  /tmp/lws.tar.gz\" | sha256sum -c - &&     mkdir -p /build/lws &&     tar --strip=1 -xf /tmp/lws.tar.gz -C /build/lws &&     rm /tmp/lws.tar.gz &&     cd /build/lws &&     cmake .         -DCMAKE_BUILD_TYPE=MinSizeRel         -DCMAKE_INSTALL_PREFIX=/usr         -DDISABLE_WERROR=ON         -DLWS_IPV6=ON         -DLWS_WITHOUT_BUILTIN_GETIFADDRS=ON         -DLWS_WITHOUT_CLIENT=ON         -DLWS_WITHOUT_EXTENSIONS=ON         -DLWS_WITHOUT_TESTAPPS=ON         -DLWS_WITH_EXTERNAL_POLL=ON         -DLWS_WITH_HTTP2=OFF         -DLWS_WITH_SHARED=OFF         -DLWS_WITH_ZIP_FOPS=OFF         -DLWS_WITH_ZLIB=OFF &&     make -j \"$(nproc)\" &&     rm -rf /root/.cmake &&     wget https://mosquitto.org/files/source/mosquitto-${VERSION}.tar.gz -O /tmp/mosq.tar.gz &&     echo \"$DOWNLOAD_SHA256  /tmp/mosq.tar.gz\" | sha256sum -c - &&     wget https://mosquitto.org/files/source/mosquitto-${VERSION}.tar.gz.asc -O /tmp/mosq.tar.gz.asc &&     export GNUPGHOME=\"$(mktemp -d)\" &&     found='';     for server in         hkps://keys.openpgp.org         hkp://keyserver.ubuntu.com:80         pgp.mit.edu     ; do         echo \"Fetching GPG key $GPG_KEYS from $server\";         gpg --keyserver \"$server\" --keyserver-options timeout=10 --recv-keys \"$GPG_KEYS\" && found=yes && break;     done;     test -z \"$found\" && echo >&2 \"error: failed to fetch GPG key $GPG_KEYS\" && exit 1;     gpg --batch --verify /tmp/mosq.tar.gz.asc /tmp/mosq.tar.gz &&     gpgconf --kill all &&     rm -rf \"$GNUPGHOME\" /tmp/mosq.tar.gz.asc &&     mkdir -p /build/mosq &&     tar --strip=1 -xf /tmp/mosq.tar.gz -C /build/mosq &&     rm /tmp/mosq.tar.gz &&     make -C /build/mosq -j \"$(nproc)\"         CFLAGS=\"-Wall -O2 -I/build/lws/include -I/build\"         LDFLAGS=\"-L/build/lws/lib\"         WITH_ADNS=no         WITH_DOCS=no         WITH_SHARED_LIBRARIES=yes         WITH_SRV=no         WITH_STRIP=yes         WITH_TLS_PSK=no         WITH_WEBSOCKETS=yes         prefix=/usr         binary &&     addgroup -S -g 1883 mosquitto 2>/dev/null &&     adduser -S -u 1883 -D -H -h /var/empty -s /sbin/nologin -G mosquitto -g mosquitto mosquitto 2>/dev/null &&     mkdir -p /mosquitto/config /mosquitto/data /mosquitto/log &&     install -d /usr/sbin/ &&     install -s -m755 /build/mosq/client/mosquitto_pub /usr/bin/mosquitto_pub &&     install -s -m755 /build/mosq/client/mosquitto_rr /usr/bin/mosquitto_rr &&     install -s -m755 /build/mosq/client/mosquitto_sub /usr/bin/mosquitto_sub &&     install -s -m644 /build/mosq/lib/libmosquitto.so.1 /usr/lib/libmosquitto.so.1 &&     install -s -m755 /build/mosq/src/mosquitto /usr/sbin/mosquitto &&     install -s -m755 /build/mosq/apps/mosquitto_ctrl/mosquitto_ctrl /usr/bin/mosquitto_ctrl &&     install -s -m755 /build/mosq/apps/mosquitto_passwd/mosquitto_passwd /usr/bin/mosquitto_passwd &&     install -s -m755 /build/mosq/plugins/dynamic-security/mosquitto_dynamic_security.so /usr/lib/mosquitto_dynamic_security.so &&     install -m644 /build/mosq/mosquitto.conf /mosquitto/config/mosquitto.conf &&     install -Dm644 /build/lws/LICENSE /usr/share/licenses/libwebsockets/LICENSE &&     install -Dm644 /build/mosq/epl-v20 /usr/share/licenses/mosquitto/epl-v20 &&     install -Dm644 /build/mosq/edl-v10 /usr/share/licenses/mosquitto/edl-v10 &&     chown -R mosquitto:mosquitto /mosquitto &&     apk --no-cache add         ca-certificates         cjson         libressl &&     apk del build-deps &&     rm -rf /build # buildkit"
            },
            {
                "comment": "buildkit.dockerfile.v0",
                "created": "2023-09-18T21:32:22Z",
                "created_by": "VOLUME [/mosquitto/data /mosquitto/log]",
                "empty_layer": true
            },
            {
                "comment": "buildkit.dockerfile.v0",
                "created": "2023-09-18T21:32:22Z",
                "created_by": "COPY docker-entrypoint.sh mosquitto-no-auth.conf / # buildkit"
            },
            {
                "comment": "buildkit.dockerfile.v0",
                "created": "2023-09-18T21:32:22Z",
                "created_by": "EXPOSE map[1883/tcp:{}]",
                "empty_layer": true
            },
            {
                "comment": "buildkit.dockerfile.v0",
                "created": "2023-09-18T21:32:22Z",
                "created_by": "ENTRYPOINT [\"/docker-entrypoint.sh\"]",
                "empty_layer": true
            },
            {
                "comment": "buildkit.dockerfile.v0",
                "created": "2023-09-18T21:32:22Z",
                "created_by": "CMD [\"/usr/sbin/mosquitto\" \"-c\" \"/mosquitto/config/mosquitto.conf\"]",
                "empty_layer": true
            }
        ],
        "Id": "d25945831d6b8935b016caacc6f612ad4876ba124601b240e64953886cf264b4",
        "Labels": {
            "description": "Eclipse Mosquitto MQTT Broker",
            "maintainer": "Roger Light <roger@atchoo.org>"
        },
        "ManifestType": "application/vnd.oci.image.manifest.v1+json",
        "NamesHistory": [
            "docker.io/library/eclipse-mosquitto:2.0.18"
        ],
        "Os": "linux",
        "Parent": "",
        "RepoDigests": [
            "docker.io/library/eclipse-mosquitto@sha256:ff945f4c19584086d56b61379c0bad5b04b0c2f609c90f1209e845e0d7394475"
        ],
        "RepoTags": [
            "docker.io/library/eclipse-mosquitto:2.0.18"
        ],
        "RootFS": {
            "Layers": [
                "sha256:d62a02444d39e0408f390b5531241920618333b50d589215edb5e90a4d24f457",
                "sha256:869cfd058ffa32f9eec431858ea3b2ee81dfb2b54aee5d6fd9c8cb7ceb1d124f",
                "sha256:ad8eea1b3abbc95376e6f000f607766823d67054f4b0c078c63af2787ee03b8e"
            ],
            "Type": "layers"
        },
        "Size": 13916779,
        "User": "",
        "Version": "",
        "VirtualSize": 13916779
    },
    "invocation": {
        "module_args": {
            "executable": "podman",
            "input": "eclipse-mosquitto-2.0.18.tar"
        }
    },
    "stderr": "Getting image source signatures\nCopying blob sha256:d62a02444d39e0408f390b5531241920618333b50d589215edb5e90a4d24f457\nCopying blob sha256:869cfd058ffa32f9eec431858ea3b2ee81dfb2b54aee5d6fd9c8cb7ceb1d124f\nCopying blob sha256:ad8eea1b3abbc95376e6f000f607766823d67054f4b0c078c63af2787ee03b8e\nCopying config sha256:d25945831d6b8935b016caacc6f612ad4876ba124601b240e64953886cf264b4\nWriting manifest to image destination\n",
    "stderr_lines": [
        "Getting image source signatures",
        "Copying blob sha256:d62a02444d39e0408f390b5531241920618333b50d589215edb5e90a4d24f457",
        "Copying blob sha256:869cfd058ffa32f9eec431858ea3b2ee81dfb2b54aee5d6fd9c8cb7ceb1d124f",
        "Copying blob sha256:ad8eea1b3abbc95376e6f000f607766823d67054f4b0c078c63af2787ee03b8e",
        "Copying config sha256:d25945831d6b8935b016caacc6f612ad4876ba124601b240e64953886cf264b4",
        "Writing manifest to image destination"
    ],
    "stdout": "Loaded image: docker.io/library/eclipse-mosquitto:2.0.18\n",
    "stdout_lines": [
        "Loaded image: docker.io/library/eclipse-mosquitto:2.0.18"
    ]
}

PLAY RECAP *******************************************************************************************************************************************************************************************************************************************************************************************************************
localhost                  : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0 

Additional environment details (AWS, VirtualBox, physical, etc.): physical

sshnaidm commented 1 week ago

@DavidJaeck yes, it's not idempotent, since Podman always loads the image and doesn't provide any indication whether it's already loaded or not. Probably it even can't say without loading it :shrug: We can't do here anything, unless you have ideas how to do it.

DavidJaeck commented 1 week ago

@sshnaidm I can confirm there is an issue with subprocess.run(['podman', 'load', '--input', 'hello-world.tar'], capture_output=True, text=True) podman usually returns [david@cmt381428759805 modules]$ podman load --input hello-world.tar Getting image source signatures Copying blob 2114fc8b7058 skipped: already exists Copying config 5dd467fce5 done | Writing manifest to image destination Loaded image: quay.io/podman/hello:latest The module sh does not seem to be affected by this issue:

import sh
output = sh.podman("load", "-i", "hello-world.tar", _ok_code=[0, 1], _err_to_out=True)  # Merge stderr with stdout
print("Output:", output)
>>>Output: Getting image source signatures
Copying blob 2114fc8b7058 skipped: already exists  
Copying config 5dd467fce5 done   | 
Writing manifest to image destination
Loaded image: quay.io/podman/hello:latest`
Maybe there is something in the enviroment of subprocess.run
I don't know what the implications of using sh.podman would be
sshnaidm commented 1 week ago

@DavidJaeck sorry, I'm not sure what you mean. Can you elaborate please?

DavidJaeck commented 1 week ago

The cmd stderr for /bin/bash podman load --input hello-world.tar contains messages like Copying blob 2114fc8b7058 skipped: already exists The cmd stderr in python for subprocess.run(['podman', 'load', '--input', 'hello-world.tar'], capture_output=True, text=True) does not contain any hints on whether the image was changed - it only contains lines like Copying blob sha256:869cfd058ffa32f9eec431858ea3b2ee81dfb2b54aee5d6fd9c8cb7ceb1d124f The cmd stderr in python for output = sh.podman("load", "-i", "hello-world.tar", _ok_code=[0, 1], _err_to_out=True) just like the standard shell invocation contains: Copying blob 2114fc8b7058 skipped: already exists

So there is an issue with subprocess.run Somehow one might get around it. Apparently using sh is not a viable alternative since it is not supported on windows.

sshnaidm commented 1 week ago

@DavidJaeck OK, but how is it related to idempotency? Firstly, the blob is not the image, it's fine to have existing blobs when you are loading the completely new image. The output still doesn't tell you if it was there before or not. Secondly, you anyway need to load it to see.