ansible-role-docker
ansible-role-docker copied to clipboard
Role fails if docker repository is already on the host but wasn't added by ansible
I'm running on Debian 11. The role failed because I already had an existing file in /etc/apt/sources.list.d/
called docker.list
. This is how the Docker install instructions recommend adding it when installing manually: https://docs.docker.com/engine/install/debian/#set-up-the-repository
I took a quick look and am guessing this is just a limitation of ansible.builtin.apt_repository
, which adds a file called download_docker_com_linux_debian.list
with the same repo. I guess it's not smart enough to actually check what repos are installed first, because its not exactly trivial.
As a workaround, it might be worth adding a task to grep the files in /etc/apt/sources.list.d
for the repository that is about to be added and skip if it already exists. Or just delete any /etc/apt/sources.list.d/docker.list
. Or something similar...
E: Conflicting values set for option Signed-By regarding source https://download.docker.com/linux/debian/ bullseye: /usr/share/keyrings/docker-archive-keyring.gpg !=
E: The list of sources could not be read.
Since this role is meant to be used on a clean installation where Docker has not been set up before, I'm more tempted to close this as a 'wontfix', just because I don't think this is something I'd want to hardcode an additional check for.
this role is meant to be used on a clean installation where Docker has not been set up before
Is there something in particular about the role that makes this so? It should be idempotent, right? Aside from this particular issue with the apt_repository
module, I didn't see anything else that would cause problems. And indeed, when I removed docker.list
from my host that had docker installed already, everything worked fine. It also upgrades the docker version just fine.
To be fair, it may be better to fix this upstream...
I just came here because I wanted to request changing the apt filename from download_docker_com_linux_debian.list
to simply docker.list
as explained in the upstream Docker installation tutorial (https://docs.docker.com/engine/install/debian/).
Is there a reason for not setting the filename
when calling the apt_repository
module? I suggest to set it to docker
just as explained in the upstream tutorial.
It would also be possible to make this configurable as proposed in #101, however this PR has been closed already.
This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!
Please read this blog post to see the reasons why I mark issues as stale.
Not stale
I'd be willing to merge a PR that makes the filename configurable — that issue (#101) was an issue, not a PR though?
Ah, I see the PR is https://github.com/geerlingguy/ansible-role-docker/pull/102/files — that PR needs some tweaks, but something similar could work. I would like to see the default either be ""
and add default(omit)
to the setting in the task, or maybe some other way of making sure it's obvious it's a string.
We could maybe even default it to docker
, though I'd need to remember to bump the role a major version since that can be a breaking change.
I just released a 5.0.0 with some breaking changes, so I think for now we'd keep the same for compatibility with existing role users, but we could consider changing the default later on.
@geerlingguy please see #368 for this, and #369 for some related changes for when you decide to push 6.0.0
This would be useful for case when adding the repository does not work properly. In my case, armhf
repository is not added resulting in No package matching 'docker-ce' is available
. When I add the repository manually according to docker guide it works fine.
Im having a similar issues. Just does not make sense.
ubuntu@k8s-node-1:~$ sudo cat /etc/apt/sources.list.d/download_docker_com_linux_ubuntu.list
deb [arch=amd64] https://download.docker.com/linux/ubuntu jammy stable
TASK [geerlingguy.docker : Install Docker packages (with downgrade option).] ********************************************************************************************************************************************
fatal: [k8s-node-1]: FAILED! => {"changed": false, "msg": "No package matching 'docker-ce-20.10.23' is available"}
fatal: [k8s-master-1]: FAILED! => {"changed": false, "msg": "No package matching 'docker-ce-20.10.23' is available"}
If i leave it to latest it installs the latest, but when i mention a specific version it fails.
task
---
- hosts: masters,workers
become: yes
become_method: sudo
vars:
pip_install_packages:
- name: docker
docker_edition: 'ce'
docker_packages:
- 'docker-ce-20.10.23'
- 'docker-ce-cli-20.10.23'
docker_packages_state: present
docker_users: [ubuntu]
roles:
- geerlingguy.pip
- geerlingguy.docker
@lhoracek and @geerlingguy any idea why its behaving like this?
I did a manual apt update, no luck.
Closed by #369