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
274 stars 148 forks source link

Podman collection does not work on my development environment #782

Closed JanMate closed 4 months ago

JanMate commented 5 months ago

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

/kind bug

/kind feature

Description

I cannot run containers.podman.podman_image in my ansible playbook due to:

fatal: [localhost]: FAILED! => {
    "msg": "Could not find imported module support code for common.  Looked for either LooseVersion.py or version.py"
}

Steps to reproduce the issue:

  1. add to your testing playbook:

    tasks:
    - name: installing podman
      package:
        name: "podman"
        state: present
    
    - name: Pull a specific version of an image
      containers.podman.podman_image:
        name: "redis"
        tag: "4"
  2. run it with ansible-playbook -i inventory.yaml my-playbook.yaml

  3. you can see the error (maybe)

Describe the results you received: I got an error message above.

Describe the results you expected: Running playbook

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 install containers.podman -f --force-with-deps

Process install dependency map
Starting collection install process
Installing 'containers.podman:1.15.1' to '/home/<username>/.ansible/collections/ansible_collections/containers/podman'

Output of ansible --version:

ansible 2.9.6
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/<username>/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.8.10 (default, Nov 22 2023, 10:22:35) [GCC 9.4.0]

Output of podman version:

Version:      3.4.2
API Version:  3.4.2
Go Version:   go1.15.2
Built:        Thu Jan  1 01:00:00 1970
OS/Arch:      linux/amd64

Output of podman info --debug:

host:
  arch: amd64
  buildahVersion: 1.23.1
  cgroupControllers: []
  cgroupManager: cgroupfs
  cgroupVersion: v1
  conmon:
    package: 'conmon: /usr/libexec/podman/conmon'
    path: /usr/libexec/podman/conmon
    version: 'conmon version 2.1.2, commit: '
  cpus: 8
  distribution:
    codename: focal
    distribution: ubuntu
    version: "20.04"
  eventLogger: file
  hostname: <hostname>
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
    uidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
  kernel: 5.10.102.1-microsoft-standard-WSL2
  linkmode: dynamic
  logDriver: k8s-file
  memFree: 6468243456
  memTotal: 13129265152
  ociRuntime:
    name: crun
    package: 'crun: /usr/bin/crun'
    path: /usr/bin/crun
    version: |-
      crun version UNKNOWN
      commit: ea1fe3938eefa14eb707f1d22adff4db670645d6
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +YAJL
  os: linux
  remoteSocket:
    path: /tmp/podman-run-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: false
  serviceIsRemote: false
  slirp4netns:
    executable: /usr/bin/slirp4netns
    package: 'slirp4netns: /usr/bin/slirp4netns'
    version: |-
      slirp4netns version 1.1.8
      commit: unknown
      libslirp: 4.3.1-git
      SLIRP_CONFIG_VERSION_MAX: 3
      libseccomp: 2.4.3
  swapFree: 4294967296
  swapTotal: 4294967296
  uptime: 72h 6m 40.55s (Approximately 3.00 days)
plugins:
  log:
  - k8s-file
  - none
  - journald
  network:
  - bridge
  - macvlan
  volume:
  - local
registries:
  search:
  - docker.io
  - quay.io
store:
  configFile: /home/<username>/.config/containers/storage.conf
  containerStore:
    number: 17
    paused: 0
    running: 0
    stopped: 17
  graphDriverName: overlay
  graphOptions:
    overlay.mount_program:
      Executable: /usr/bin/fuse-overlayfs
      Package: 'fuse-overlayfs: /usr/bin/fuse-overlayfs'
      Version: |-
        fusermount3 version: 3.9.0
        fuse-overlayfs: version 1.5
        FUSE library version 3.9.0
        using FUSE kernel interface version 7.31
  graphRoot: /home/<username>/.local/share/containers/storage
  graphStatus:
    Backing Filesystem: extfs
    Native Overlay Diff: "false"
    Supports d_type: "true"
    Using metacopy: "false"
  imageStore:
    number: 15
  runRoot: /tmp/podman-run-1000/containers
  volumePath: /home/<username>/.local/share/containers/storage/volumes
version:
  APIVersion: 3.4.2
  Built: 0
  BuiltTime: Thu Jan  1 01:00:00 1970
  GitCommit: ""
  GoVersion: go1.15.2
  OsArch: linux/amd64
  Version: 3.4.2

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

Listing... Done
podman/unknown,now 100:3.4.2-5 amd64 [installed]
podman/unknown 100:3.4.2-5 arm64
podman/unknown 100:3.4.2-5 armhf
podman/unknown 100:3.4.2-5 ppc64el
podman/unknown 100:3.4.2-5 s390x

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

- name: Pull, tag and push OCI images
  hosts: localhost
  connection: local
  gather_facts: false
  vars:
    tag: "4"
    images: []
  tasks:
    - name: installing podman
      package:
        name: "podman"
        state: present

    - name: Pull a specific version of an image
      containers.podman.podman_image:
        name: "redis"
        tag: "{{ tag }}"

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 2.9.6
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/<username>/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 3.8.10 (default, Nov 22 2023, 10:22:35) [GCC 9.4.0]
Using /etc/ansible/ansible.cfg as config file
host_list declined parsing /mnt/c/Users/<username>/repos/awx/inv_local.yaml as it did not pass its verify_file() method
Skipping empty key (localhost) in group (hosts)
Parsed /mnt/c/Users/<username>/repos/awx/inv_local.yaml inventory source with yaml plugin
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

PLAYBOOK: playbook.yaml *********************************************************************************************************************************************************************
1 plays in playbook.yaml

PLAY [Pull, tag and push OCI images] ****************************************************************************************************************************************************************************
META: ran handlers

TASK [installing podman] ****************************************************************************************************************************************************************************************
task path: /mnt/c/Users/<username>/repos/awx/playbook.yaml:32
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: <username>
<127.0.0.1> EXEC /bin/sh -c 'echo ~<username> && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/<username>/.ansible/tmp/ansible-tmp-1718012235.696705-75104995463721 `" && echo ansible-tmp-1718012235.696705-75104995463721="` echo /home/<username>/.ansible/tmp/ansible-tmp-1718012235.696705-75104995463721 `" ) && sleep 0'
Using module file /usr/lib/python3/dist-packages/ansible/modules/system/setup.py
<127.0.0.1> PUT /home/<username>/.ansible/tmp/ansible-local-290344hvuvw82/tmpu6yelmfl TO /home/<username>/.ansible/tmp/ansible-tmp-1718012235.696705-75104995463721/AnsiballZ_setup.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/<username>/.ansible/tmp/ansible-tmp-1718012235.696705-75104995463721/ /home/<username>/.ansible/tmp/ansible-tmp-1718012235.696705-75104995463721/AnsiballZ_setup.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python3 /home/<username>/.ansible/tmp/ansible-tmp-1718012235.696705-75104995463721/AnsiballZ_setup.py && sleep 0'
Using module file /usr/lib/python3/dist-packages/ansible/modules/packaging/os/apt.py
<127.0.0.1> PUT /home/<username>/.ansible/tmp/ansible-local-290344hvuvw82/tmpmh6ox_je TO /home/<username>/.ansible/tmp/ansible-tmp-1718012235.696705-75104995463721/AnsiballZ_apt.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/<username>/.ansible/tmp/ansible-tmp-1718012235.696705-75104995463721/ /home/<username>/.ansible/tmp/ansible-tmp-1718012235.696705-75104995463721/AnsiballZ_apt.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python3 /home/<username>/.ansible/tmp/ansible-tmp-1718012235.696705-75104995463721/AnsiballZ_apt.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/<username>/.ansible/tmp/ansible-tmp-1718012235.696705-75104995463721/ > /dev/null 2>&1 && sleep 0'
ok: [localhost] => {
    "cache_update_time": 1717773694,
    "cache_updated": false,
    "changed": false,
    "invocation": {
        "module_args": {
            "allow_unauthenticated": false,
            "autoclean": false,
            "autoremove": false,
            "cache_valid_time": 0,
            "deb": null,
            "default_release": null,
            "dpkg_options": "force-confdef,force-confold",
            "force": false,
            "force_apt_get": false,
            "install_recommends": null,
            "name": "podman",
            "only_upgrade": false,
            "package": [
                "podman"
            ],
            "policy_rc_d": null,
            "purge": false,
            "state": "present",
            "update_cache": null,
            "upgrade": null
        }
    }
}

TASK [Pull a specific version of an image] **********************************************************************************************************************************************************************
task path: /mnt/c/Users/<username>/repos/awx/playbook.yaml:37
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: <username>
<127.0.0.1> EXEC /bin/sh -c 'echo ~<username> && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/<username>/.ansible/tmp/ansible-tmp-1718012237.4058702-8317627162299 `" && echo ansible-tmp-1718012237.4058702-8317627162299="` echo /home/<username>/.ansible/tmp/ansible-tmp-1718012237.4058702-8317627162299 `" ) && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/<username>/.ansible/tmp/ansible-tmp-1718012237.4058702-8317627162299/ > /dev/null 2>&1 && sleep 0'
fatal: [localhost]: FAILED! => {
    "msg": "Could not find imported module support code for common.  Looked for either LooseVersion.py or version.py"
}

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

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

Running on Ubuntu 20 in WSL 2.0

sshnaidm commented 5 months ago

I don't think it's gonna play with Ansible 2.9. Either install ansible-core from latest versions, or use very old ansible-podman collection version (not recommended). pip install ansible-core Also Ubuntu 20 is very old. It's recommended 22.04 if not 24.04. Podman is officially supported only from 20.10 iirc. All these very old things might be incompatible with the new software.