ansible/molecule

"Cannot autolaunch D-Bus without X11 $DISPLAY" while running tox test on dockerfile

zeitounator opened this issue · 0 comments

Issue Type

  • Bug report

Molecule and Ansible details

ansible --version && molecule --version
ansible [core 2.14.0]
  config file = None
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/user/Sources/molecule/.venv/lib/python3.9/site-packages/ansible
  ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/user/Sources/molecule/.venv/bin/ansible
  python version = 3.9.5 (default, Nov 23 2021, 15:27:38) [GCC 9.3.0] (/home/user/Sources/molecule/.venv/bin/python)
  jinja version = 3.1.2
  libyaml = True
INFO     Found config file /home/user/Sources/molecule/.config/molecule/config.yml
molecule 4.0.4.dev28 using python 3.9 
    ansible:2.14.0
    delegated:4.0.4.dev28 from molecule
    docker:2.1.0 from molecule_docker requiring collections: community.docker>=3.0.2 ansible.posix>=1.4.0

Molecule installation method (one of):

  • pip (editable inside a venv)

Ansible installation method (one of):

  • pip

Detail any linters or test runners used:
tox as configured in the molecule source tree

Desired Behavior

Running tox should run all tests and succeed (as long as current branch is ok). This includes dockerfile tests

Actual Behaviour

All of the below happens by simply running tox

I have the following configuration for my docker client (i.e. only relevant part) in ~/.docker/config.json

{
        "auths": {},
        "credsStore": "secretservice"
}

This instruct docker to store the credentials in my local linux keystore whenever I issue a docker login rather than in clear text inside the json file.

For a reason I did not yet understand and although none of the relevant builds require credentials for a any docker registry while running tox dockerfile tests, all image builds fail with the following error message (abridged) regardless of the origin of their base image.

TASK [Test Dockerfile template] ***********************************************************************

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ansible_collections.community.docker.plugins.module_utils._api.credentials.errors.StoreError: Credentials store docker-credential-secretservice exited with "Cannot autolaunch D-Bus without X11 $DISPLAY".

The workaround solution is actually trivial but I have no idea at this point if it is acceptable. I could fix by just adding a line to tox.ini, i.e.:

# do not put * in passenv as it may break builds do to reduced isolation
passenv =
    DISPLAY
    [... rest of existing env in file ...]

Let me know if this would be an acceptable change and also if you want a PR for this. Else I can give any other needed information if you need more details.