geerlingguy / ansible-role-docker

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

Task 'Add Docker apt key' fails on Pop_OS! 22.04 #382

Closed pypeaday closed 1 year ago

pypeaday commented 1 year ago

Love this role! I'm trying to use it to get docker up and running on my new desktop, I see that there was a fix rolled in a couple months ago to address the deprecation of adding gpg keys. My system tries that task because I get a 404 in the Add Docker apt key task which is supposed to write to /etc/apt/trusted/gpg.d/docker.asc.

OS: Pop_OS! 22.04 ansible version: 2.10.8

TASK [geerlingguy.docker : Add Docker apt key.] *******************************************************************************************
task path: /home/nic/.ansible/roles/geerlingguy.docker/tasks/setup-Debian.yml:28
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: nic
<127.0.0.1> EXEC /bin/sh -c 'echo ~nic && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/nic/.ansible/tmp `"&& mkdir "` echo /home/nic/.ansible/tmp/ansible-tmp-1666793580.0911322-1284764-100212532572354 `" && echo ansible-tmp-1666793580.0911322-1284764-100212532572354="` echo /home/nic/.ansible/tmp/ansible-tmp-1666793580.0911322-1284764-100212532572354 `" ) && sleep 0'
Using module file /usr/lib/python3/dist-packages/ansible/modules/get_url.py
<127.0.0.1> PUT /home/nic/.ansible/tmp/ansible-local-1283842nmp4rqwc/tmpj2i8e42x TO /home/nic/.ansible/tmp/ansible-tmp-1666793580.0911322-1284764-100212532572354/AnsiballZ_get_url.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/nic/.ansible/tmp/ansible-tmp-1666793580.0911322-1284764-100212532572354/ /home/nic/.ansible/tmp/ansible-tmp-1666793580.0911322-1284764-100212532572354/AnsiballZ_get_url.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'sudo -H -S  -p "[sudo via ansible, key=piynqceudsljhelgfcpsenhouvoqrzbj] password:" -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-piynqceudsljhelgfcpsenhouvoqrzbj ; /usr/bin/python3 /home/nic/.ansible/tmp/ansible-tmp-1666793580.0911322-1284764-100212532572354/AnsiballZ_get_url.py'"'"' && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/nic/.ansible/tmp/ansible-tmp-1666793580.0911322-1284764-100212532572354/ > /dev/null 2>&1 && sleep 0'
fatal: [localhost]: FAILED! => {
    "changed": false,
    "dest": "/etc/apt/trusted.gpg.d/docker.asc",
    "elapsed": 0,
    "invocation": {
        "module_args": {
            "attributes": null,
            "backup": false,
            "checksum": "",
            "client_cert": null,
            "client_key": null,
            "dest": "/etc/apt/trusted.gpg.d/docker.asc",
            "force": true,
            "force_basic_auth": false,
            "group": null,
            "headers": null,
            "http_agent": "ansible-httpget",
            "mode": "0644",
            "owner": null,
            "selevel": null,
            "serole": null,
            "setype": null,
            "seuser": null,
            "sha256sum": "",
            "timeout": 10,
            "tmp_dest": null,
            "unsafe_writes": false,
            "url": "https://download.docker.com/linux/pop!_os/gpg",
            "url_password": null,
            "url_username": null,
            "use_proxy": true,
            "validate_certs": true
        }
    },
    "msg": "Request failed",
    "response": "HTTP Error 404: Not Found",
    "status_code": 404,
    "url": "https://download.docker.com/linux/pop!_os/gpg"
}
pypeaday commented 1 year ago

I'm still very new to ansible, but I think the url just needs to be .../linux/ubuntu/gpg instead of .../linux/pop!_os/gpg. Can the task do that kind of string replacement?

pypeaday commented 1 year ago

I see that I can just set a variable docker_apt_gpg_key to https://download.docker.com/linux/ubuntu/gpg...

Same issue with the Task Add Docker repository in setup-Debian.yml. Trying a similar fix to set the variable docker_apt_repository but no luck yet with setting the right URL

Example: tried "https://download.docker.com/linux/ubuntu jammy stable" but get an error of Invalid repository string: <url>

pypeaday commented 1 year ago

Sorry for the spam - basically debugging in real time...

The solution for the apt repository is docker_apt_repository: deb https://download.docker.com/linux/ubuntu jammy stable

I don't really know how to roll this in but no one has time to prioritize it I could give it a shot or if it just needs documented I can add some and PR

xucian commented 1 year ago

I guess that worked on your machine. I'm getting "Conflicting values set for option Signed-By regarding source https://download.docker.com/linux/ubuntu/ focal"

Any status/update for this issue?

pypeaday commented 1 year ago

That looks like you're trying to configure on Ubuntu 20.04 (focal fossa) rather than 22.04 (jammy jellyfish). I don't have any immediate ideas on anything other than to point that out - can you link your playbook? It might just be a misconfigured variable

xucian commented 1 year ago

focal

Thanks for the timely reply. I changed it to focal, with no luck:

- hosts: nodes
  become: yes

  # Only needed if you want to build docker images on the remote machine
  # vars:
  #   pip_install_packages:
  #     - name: docker

  roles:
    # Only needed if you want to build docker images on the remote machine
    # - role: geerlingguy.pip

    - role: geerlingguy.docker
      # Main params
      docker_edition: 'ce'
      docker_packages:
          - "docker-{{ docker_edition }}"
          - "docker-{{ docker_edition }}-cli"
          - "docker-{{ docker_edition }}-rootless-extras"
      docker_packages_state: present
      # Additional params
      docker_install_compose_plugin: false
      docker_compose_package: docker-compose-plugin
      docker_compose_package_state: present
      # A list of users who will be added to the docker group.
      docker_users:
        - "{{ ansible_user_id }}"
      docker_daemon_options:
        # Custom dockerd options can be configured through this dictionary representing the json file /etc/docker/daemon.json
        # Added: overlay2 is the new recommended driver: https://docs.docker.com/storage/storagedriver/select-storage-driver
        storage-driver: "overlay2"
        log-opts:
          max-size: "100m"
      docker_apt_repository: deb https://download.docker.com/linux/ubuntu focal stable

Edit: Using Ubuntu 20.04, yes

pypeaday commented 1 year ago

Ok so the relevant docker variables in my playbook are:

    # docker
    docker_compose_version: "1.29.1"
    docker_apt_gpg_key: "https://download.docker.com/linux/ubuntu/gpg"
    docker_apt_repository: "deb https://download.docker.com/linux/ubuntu jammy stable"

I opened this issue for Pop_OS! 22.04 which is based on Ubuntu 22.04 - Jammy Jellyfish. You haven't confirmed if you're running an 20.04 or 22.04 distribution. I believe this works just fine on Ubuntu 20 and 22, the problem being that the discovered OS is Pop_OS relies on the Ubuntu releases of Docker, not a Pop_OS release.

stale[bot] commented 1 year 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.

stale[bot] commented 1 year ago

This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details.