Skip to content

feat: Use docker connection variables specified in 'platforms'#354

Open
adam-bishop wants to merge 1 commit intoansible-community:mainfrom
adam-bishop:main
Open

feat: Use docker connection variables specified in 'platforms'#354
adam-bishop wants to merge 1 commit intoansible-community:mainfrom
adam-bishop:main

Conversation

@adam-bishop
Copy link

Currently, the connection attributes specified in platforms are ignored, despite being in the schema. They're wired up but the 'sanity' check assumes that any config for connecting to dockerd comes from environment variables so unless you're using dockerd locally or executing molecule on a container host directly, the check will fail. It also assumes that one would only ever want to connect to a single dockerd.

This causes some weird behaviour - because the variables are wired up in the playbooks, molecule will run the sanity checks against your local dockerd, and then run the tests against the configured one - meaning your tests will randomly fail depending on whether you've got dockerd running locally, even though it's not used.

This change preserves the existing behaviour as far as possible as it still looks at the environment first and attempts to connect with defaults. If that fails, it then looks for connection details specified as attributes in each platform entry. It should also be possible to run tests on different dockerd instances (e.g. to target aarch64 and x86_64).

Some changes were needed to create/destroy.yml, as the connection variables weren't used for the network create/update operations.

Error handling is improved a little, as it wasn't obvious why the 'sanity' checks were failing.

There are some CI failures, but I believe they're unrelated.

With two platforms defined - one pointing to unix:///Users/adamb/.rd/docker.sock and the other to unix:///Users/adamb/.rd/docker2.sock

...
INFO     Sanity checks: 'docker'
INFO     Successfully connected using settings defined in fedora
INFO     Successfully connected using settings defined in bedora
...
TASK [Check presence of custom Dockerfiles] ************************************
ok: [localhost] => (item=fedora) => {"ansible_loop_var": "item", "changed": false, "item": {"docker_host": "unix:///Users/adamb/.rd/docker.sock", "docker_networks": [{"ipam_config": [{"gateway": "10.3.1.254", "subnet": "10.3.1.0/24"}], "name": "foo"}], "image": "fedora:latest", "name": "fedora", "networks": [{"name": "foo"}, {"name": "bar"}]}, "stat": {"exists": false}}
ok: [localhost] => (item=bedora) => {"ansible_loop_var": "item", "changed": false, "item": {"docker_host": "unix:///Users/adamb/.rd/docker2.sock", "docker_networks": [{"ipam_config": [{"gateway": "10.3.1.254", "subnet": "10.3.1.0/24"}], "name": "foo"}], "image": "fedora:latest", "name": "bedora", "networks": [{"name": "foo"}, {"name": "bar"}]}, "stat": {"exists": false}}

@adam-bishop adam-bishop changed the title Use docker connection variables specified in 'platforms' feat: Use docker connection variables specified in 'platforms' Jan 23, 2026
@github-actions github-actions bot added the feat label Jan 23, 2026
@github-actions github-actions bot added feat and removed feat labels Jan 23, 2026
@adam-bishop adam-bishop marked this pull request as ready for review January 23, 2026 00:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant