You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you run a docker_plugin task with states "present" or "enable" (maybe "disable" too) with ansible in check_mode (flag -C in command line), the task fails because it tries to query the docker API for information on the plugin when accessing the result property even though it is in check mode and the plugin is bound to be absent - thus causing the failure. I'm not sure what the proper behavior should be, but I believe the check run should not fail here.
The specific plugin I was trying to install is grafana/loki-docker-driver:latest, though I think that does not affect the issue.
The target machine for the deploy runs an Ubuntu 22.04.
STEPS TO REPRODUCE
If I understood the module's code correctly, any attempt to install/enable a docker plugin via the docker_plugin module while running Ansible in check mode will fail. As an example, for me it failed using the following task:
I'm not exactly sure what the result property should return in check mode (would None be acceptabe?) but the playbook as a whole should not fail since, in check mode, it assumes the plugin was properly installed.
ACTUAL RESULTS
This is the failure output only from the docker_plugin task. If more information is needed feel free to ask. I'm showing only this part because I'm afraid of inadvertedly sharing sensible information on our development environment. Also, this was enough for me to find the problem in the module's source code after a while.
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_community.docker.docker_plugin_payload_ag90pjpr/ansible_community.docker.docker_plugin_payload.zip/ansible_collections/community/docker/plugins/module_utils/_api/api/client.py", line 259, in _raise_for_status
response.raise_for_status()
File "/usr/lib/python3/dist-packages/requests/models.py", line 940, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http+docker://localhost/v1.41/plugins/loki/json
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/tmp/ansible_community.docker.docker_plugin_payload_ag90pjpr/ansible_community.docker.docker_plugin_payload.zip/ansible_collections/community/docker/plugins/modules/docker_plugin.py", line 375, in main
File "/tmp/ansible_community.docker.docker_plugin_payload_ag90pjpr/ansible_community.docker.docker_plugin_payload.zip/ansible_collections/community/docker/plugins/modules/docker_plugin.py", line 353, in result
File "/tmp/ansible_community.docker.docker_plugin_payload_ag90pjpr/ansible_community.docker.docker_plugin_payload.zip/ansible_collections/community/docker/plugins/module_utils/_api/api/client.py", line 532, in get_json
return self._result(self._get(self._url(pathfmt, *args, versioned_api=True), **kwargs), json=True)
File "/tmp/ansible_community.docker.docker_plugin_payload_ag90pjpr/ansible_community.docker.docker_plugin_payload.zip/ansible_collections/community/docker/plugins/module_utils/_api/api/client.py", line 266, in _result
self._raise_for_status(response)
File "/tmp/ansible_community.docker.docker_plugin_payload_ag90pjpr/ansible_community.docker.docker_plugin_payload.zip/ansible_collections/community/docker/plugins/module_utils/_api/api/client.py", line 261, in _raise_for_status
raise_from(create_api_error_from_http_exception(e), e)
File "/tmp/ansible_community.docker.docker_plugin_payload_ag90pjpr/ansible_community.docker.docker_plugin_payload.zip/ansible_collections/community/docker/plugins/module_utils/_api/errors.py", line 45, in create_api_error_from_http_exception
raise_from(cls(e, response=response, explanation=explanation), e)
File "<string>", line 3, in raise_from
ansible_collections.community.docker.plugins.module_utils._api.errors.NotFound: 404 Client Error for http+docker://localhost/v1.41/plugins/loki/json: Not Found ("plugin "loki" not found")
fatal: [swarm_manager]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"alias": "loki",
"api_version": "auto",
"ca_cert": null,
"client_cert": null,
"client_key": null,
"debug": false,
"docker_host": "unix://var/run/docker.sock",
"enable_timeout": 0,
"force_remove": false,
"plugin_name": "grafana/loki-docker-driver:latest",
"plugin_options": {},
"ssl_version": null,
"state": "enable",
"timeout": 60,
"tls": false,
"tls_hostname": null,
"use_ssh_client": false,
"validate_certs": false
}
},
"msg": "An unexpected docker error occurred: 404 Client Error for http+docker://localhost/v1.41/plugins/loki/json: Not Found (\"plugin \"loki\" not found\")"
}
The text was updated successfully, but these errors were encountered:
SUMMARY
If you run a
docker_plugin
task with states "present" or "enable" (maybe "disable" too) with ansible in check_mode (flag-C
in command line), the task fails because it tries to query the docker API for information on the plugin when accessing theresult
property even though it is in check mode and the plugin is bound to be absent - thus causing the failure. I'm not sure what the proper behavior should be, but I believe the check run should not fail here.The specific plugin I was trying to install is
grafana/loki-docker-driver:latest
, though I think that does not affect the issue.ISSUE TYPE
COMPONENT NAME
docker_plugin
ANSIBLE VERSION
COLLECTION VERSION
CONFIGURATION
ansible-config dump --only-changed
output was emptyOS / ENVIRONMENT
This is happening to me when running a GitLab CI script on a "python" image and using roughly this sequence of commands for setup:
The target machine for the deploy runs an Ubuntu 22.04.
STEPS TO REPRODUCE
If I understood the module's code correctly, any attempt to install/enable a docker plugin via the
docker_plugin
module while running Ansible in check mode will fail. As an example, for me it failed using the following task:EXPECTED RESULTS
I'm not exactly sure what the
result
property should return in check mode (wouldNone
be acceptabe?) but the playbook as a whole should not fail since, in check mode, it assumes the plugin was properly installed.ACTUAL RESULTS
This is the failure output only from the
docker_plugin
task. If more information is needed feel free to ask. I'm showing only this part because I'm afraid of inadvertedly sharing sensible information on our development environment. Also, this was enough for me to find the problem in the module's source code after a while.The text was updated successfully, but these errors were encountered: