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
264 stars 142 forks source link

`AttributeError: 'list' object has no attribute 'get'` trying to use collection on recent Fedora (podman 5.0?) #712

Closed AdamWill closed 7 months ago

AdamWill commented 7 months ago

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

/kind bug

Description

Trying to run an ansible-podman-based playbook which I've run many times without issue today, I ran into this:

TASK [podman : Create the pod] ***************************************************************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'list' object has no attribute 'get'
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"/home/adamw/.ansible/tmp/ansible-tmp-1708044954.3806355-449558-182177222046668/AnsiballZ_podman_pod.py\", line 107, in <module>\n    _ansiballz_main()\n  File \"/home/adamw/.ansible/tmp/ansible-tmp-1708044954.3806355-449558-182177222046668/AnsiballZ_podman_pod.py\", line 99, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/home/adamw/.ansible/tmp/ansible-tmp-1708044954.3806355-449558-182177222046668/AnsiballZ_podman_pod.py\", line 47, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.containers.podman.plugins.modules.podman_pod', init_globals=dict(_module_fqn='ansible_collections.containers.podman.plugins.modules.podman_pod', _modlib_path=modlib_path),\n  File \"<frozen runpy>\", line 226, in run_module\n  File \"<frozen runpy>\", line 98, in _run_module_code\n  File \"<frozen runpy>\", line 88, in _run_code\n  File \"/tmp/ansible_containers.podman.podman_pod_payload_mgywsscc/ansible_containers.podman.podman_pod_payload.zip/ansible_collections/containers/podman/plugins/modules/podman_pod.py\", line 466, in <module>\n  File \"/tmp/ansible_containers.podman.podman_pod_payload_mgywsscc/ansible_containers.podman.podman_pod_payload.zip/ansible_collections/containers/podman/plugins/modules/podman_pod.py\", line 461, in main\n  File \"/tmp/ansible_containers.podman.podman_pod_payload_mgywsscc/ansible_containers.podman.podman_pod_payload.zip/ansible_collections/containers/podman/plugins/module_utils/podman/podman_pod_lib.py\", line 830, in execute\n  File \"/tmp/ansible_containers.podman.podman_pod_payload_mgywsscc/ansible_containers.podman.podman_pod_payload.zip/ansible_collections/containers/podman/plugins/module_utils/podman/podman_pod_lib.py\", line 884, in make_started\n  File \"/tmp/ansible_containers.podman.podman_pod_payload_mgywsscc/ansible_containers.podman.podman_pod_payload.zip/ansible_collections/containers/podman/plugins/module_utils/podman/podman_pod_lib.py\", line 837, in _create_or_recreate_pod\n  File \"/tmp/ansible_containers.podman.podman_pod_payload_mgywsscc/ansible_containers.podman.podman_pod_payload.zip/ansible_collections/containers/podman/plugins/module_utils/podman/podman_pod_lib.py\", line 617, in different\n  File \"/tmp/ansible_containers.podman.podman_pod_payload_mgywsscc/ansible_containers.podman.podman_pod_payload.zip/ansible_collections/containers/podman/plugins/module_utils/podman/podman_pod_lib.py\", line 568, in is_different\n  File \"/tmp/ansible_containers.podman.podman_pod_payload_mgywsscc/ansible_containers.podman.podman_pod_payload.zip/ansible_collections/containers/podman/plugins/module_utils/podman/podman_pod_lib.py\", line 368, in diffparam_cgroup_parent\nAttributeError: 'list' object has no attribute 'get'\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

You can make that a bit more intelligible by replacing the "\n"s with literal newlines, it boils down to:

  File \"/tmp/ansible_containers.podman.podman_pod_payload_mgywsscc/ansible_containers.podman.podman_pod_payload.zip/ansible_collections/containers/podman/plugins/module_utils/podman/podman_pod_lib.py\", line 368, in diffparam_cgroup_parent
AttributeError: 'list' object has no attribute 'get'

the step that fails is just this:

- name: Create the pod
  containers.podman.podman_pod:
    name: bodhi-dev
    state: started
    publish:
      - "6543:6543"
      - "6544:6544"
      - "6545:6545"
      - "6546:6546"
      - "15672:15672"

Steps to reproduce the issue:

  1. Install a recent Fedora 40 or 41, probably with podman-5.0.0~rc1-1.fc40 or newer (or, I guess, deploy podman 5.0.0 rc1 however you like)
  2. Try and run a play with a straightforward containers.podman.podman_pod in it, as above

Describe the results you received: Boom! Traceback!

Describe the results you expected: A pod.

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

Neither of the above, it's included in Fedora's ansible package, ansible-9.2.0-1.fc40.noarch. Code seems the same as current git head.

Output of ansible --version:

ansible [core 2.16.3]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/adamw/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.12/site-packages/ansible
  ansible collection location = /home/adamw/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.12.2 (main, Feb  7 2024, 00:00:00) [GCC 14.0.1 20240127 (Red Hat 14.0.1-0)] (/usr/bin/python3)
  jinja version = 3.1.3
  libyaml = True

Output of podman version:

Client:       Podman Engine
Version:      5.0.0-rc1
API Version:  5.0.0-rc1
Go Version:   go1.22rc2
Built:        Fri Feb  9 05:36:54 2024
OS/Arch:      linux/amd64

Output of podman info --debug:

host:
  arch: amd64
  buildahVersion: 1.34.1-dev
  cgroupControllers:
  - cpu
  - io
  - memory
  - pids
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: conmon-2.1.8-4.fc40.x86_64
    path: /usr/bin/conmon
    version: 'conmon version 2.1.8, commit: '
  cpuUtilization:
    idlePercent: 94.04
    systemPercent: 1.29
    userPercent: 4.67
  cpus: 12
  databaseBackend: boltdb
  distribution:
    distribution: fedora
    variant: workstation
    version: "40"
  eventLogger: journald
  freeLocks: 1931
  hostname: xps13a.happyassassin.net
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 524288
      size: 65536
    uidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 524288
      size: 65536
  kernel: 6.8.0-0.rc3.20240209git1f719a2f3fa6.31.fc40.x86_64
  linkmode: dynamic
  logDriver: journald
  memFree: 963268608
  memTotal: 16369684480
  networkBackend: netavark
  networkBackendInfo:
    backend: netavark
    dns:
      package: aardvark-dns-1.10.0-1.fc40.x86_64
      path: /usr/libexec/podman/aardvark-dns
      version: aardvark-dns 1.10.0
    package: netavark-1.10.2-1.fc40.x86_64
    path: /usr/libexec/podman/netavark
    version: netavark 1.10.2
  ociRuntime:
    name: crun
    package: crun-1.14.1-1.fc40.x86_64
    path: /usr/bin/crun
    version: |-
      crun version 1.14.1
      commit: de537a7965bfbe9992e2cfae0baeb56a08128171
      rundir: /run/user/1000/crun
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +LIBKRUN +WASM:wasmedge +YAJL
  os: linux
  pasta:
    executable: /usr/bin/pasta
    package: passt-0^20231230.gf091893-3.fc40.x86_64
    version: |
      pasta 0^20231230.gf091893-3.fc40.x86_64
      Copyright Red Hat
      GNU General Public License, version 2 or later
        <https://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
      This is free software: you are free to change and redistribute it.
      There is NO WARRANTY, to the extent permitted by law.
  remoteSocket:
    exists: false
    path: /run/user/1000/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.2-2.fc40.x86_64
    version: |-
      slirp4netns version 1.2.2
      commit: 0ee2d87523e906518d34a6b423271e4826f71faf
      libslirp: 4.7.0
      SLIRP_CONFIG_VERSION_MAX: 4
      libseccomp: 2.5.3
  swapFree: 4188852224
  swapTotal: 8589930496
  uptime: 96h 19m 41.00s (Approximately 4.00 days)
  variant: ""
plugins:
  authorization: null
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  - ipvlan
  volume:
  - local
registries:
  search:
  - registry.fedoraproject.org
  - registry.access.redhat.com
  - docker.io
  - quay.io
store:
  configFile: /home/adamw/.config/containers/storage.conf
  containerStore:
    number: 7
    paused: 0
    running: 0
    stopped: 7
  graphDriverName: overlay
  graphOptions: {}
  graphRoot: /home/adamw/.local/share/containers/storage
  graphRootAllocated: 510389125120
  graphRootUsed: 267405070336
  graphStatus:
    Backing Filesystem: btrfs
    Native Overlay Diff: "true"
    Supports d_type: "true"
    Supports shifting: "false"
    Supports volatile: "true"
    Using metacopy: "false"
  imageCopyTmpDir: /var/tmp
  imageStore:
    number: 106
  runRoot: /run/user/1000/containers
  transientStore: false
  volumePath: /home/adamw/.local/share/containers/storage/volumes
version:
  APIVersion: 5.0.0-rc1
  Built: 1707485814
  BuiltTime: Fri Feb  9 05:36:54 2024
  GitCommit: ""
  GoVersion: go1.22rc2
  Os: linux
  OsArch: linux/amd64
  Version: 5.0.0-rc1

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

podman-5.0.0~rc1-2.fc40.x86_64

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

- name: Create the pod
  containers.podman.podman_pod:
    name: bodhi-dev
    state: started
    publish:
      - "6543:6543"
      - "6544:6544"
      - "6545:6545"
      - "6546:6546"
      - "15672:15672"

Command line and output of ansible run with high verbosity

See above.

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

AdamWill commented 7 months ago

Poking through the code a bit, it looks like podman pod inspect (somepod) now returns a list of dicts; for my case, it seems to be a list containing a single dict. Before I'm guessing it just returned a dict - that's certainly what this sample output from the 4.4 docs shows.

AdamWill commented 7 months ago

Aha, it was https://github.com/containers/podman/pull/21514 .