geerlingguy / ansible-role-docker

Ansible Role - Docker
https://galaxy.ansible.com/geerlingguy/docker/
MIT License
1.8k stars 851 forks source link

Failure when adding docker repository #434

Open pantelis-karamolegkos opened 9 months ago

pantelis-karamolegkos commented 9 months ago

I am installing the role as follows

    - name: Install required ansible-galaxy roles
      local_action: shell ansible-galaxy install -r requirements.yaml --force

where

$ cat requirements.yaml
- src: geerlingguy.docker

and then invoking it

    - name: Install docker and docker-compose
      include_role:
        name: geerlingguy.docker
        apply:
          become: yes
      vars:
        docker_compose_path: "/usr/local/bin/docker-compose"
        docker_compose_version: "1.27.4"

This fails with the following error

│ TASK [geerlingguy.docker : Add Docker repository.]
│ *****************************
│ An exception occurred during task execution. To see the full traceback, use
│ -vvv. The error was: apt_pkg.Error: E:Conflicting values set for option
│ Signed-By regarding source https://download.docker.com/linux/ubuntu/ focal:
│ /etc/apt/trusted.gpg.d/docker.asc != , E:The list of sources could not be
│ read.

ansible runs on the following machine

$ cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.2 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.2 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

Any suggestions?

pantelis-karamolegkos commented 9 months ago

@geerlingguy does it have to do maybe with this commit? was the initial name of the list file download_docker_com_linux_ubuntu.list

kawadeomkar commented 9 months ago

Hey @pantelis-karamolegkos I had the same issue and fixed it here https://github.com/geerlingguy/ansible-role-docker/pull/436 do you mind trying it out to see if it works for you? You first need to run

sudo rm /etc/apt/sources.list.d/docker.list
sudo rm /etc/apt/sources.list.d/download_docker_com_linux_ubuntu.list

in the respective environment

pantelis-karamolegkos commented 9 months ago

@kawadeomkar yes I tried that and it did solve the issue; I believe the problem relates to what I said in my last comment, i.e. to the renaming of the source file (although not 100% sure)

kawadeomkar commented 9 months ago

@pantelis-karamolegkos Yes I believe so as well. Not entirely sure but with the commit you mentioned, this addition:

docker_apt_filename: "docker"

I think may have caused the inconsistency with the Signed-by field. Previously it was named download_docker_com_linux_ubuntu but it is named docker now - so if you had run a previous version of this role you would get this error.

nerg4l commented 6 months ago

Is there a plan to make it backwards compatible or to pin this issue? All I had to do was remove those files but I use Ansible to avoid touching my servers.

quiqueg commented 5 months ago

Looks like the change was intentional, and some notes were added to the README.md here (emphasis mine):

docker_apt_filename controls the name of the source list file created in sources.list.d. If you are upgrading from an older (<7.0.0) version of this role, you should change this to the name of the existing file (e.g. download_docker_com_linux_debian on Debian) to avoid conflicting lists.

I read through the whole diff before upgrading, yet still missed this :)

Perhaps a CHANGELOG.md or some other lightweight Migrating from v# in the README.md would help users to catch these types of issues before upgrading?

github-actions[bot] commented 1 month ago

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.