Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot create Docker images using Molecule due to _api.credentials.errors #3934

Closed
Tom-Kun opened this issue Jun 14, 2023 · 1 comment
Closed
Labels

Comments

@Tom-Kun
Copy link

Tom-Kun commented Jun 14, 2023

Issue Type

  • Bug report

Molecule and Ansible details

ansible --version
ansible [core 2.14.6]
  config file = /home/etba/.ansible.cfg
  configured module search path = ['/home/etba/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules', '/usr/lib/python3/dist-packages/ansible/modules', '/home/etba/monitoring-global/ansible/library']
  ansible python module location = /home/etba/ansible-7.6.0/lib/python3.10/site-packages/ansible
  ansible collection location = /home/etba/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/etba/ansible-7.6.0/bin/ansible
  python version = 3.10.9 (main, Dec  7 2022, 01:12:00) [GCC 9.4.0] (/home/etba/ansible-7.6.0/bin/python)
  jinja version = 3.1.2
  libyaml = True
molecule 5.0.1 using python 3.10
    ansible:2.14.6
    azure:23.4.1 from molecule_plugins
    containers:23.4.1 from molecule_plugins requiring collections: ansible.posix>=1.3.0 community.docker>=1.9.1 containers.podman>=1.8.1
    delegated:5.0.1 from molecule
    docker:23.4.1 from molecule_plugins requiring collections: community.docker>=3.0.2 ansible.posix>=1.4.0
    ec2:23.4.1 from molecule_plugins
    gce:23.4.1 from molecule_plugins requiring collections: google.cloud>=1.0.2 community.crypto>=1.8.0
    podman:23.4.1 from molecule_plugins requiring collections: containers.podman>=1.7.0 ansible.posix>=1.3.0
    vagrant:23.4.1 from molecule_plugins

Docker version used is on a WSL2 with a Docker Desktop v.4.19.0 and a Docker Engine version 24.0.2.

Molecule installation method (one of):

  • pip using a virtualenv

Ansible installation method (one of):

  • pip using a virtualenv

Detail any linters or test runners used:

Desired Behavior

Getting the Docker image build by Ansible using the molecule test or molecule create commands with Docker containers up and running.

Actual Behaviour

For some weird reasons, the molecule create or molecule test command failed at the Ansible task "Build an Ansible compatible image (new)" with the following error message :

The error was: ansible_collections.community.docker.plugins.module_utils._api.credentials.errors.StoreError: Unexpected OS error "Exec format error", errno=8

The error seems to happend in the following playbook file : $INSTALLATION_MOLECULE_PATH_USING_PIP/lib/python3.10/site-packages/molecule_plugins/docker/playbooks/create.yml

The complete error even with the verbose debug -vvvv is the following :

"module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_community.docker.docker_image_payload_v1a8gthl/ansible_community.docker.docker_image_payload.zip/ansible_collections/community/docker/plugins/module_utils/_api/credentials/store.py\", line 91, in _execute\n  File \"/usr/lib/python3.10/subprocess.py\", line 421, in check_output\n    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,\n  File \"/usr/lib/python3.10/subprocess.py\", line 503, in run\n    with Popen(*popenargs, **kwargs) as process:\n  File \"/usr/lib/python3.10/subprocess.py\", line 971, in __init__\n    self._execute_child(args, executable, preexec_fn, close_fds,\n  File \"/usr/lib/python3.10/subprocess.py\", line 1847, in _execute_child\n    raise child_exception_type(errno_num, err_msg, err_filename)\nOSError: [Errno 8] Exec format error: '/usr/bin/docker-credential-desktop.exe'\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File \"/tmp/.ansible/ansible-tmp-1686758528.644757-23166-178765827922751/AnsiballZ_docker_image.py\", line 107, in <module>\n    _ansiballz_main()\n  File \"/tmp/.ansible/ansible-tmp-1686758528.644757-23166-178765827922751/AnsiballZ_docker_image.py\", line 99, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/tmp/.ansible/ansible-tmp-1686758528.644757-23166-178765827922751/AnsiballZ_docker_image.py\", line 47, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.community.docker.plugins.modules.docker_image', init_globals=dict(_module_fqn='ansible_collections.community.docker.plugins.modules.docker_image', _modlib_path=modlib_path),\n  File \"/usr/lib/python3.10/runpy.py\", line 224, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib/python3.10/runpy.py\", line 96, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/usr/lib/python3.10/runpy.py\", line 86, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_community.docker.docker_image_payload_v1a8gthl/ansible_community.docker.docker_image_payload.zip/ansible_collections/community/docker/plugins/modules/docker_image.py\", line 962, in <module>\n  File \"/tmp/ansible_community.docker.docker_image_payload_v1a8gthl/ansible_community.docker.docker_image_payload.zip/ansible_collections/community/docker/plugins/modules/docker_image.py\", line 951, in main\n  File \"/tmp/ansible_community.docker.docker_image_payload_v1a8gthl/ansible_community.docker.docker_image_payload.zip/ansible_collections/community/docker/plugins/modules/docker_image.py\", line 416, in __init__\n  File \"/tmp/ansible_community.docker.docker_image_payload_v1a8gthl/ansible_community.docker.docker_image_payload.zip/ansible_collections/community/docker/plugins/modules/docker_image.py\", line 450, in present\n  File \"/tmp/ansible_community.docker.docker_image_payload_v1a8gthl/ansible_community.docker.docker_image_payload.zip/ansible_collections/community/docker/plugins/modules/docker_image.py\", line 760, in build_image\n  File \"/tmp/ansible_community.docker.docker_image_payload_v1a8gthl/ansible_community.docker.docker_image_payload.zip/ansible_collections/community/docker/plugins/module_utils/_api/api/client.py\", line 509, in _set_auth_headers\n  File \"/tmp/ansible_community.docker.docker_image_payload_v1a8gthl/ansible_community.docker.docker_image_payload.zip/ansible_collections/community/docker/plugins/module_utils/_api/auth.py\", line 299, in get_all_credentials\n  File \"/tmp/ansible_community.docker.docker_image_payload_v1a8gthl/ansible_community.docker.docker_image_payload.zip/ansible_collections/community/docker/plugins/module_utils/_api/credentials/store.py\", line 83, in list\n  File \"/tmp/ansible_community.docker.docker_image_payload_v1a8gthl/ansible_community.docker.docker_image_payload.zip/ansible_collections/community/docker/plugins/module_utils/_api/credentials/store.py\", line 114, in _execute\nansible_collections.community.docker.plugins.module_utils._api.credentials.errors.StoreError: Unexpected OS error \"Exec format error\", errno=8

Other informations :

  • molecule.yml
---
dependency:
  name: galaxy
driver:
  name: docker
scenario:
  test_sequence:
    - destroy
    - dependency
    - syntax
    - create
    - check
    - converge
    - idempotence
    - verify
    - destroy
platforms:
  # Ubuntu Docker images
  - name: ubuntu-bionic
    image: ubuntu:bionic
    dockerfile: ../Dockerfile.j2
    privileged: true
    volumes:
      - "/sys/fs/cgroup:/sys/fs/cgroup:rw"
  - name: ubuntu-focal
    image: ubuntu:focal
    dockerfile: ../Dockerfile.j2
    privileged: true
    volumes:
      - "/sys/fs/cgroup:/sys/fs/cgroup:rw"
    command: "/sbin/init"
  - name: ubuntu-jammy
    image: ubuntu:jammy
    dockerfile: ../Dockerfile.j2
    privileged: true
    volumes:
      - "/sys/fs/cgroup:/sys/fs/cgroup:rw"
    command: "/sbin/init"
  # Debian Docker images
  - name: debian-11
    image: debian:11
    dockerfile: ../Dockerfile.j2
    privileged: true
    volumes:
      - "/sys/fs/cgroup:/sys/fs/cgroup:rw"
    command: "/sbin/init"
  - name: debian-12
    image: debian:12
    dockerfile: ../Dockerfile.j2
    privileged: true
    volumes:
      - "/sys/fs/cgroup:/sys/fs/cgroup:rw"
    command: "/sbin/init"
provisioner:
  name: ansible
  config_options:
    defaults:
      remote_tmp: /tmp/.ansible
  playbooks:
    converge: converge.yml
    verify: verify.yml
  • Dockerfile.j2
# Molecule managed

{% if item.registry is defined %}
FROM {{ item.registry.url }}/{{ item.image }}
{% else %}
FROM {{ item.image }}
{% endif %}

{% if item.env is defined %}
{% for var, value in item.env.items() %}
{% if value %}
ENV {{ var }} {{ value }}
{% endif %}
{% endfor %}
{% endif %}

RUN \
  # Debian/Ubuntu
  apt-get update \
  && DEBIAN_FRONTEND=noninteractive apt-get install -y dbus aptitude bash dirmngr iproute2 python3 python3-apt procps sudo systemd systemd-sysv \
  && apt-get clean; \

Before upgrading the Molecule and the Ansible version it was working perfectly. Maybe there is an issue with a Python conflict packages such as requests and docker.

pip freeze
ansible==7.6.0
ansible-compat==3.0.2
ansible-core==2.14.6
ansible-lint==6.16.2
cookiecutter==2.1.1
cryptography==41.0.1
distro==1.8.0
docker==6.1.3
enrich==1.2.7
Jinja2==3.1.2
jinja2-time==0.2.0
molecule==5.0.1
molecule-plugins==23.4.1
netaddr==0.8.0
PyYAML==6.0
requests==2.31.0
urllib3==1.26.16
yamllint==1.32.0

I have no idea what's going on and why this is happening and I'll appreciate some help on the subject. :)

Kind regards,
Tom

@Tom-Kun Tom-Kun added the bug label Jun 14, 2023
@mcdonnnj
Copy link

You're probably running into microsoft/WSL#8952 when it tries to use a credentials helper since the error is: Exec format error: '/usr/bin/docker-credential-desktop.exe'. Try the fix mentioned in the issue I linked and see if it will work.

@ansible ansible locked and limited conversation to collaborators Jun 23, 2023
@ssbarnea ssbarnea converted this issue into discussion #3937 Jun 23, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
Projects
None yet
Development

No branches or pull requests

3 participants